Function::String 


FixedWidth
FixedWidth(Value,Position,Length)
FixedWidth("My Heading",1,40) -- return string where My Heading is centered in a 40 character long space padded string.
FixedWidth(MyValue,MyPosition,MyLength)

FixedWidth return a space (blank) padded string "Length" long where Value is positioned according to the position switch.

The purpose of the function is to make it easier to build columns in a text file/export/console output.

The function is created to make DFW more compatible with DFD style thinking and output.

Especially useful in combination with WriteToFile(), ConsoleCopy() etc.

Parameters

Value: String, but will automatically convert any DataEase field type to string. Can be up to 255 long.
Position:

0 = Left (Default) - "This is a test "
1= Center - " This is a test "
2= Right - " This is a test"
Length: The length of the padded string to be returned.

Returns/Result

String (up to 255) padded with blank to lenght.

Examples

Example 1:

define temp "retval" text .

define temp "spacer" text 255 .

define temp "line" text 69 .

define temp "looper" number .

looper := 0 .

spacer :=" " .

line := "-------------------------------------------------------------------------------------------------------------------------" .

while looper <25 do

retval := ConsoleCopy(" ",5+0) .

looper := Looper +1 .

end

looper := 0 .

retval := ConsoleCopy(" ",5+0) .

for WriteToFile with OrderNr = Data-entry Field1 ;

while MemoChunk(Header,Looper) not=blank do

retval := ConsoleCopy(MemoChunk(Header,Looper),0) .

looper :=looper + 1 .

end

retval := ConsoleCopy(" ",4+0) .

retval := ConsoleCopy(Subject,4+0) .

retval := ConsoleCopy(" ",4+0) .

retval :=ConsoleCopy(concat(FixedWidth("Productnr", 0 , 15),fixedWidth("Product Description", 0 , 29),FixedWidth("Price", 1+1 , 10),FixedWidth("#", 1+0 , 5),FixedWidth("Total",2+0,10)) , 4+0) .

retval := ConsoleCopy(line, 4+0) .

for Orderlines with Ordernr = WriteToFile Ordernr ;

retval := ConsoleCopy(concat(FixedWidth(productNr,0,15) ,FixedWidth(Description,0,29),FixedWidth(Prices,2,10),FixedWidth(Count ,2,5),FixedWidth(Total,2,10)), 4+0) .

end

retval := ConsoleCopy(" ",5+0) .

retval := ConsoleCopy(FixedWidth(concat("Total Order: ", Total Order),2,69),4+0) .

retval := ConsoleCopy(line, 4+0) .

retval := ConsoleCopy(" ",5+0) .

retval := ConsoleCopy(" ",5+0) .

Looper := 0 .

while MemoChunk(Footer,Looper) not=blank do

retval := ConsoleCopy(MemoChunk(Footer,Looper),0) .

looper :=looper + 1 .

end

retval := ConsoleShow(1) .