anixon Posted February 4, 2009 Share Posted February 4, 2009 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? CODEIf 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 More sharing options...
picaxe Posted February 4, 2009 Share Posted February 4, 2009 Try StringFormat Link to comment Share on other sites More sharing options...
jvanegmond Posted February 4, 2009 Share Posted February 4, 2009 (edited) 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 February 4, 2009 by Manadar github.com/jvanegmond Link to comment Share on other sites More sharing options...
anixon Posted February 4, 2009 Author Share Posted February 4, 2009 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"endifIf stringlen($variable1) <= 100 then $variable1 = $variable1 & "tab" Else $variable1 = $variable1 & "tab" & "tab"endifFileWriteLine($File, (@MDAY & "/" & @MON & "/" & @YEAR & " " & @HOUR & ":" & @MIN & ":" & @SEC _ $variable & $variable1))What do you think? Link to comment Share on other sites More sharing options...
jvanegmond Posted February 4, 2009 Share Posted February 4, 2009 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. github.com/jvanegmond Link to comment Share on other sites More sharing options...
anixon Posted February 5, 2009 Author Share Posted February 5, 2009 (edited) 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?CODEIf 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 TabIf 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 February 5, 2009 by anixon Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now