Simplicty and flexibility!


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) .

Reference

See Also


On the forum about FixedWidth

FixedWidth() - Return a blank padded, positioned String doesn't appear

Hello, I'm trying to use FixedWidth function but it doesn't appear on the function list. Why? I'm using Dataease version 8.0.0.1375. Thanks....

Product: Dataease [{8}]FIVE. Written by Marco Marchesi 14/11/13 at 13:50:29

Re:FixedWidth() - Return a blank padded, positioned String doesn't appear

Download SampleJust had to check, but FixedWidth was implemented in 8.0.0.1325 so if you are running 1375 you should be safely within t...

Product: Dataease [{8}]FIVE. Written by DataEase 14/11/13 at 17:02:34

Use of FixedWidth()

Hi,I am trying to create tabulated output for use in an HTML memo field.&nbsp; FixedWidth() seemed to be the solution but it pads the text with spaces which are ignored in HTML which looks for &amp;nbsp instead. Is there are a way around this?<...

Product: Dataease [{8}]FIVE. Written by Bill Nicholson 20/12/14 at 17:23:36

Re:Use of FixedWidth()

I have more or less answered my own question by use of the new function StringReplace() which I hadn't noticed before. It isn't however as simple as might be hoped.The first problem is that to replace a hard space with &amp;nbsp; means that we...

Product: Dataease [{8}]FIVE. Written by Bill Nicholson 21/12/14 at 08:24:51

Re:Use of FixedWidth()

First question here is why do you want to use it in a HTML field when it formatted as a text field? Why not just create it as a text field and view it in a normal Memo field?...

Product: Dataease [{8}]FIVE. Written by DataEase 21/12/14 at 14:41:37

Re:Re:Use of FixedWidth()

First things first...&lt;p&gt;&amp;nbsp;009_EPC_EXHIBIT&amp;nbsp;IX&amp;nbsp;&amp;nbsp;&amp;nbsp;DIRECTIVES&amp;nbsp;OF&amp;nbsp;HEALTH&amp;nbsp;SAFETY&amp;nbsp;AND&amp;nbsp;ENVIRO...

Product: Dataease [{8}]FIVE. Written by DataEase 21/12/14 at 14:41:59

Re:Re:Use of FixedWidth()

Download Sample Hi Bill. You get 10 for the attempt and&nbsp;1 for style! I think this need a little "tough love" ;-)The worst approach you can have...

Product: Dataease [{8}]FIVE. Written by DataEase 21/12/14 at 16:20:51

Re:Re:Re:Use of FixedWidth()

OK I will look at your example with interest. I wanted to avoid tables (with which I am indeed familiar) because the number of lines of tabulated data is variable and I didn't see an easy way to achieve this using a table. Maybe your example will help...

Product: Dataease [{8}]FIVE. Written by Bill Nicholson 21/12/14 at 16:57:32

Re:Re:Re:Re:Use of FixedWidth()

You can build the table completely dynamically so that shouldn't be a problem.You can even add rows and span rows etc.HTML is fantastic when you get under its skin. We will follow up with a lot of samples/templates on how to use HTML i...

Product: Dataease [{8}]FIVE. Written by DataEase 21/12/14 at 18:18:00

Solution:How to align data on the right on a text field with FixedWidth() and StringTo().

Download Sample Thank you for giving us such a brilliant opportunity to show of some of the new and sadly not so well known functions in...

Product: Dataease [{8}]FIVE. Written by DataEase 13/02/15 at 18:13:40

Re:Solution:How to align data on the right on a text field with FixedWidth() and StringTo().

Great! It works well. I have another questiom. I have to format a field in this way "000000000.00" in a fixed text field within a length 12 char (padded with zeroes) . The input field is simply a number with 2 decimals. Take in mind that I'm in Italy...

Product: Dataease [{8}]FIVE. Written by Marco Marchesi 27/02/15 at 09:53:56

On the blog about FixedWidth

New Function in 8 - FixedWidth() - Return a blank padded, positioned String (Ver. 8.0.0.1325)

The DOS retro implementations in DE8 is not yet over. Today we released FixedWidth() which is a string function to help build text documents easier. FixedWidth(Value,Position,Length) will return a string Length long with Value positio...

Product: Dataease [{8}]FIVE. Written by DataEase 08/07/13 at 12:20:13

Developer Tips! FixedWidth() and StringTo() in practice ...

Download Sample Thank you for giving us such a brilliant opportunity to show of some of the new and sadly not so well known functions in...

Product: Dataease [{8}]FIVE. Written by DataEase 13/02/15 at 18:56:43


dg3_HelpView