dickieknee Posted March 24, 2006 Share Posted March 24, 2006 I would like to set a number of different tabs so that when i write the text to the file then it will all be aligned so if one colum has more than 16 characters and the next row in the same colums only has 2 characters then the next colum will not be aligned as the second row will tab to the first tab and the first row will tab to the second tab ie Col1 header Col2 header Col3 header text1ishereto text2ishere text3ishere text1 text2 text 3 i would like to set the tab positions so it looks like this tab1 tab2 position position set here set here | | Col1 header Col2 header Col3 header text1ishereto text2ishere text3ishere text1 text2 text 3 sorry i have no code ideas on how to do this thanks in advance Link to comment Share on other sites More sharing options...
seandisanti Posted March 24, 2006 Share Posted March 24, 2006 I would like to set a number of different tabs so that when i write the text to the file then it will all be alignedso if one colum has more than 16 characters and the next row in the same colums only has 2 characters then the next colum will not be aligned as the second row will tab to the first tab and the first row will tab to the second tabieCol1 header Col2 header Col3 headertext1ishereto text2ishere text3isheretext1 text2 text 3i would like to set the tab positions so it looks like this tab1 tab2 position position set here set here | |Col1 header Col2 header Col3 headertext1ishereto text2ishere text3isheretext1 text2 text 3sorry i have no code ideas on how to do thisthanks in advanceit sounds like you're trying to do a fixed width text file, the easiest way to do it (assuming you have all of your output in an array before writing it) would be to just figure out which element from each column has the most characters. then add spaces to each of the shorter elements until each element is the length of the longest plus a space or two gap. does that make sense? Link to comment Share on other sites More sharing options...
dickieknee Posted March 24, 2006 Author Share Posted March 24, 2006 it sounds like you're trying to do a fixed width text file, the easiest way to do it (assuming you have all of your output in an array before writing it) would be to just figure out which element from each column has the most characters. then add spaces to each of the shorter elements until each element is the length of the longest plus a space or two gap. does that make sense?yes thanks it does make sense, though i had hoped there may have been a way to set the tabs, this would have made the execution a tad faster Link to comment Share on other sites More sharing options...
billmez Posted March 25, 2006 Share Posted March 25, 2006 I would like to set a number of different tabs so that when i write the text to the file then it will all be aligned so if one colum has more than 16 characters and the next row in the same colums only has 2 characters then the next colum will not be aligned as the second row will tab to the first tab and the first row will tab to the second tab ie Col1 header Col2 header Col3 header text1ishereto text2ishere text3ishere text1 text2 text 3 i would like to set the tab positions so it looks like this tab1 tab2 position position set here set here | | Col1 header Col2 header Col3 header text1ishereto text2ishere text3ishere text1 text2 text 3 sorry i have no code ideas on how to do this thanks in advance $output &= "Col1 header" & @TAB & "Col2 header" & @TAB & "Col3 header" & @CRLF $output &= text1ishereto" & @TAB & "text2ishere" & @TAB & "text3ishere" & @CRLF $output &= text1" & @TAB & "text2" & @TAB & "text 3" & @CRLF FileWrite($FHandle, $output) Keep in mind that you may have to check the length of the output and headers, and if the output length is greater than the header length, add another tab to keep the alignment. To do that you would append the output to the output vatiable, and write the header line afterwards, then combine the adjusted header line with the output variable, and write to the file. 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