Jump to content
Rskm

allocate specific width for a number

Recommended Posts

Hi, i am writing an output to notepad. The output has few columns, the contents of which is all numbers (floats & or integers). The issue is that i cannot get the columns appear straight as if a number in the column becomes negative, it pushes the number in the next column to right or viceversa. So, is it possible to allocate a fixed number of columns per number

something like  Filewrite($notepad,my_format($xl_limit,10)&my_format($maxx,10)&my_format($pp_ar_total,10)).. where my_format would mean 10 columns to be allocated for the variable

 thanks 

Edited by Rskm
more explanation

Share this post


Link to post
Share on other sites

Yes you can with StringFormat ().  Look in help file, there is numerous examples how you can do it...

Edited by Nine

Share this post


Link to post
Share on other sites
19 minutes ago, Nine said:

Yes you can with StringFormat ().  Look in help file, there is numerous examples how you can do it...

Hi, I tried the below option 

Filewrite($notepad,stringformat("%-20.3",$xl_limit&$maxx&$pp_ar_total&@crlf)).  this is  just printing %-20.3 .. what i need is to print the variables xl_limit, maxx and pp_ar_total in a line with 20 columns allocated and with 3 decimals. 

Share this post


Link to post
Share on other sites

Try this :

Local $v1 = 124.22, $v2 = -2987.5, $v3 = 77777
ConsoleWrite (StringFormat ("% 20.3f% 20.3f% 20.3f", $v1, $v2, $v3) & @CRLF)
ConsoleWrite ("123456789012345678901234567890123456789012345678901234567890" & @CRLF)

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...