Jump to content

Column Positioned Text


anixon
 Share

Recommended Posts

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

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...