none
Print tabulated in video RRS feed

  • Question

  • Hello everyone, I apologize for my English, I'm using google translator
    I have a text file and should print out the values in the file on the screen, using the DrawText, but output is so not tabulated, but very staggered, you have any suggestions on how to solve this problem? or this thing is unsolvable

    T.U.

    Wednesday, July 22, 2015 12:25 PM

Answers

  • (translated by Google translator)

    In order for the program can print the text as a table, it is necessary to give to the program not the entire contents of a text file, but one word for one time, for example. To do this, you can save a text file with one word per line, and then read it using the command "File.ReadLine(filePath, lineNumber)".

    To print a table in the graphics window, you must specify the location for each new word.
    The following example will print the words in two columns

    For n = 1 To 10 Step 2
      m_text =   File.ReadLine(filePath, n)
      GraphicsWindow.DrawText(10, n * 20, m_text)
      m_text =     File.ReadLine(filePath, n + 1)
      GraphicsWindow.DrawText(200, n * 20, m_text)

    EndFor

    The program will print 5 rows and 2 columns.

    Sorry for the wait

    Wednesday, July 22, 2015 4:18 PM
  • You can get the contents of the document in 1 go using readContents.

    Then maybe, since you're looking for values, go at it like a wordprocessor - in the 1st instance looking for white space.

    contents = " blah descr beasts   feeffe    stati    rrer  rrr.    re, -     tttt"
    
    WHITESPACE = "1=10;2=11;3=12;4=13;5=32" 'define some whitespace
    
    For i = 1 To Text.GetLength(contents)  
      While Array.ContainsValue(WHITESPACE Text.GetCharacterCode(Text.GetSubText(contents i 1))) And i <= Text.GetLength(contents)     
        i = i + 1    
      EndWhile 
      
      j = j + 1
      While Array.ContainsValue(WHITESPACE Text.GetCharacterCode(Text.GetSubText(contents i 1))) = "False" And i <= Text.GetLength(contents)
        word[j] = word[j] + Text.GetSubText(contents i 1)
        i = i + 1    
      EndWhile 
    EndFor
    
    columns = 5
    colWidth = GraphicsWindow.Width / columns
    
    For j = 1 To Math.Ceiling(Array.GetItemCount(word) / columns)
      For i = 1 To columns
        k = k + 1
        GraphicsWindow.DrawText(colWidth * (i-1), 25 * (j-1), word[k])  
      EndFor
    EndFor


    Wednesday, July 22, 2015 10:56 PM
    Moderator

All replies

  • You could try someting along these lines:

    t[1]="1=abc;2=QWERTY"
    t[2]="1=iiiiij;2=PO"
    t[3]="1=wwmmww;2=AA"
    t[4]="1=A;2=ZZZZZZ"
    
    For i=1 To 4
      For j=1 to 2
        lenT=Text.GetLength(t[i][j])
        GraphicsWindow.DrawText(20-lenT+70*(j-1),20*i,t[i][j])
      EndFor 
    EndFor

    Output:


    Jan [ WhTurner ] The Netherlands

    Wednesday, July 22, 2015 1:35 PM
    Answerer
  • Give us your code...
    Wednesday, July 22, 2015 1:39 PM
  • I have a text file made up of four fields, an index field, a field name, a description field 1, and a description field 2
    and I have to print to video the values in this file, but the values are not in line, that are printed like this:
    1 blah descr beasts
    2   feeffe    stati    rrer
    3  rrr      re          tttt
    ie they are not tabulated as in the text file
    Wednesday, July 22, 2015 2:35 PM
  • Therefore, I ask to give us the code of your program.

    Without the code we can not find your problem.

    Wednesday, July 22, 2015 2:50 PM
  • the code that I made is simple and of three lines 

    filepath = Program.Directory + "/appoggioFile.txt"
    read = File.ReadContents(filepath)
    GraphicsWindow.DrawText(10,10,read)

    the main problem is just the tab that I can not set it for good

    Wednesday, July 22, 2015 3:00 PM
  • Please wait for some time...
    Wednesday, July 22, 2015 3:14 PM
  • If the data in the file is comma-sererated, you have to split it in fields and print each of the fields in its own column.

    If not clear print here one of the lines from the file. Then we cab help you better.


    Jan [ WhTurner ] The Netherlands

    Wednesday, July 22, 2015 3:28 PM
    Answerer
  • (translated by Google translator)

    In order for the program can print the text as a table, it is necessary to give to the program not the entire contents of a text file, but one word for one time, for example. To do this, you can save a text file with one word per line, and then read it using the command "File.ReadLine(filePath, lineNumber)".

    To print a table in the graphics window, you must specify the location for each new word.
    The following example will print the words in two columns

    For n = 1 To 10 Step 2
      m_text =   File.ReadLine(filePath, n)
      GraphicsWindow.DrawText(10, n * 20, m_text)
      m_text =     File.ReadLine(filePath, n + 1)
      GraphicsWindow.DrawText(200, n * 20, m_text)

    EndFor

    The program will print 5 rows and 2 columns.

    Sorry for the wait

    Wednesday, July 22, 2015 4:18 PM
  • thank you very much for your help, tomorrow morning (at least here Italy) when I get back to work I try this and I update you on the progress.
    Wednesday, July 22, 2015 4:24 PM
  • You can get the contents of the document in 1 go using readContents.

    Then maybe, since you're looking for values, go at it like a wordprocessor - in the 1st instance looking for white space.

    contents = " blah descr beasts   feeffe    stati    rrer  rrr.    re, -     tttt"
    
    WHITESPACE = "1=10;2=11;3=12;4=13;5=32" 'define some whitespace
    
    For i = 1 To Text.GetLength(contents)  
      While Array.ContainsValue(WHITESPACE Text.GetCharacterCode(Text.GetSubText(contents i 1))) And i <= Text.GetLength(contents)     
        i = i + 1    
      EndWhile 
      
      j = j + 1
      While Array.ContainsValue(WHITESPACE Text.GetCharacterCode(Text.GetSubText(contents i 1))) = "False" And i <= Text.GetLength(contents)
        word[j] = word[j] + Text.GetSubText(contents i 1)
        i = i + 1    
      EndWhile 
    EndFor
    
    columns = 5
    colWidth = GraphicsWindow.Width / columns
    
    For j = 1 To Math.Ceiling(Array.GetItemCount(word) / columns)
      For i = 1 To columns
        k = k + 1
        GraphicsWindow.DrawText(colWidth * (i-1), 25 * (j-1), word[k])  
      EndFor
    EndFor


    Wednesday, July 22, 2015 10:56 PM
    Moderator