Jump to content
Sign in to follow this  
anixon

Column Positioned Text

Recommended Posts

anixon

This code does not line up in columns the text variables because the text variables vary in length. This is not resolved when in the FileWriteLine a & "space" & is replaced with a & "tab" &

Is there a way of setting the column position for each variable?

CODE
If FileExists($DailyLog) Then FileSetAttrib($DailyLog, "-R")

;//Open an existing file

$File = FileOpen($DailyLog, 9)

FileWriteLine($File, (@MDAY & "/" & @MON & "/" & @YEAR & " " & @HOUR & ":" & @MIN & ":" & @SEC _

& " " & $Chk & " " & $Author & " " &$Receipt & " " & $Num & " " & $Notes))

FileClose($File)

ProcessWaitClose($DailyLog, 30)

FileSetAttrib($DailyLog, "+R")

Assistance is always appreciated.. Ant..

Share this post


Link to post
Share on other sites
jvanegmond

I'm afraid not, anixon. There is no real method to detect when an extra space or tab is needed, because it depends on the editor that is showing you the file. The editor may choose to display in a different font, which can results in varying width.

You may want to try a different file format, such as HTML and output the text in tables (<table><tr><td>) so that the "editor" ( now a browser ) is forced to show them in the columns you want.

Edited by Manadar

Share this post


Link to post
Share on other sites
anixon

I'm afraid not, anixon. There is no real method to detect when an extra space or tab is needed, because it depends on the editor that is showing you the file. The editor may choose to display in a different font, which can results in varying width.

You may want to try a different file format, such as HTML and output the text in tables (<table><tr><td>) so that the "editor" ( now a browser ) is forced to show them in the columns you want.

The file being created is associated with Notebook and that applications default $font. Perhaps the file should just be comma delimited then parsed in Excel which would put each variable into column format. Or perhaps it is possible to calculate the length of each string and add 1 or two tabs as the case requires before recompile the string using those variables.

If stringlen($variable) <= 100 then

$variable = $variable & "tab"

Else

$variable = $variable & "tab" & "tab"

endif

If stringlen($variable1) <= 100 then

$variable1 = $variable1 & "tab"

Else

$variable1 = $variable1 & "tab" & "tab"

endif

FileWriteLine($File, (@MDAY & "/" & @MON & "/" & @YEAR & " " & @HOUR & ":" & @MIN & ":" & @SEC _

$variable & $variable1))

What do you think?

Share this post


Link to post
Share on other sites
jvanegmond

Adding a variable number of tabs is not a bad idea, but it would be much easier to just let this be parsed by whatever you're using to read it. I think writing a .csv file would be even a better, and much simpler, approach than making it write a HTML file.

Share this post


Link to post
Share on other sites
anixon

This code does not line up in columns the text variables because the text variables vary in length. This is not resolved when in the FileWriteLine a & "space" & is replaced with a & "tab" &

Is there a way of setting the column position for each variable?

CODE
If FileExists($DailyLog) Then FileSetAttrib($DailyLog, "-R")

;//Open an existing file

$File = FileOpen($DailyLog, 9)

FileWriteLine($File, (@MDAY & "/" & @MON & "/" & @YEAR & " " & @HOUR & ":" & @MIN & ":" & @SEC _

& " " & $Chk & " " & $Author & " " &$Receipt & " " & $Num & " " & $Notes))

FileClose($File)

ProcessWaitClose($DailyLog, 30)

FileSetAttrib($DailyLog, "+R")

Assistance is always appreciated.. Ant..

This was how the problem was solved and thanks to those who contributed to the posting Ant..

CODE
;//Set Column Format For $Author

If Stringlen($Author) <= 16 then $Tab = " " ; 2 x Tab

If StringLen($Author) > 16 then $Tab = " " ;1 x Tab

If FileExists($DailyLog) Then FileSetAttrib($DailyLog, "-R")

;//Open an existing file

$File = FileOpen($DailyLog, 9)

FileWriteLine($File, (@MDAY & "/" & @MON & "/" & @YEAR & " " & @HOUR & ":" & @MIN & ":" & @SEC _

& " " & $Chk & " " & $Author & $Tab & $Receipt & " " & $Num & " " & $Notes))

FileClose($File)

ProcessWaitClose($DailyLog, 30)

FileSetAttrib($DailyLog, "+R")

Edited by anixon

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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.