locked
Print tabulated in video RRS feed

  • Question

  • Hello everyone, I apologize for my English, I'm using google translated. 

    taking up an old post ( https://social.msdn.microsoft.com/Forums/en-US/ea288e13-e83e-403f-b579-fd9bd578b7d8/print-tabulated-in-video?forum=smallbasic ) 

    I wanted to ask how you can print with a DrawText elements in a text file so tabulated, because in a column of the file is present the description and the description contains spaces, for example, it says: YEAR 2015 ", and then the old post this printing takes place in different columns.
    Any idea on how we can solve this problem?

    T.U.

    Friday, August 7, 2015 7:33 AM

Answers

  • Here's a program that reads a big txt file, prints it to the GraphicsWindow in a 2 column format (word wrap) and has a page turner.

    It uses litdev extension.

    FWW116


    • Edited by Jibba j Saturday, August 8, 2015 3:56 AM add screenshot
    • Proposed as answer by litdev Sunday, August 9, 2015 8:22 AM
    • Marked as answer by WhTurner33Editor Sunday, August 16, 2015 10:47 AM
    Saturday, August 8, 2015 3:50 AM

All replies

  • I just added 3 lines of code to the sample I posted on the other thread.

    They're commented as ADDED 1,2,3.

    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
    
    spaces = "                                          " 'ADDED 1
    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])     
        printContent = printContent + word[k] + Text.GetSubText(spaces, 1, (25 - Text.GetLength(word[k]))) 'ADDED 2
       EndFor   
     EndFor
     
     File.WriteContents(Program.Directory + "\tabFile.txt", printContent)  'ADDED 3

    Friday, August 7, 2015 12:50 PM
  • but if I want to, for example, that the words "blah descr" are part of the same column ??? because on my file, in column decription, it consists of two words separated by space
    Friday, August 7, 2015 1:08 PM
  • but if I want to, for example, that the words "blah descr" are part of the same column ??? because on my file, in column decription, it consists of two words separated by space

    (translated by Google translator)

    Therefore, I suggest you use a one line in the text file for to store in it only one entry from the entire list. Then your file will consist of separate lines, each of which is very easy to write or read using commands File.WriteLine(filePath, lineNumber, contents) and File.ReadLine(filePath, lineNumber).

    Friday, August 7, 2015 2:08 PM
  • the problem is not in the reading and writing of files, that works well, the problem is that when I make the print on the screen with a DrawText does not happen tabulation
    Friday, August 7, 2015 2:31 PM
  • (translated by Google translator)

    But you have this problem because you can not comfortably read one entry from the list. Spaces between words makes the problem for you. I'm right?

    However, if the write and read an entire line from the file, then a space character will not make a problem.

    What language is native for you? Where are you from?

    Friday, August 7, 2015 3:02 PM
  • Try this:

    ' graphic print in 2 columns [ uses LitDev-extension] 
    t=" blah descr beasts   feeffe    stati    rrer  rrr.    re, -     tttt"
    a=LDText.Split(t," ")
    For i=1 To Array.GetItemCount(a)
      ''TextWindow.WriteLine(a[i])
      x=50+70*Math.Remainder(i-1,2)
      y=50+30*Math.Floor((i-1)/2)
      GraphicsWindow.DrawText(x,y,i+" "+a[i])
    EndFor


    Jan [ WhTurner ] The Netherlands

    • Proposed as answer by litdev Sunday, August 9, 2015 8:22 AM
    Friday, August 7, 2015 5:56 PM
    Answerer
  • Here's a program that reads a big txt file, prints it to the GraphicsWindow in a 2 column format (word wrap) and has a page turner.

    It uses litdev extension.

    FWW116


    • Edited by Jibba j Saturday, August 8, 2015 3:56 AM add screenshot
    • Proposed as answer by litdev Sunday, August 9, 2015 8:22 AM
    • Marked as answer by WhTurner33Editor Sunday, August 16, 2015 10:47 AM
    Saturday, August 8, 2015 3:50 AM
  • Jibba Jabba, your program FWW116, cuts the line just for the width of the column. Thiis can be in the middle of a word. I searched for a solution en found the following one: replace the first If-block in the big loop with:

      If www >= columnWidth And canWrap Then 
        '  search for last space
        For ii=text.GetLength(line) To Text.GetLength(line)-30 Step -1
          If Text.GetSubText(line,ii,1)=" " then
            possp=ii
            ii=0
          endif
        EndFor
        wrap =  Text.GetSubTextToEnd(line possp+1)     
        line = Text.GetSubText(line 1 possp-1) + Text.GetCharacter(13)    
        contents = Text.Append(wrap, Text.GetSubTextToEnd(contents 1))    
        canWrap = "False"
    
    Then the line is cut on the last space and the rest is moved to the next line.


    Jan [ WhTurner ] The Netherlands

    Monday, August 10, 2015 3:23 PM
    Answerer
  • Hi Jan

    Nice feature. I had it behaving as word-break on.

    I plugged your code in and found the occasional line wrapped after 1 word.

    Tuesday, August 11, 2015 12:29 AM