loop and richtext2

Viewing 6 reply threads
  • Author
    Posts
    • #18135
      Jože Marinko
      Participant

      Hey,
      I want read text from external .txt file. It is a data file, like Exel. So I have rows and columns. I read all data and put it in array variable.
      Now I want read this data and put array fields in paragraph: Here is a code:
      for i=1 to row
      paragraph “CONTENT_PARAGRAPH_1” colAlign_1, 0, 0, 0, 1.0, 1.0
      pen 1
      set style “CONTENT_1”
      content[i][1]
      endparagraph

      textblock “CONTENT_BLOCK_1” colWidth_1, 1, 0, 1.0, 1.0, 1, “CONTENT_PARAGRAPH_1″
      richtext2 0,0,”CONTENT_BLOCK_1”
      add2 colWidth_1,0
      next i

      !—–
      With content[1][1], 2D drawing is OK.
      With content[i][1], I got a dot in floor plan and a message: String type expression required at line (with endparagraph).

      What is wrong?

    • #18136
      Péter Baksa
      Keymaster

      Are you sure that all of the elements in the array are strings? Are you sure row isn’t bigger than the size of the array?

      Péter Baksa
      Library Platform, Software Engineer
      GRAPHISOFT SE

    • #18137
      Jože Marinko
      Participant

      Yes, I am sure. But I think there is not a problem in data but in index of array. If index is not variable [i] but number [1] everything is OK.

    • #18138
      Barry Kelly
      Participant

      I think the problem is you are creating the same Paragraph as you go throu the loop.
      So when I=1, you are creating … paragraph “CONTENT_PARAGRAPH_1”
      When I=2, you are creating … paragraph “CONTENT_PARAGRAPH_1”
      When I=3, you are creating … paragraph “CONTENT_PARAGRAPH_1”

      All the same paragraph but with different content … content[i][1]

      When you manually set ‘i’ to ‘1’ you now have the same content in the same paragraph, which is why it works.

      Barry.

      Versions 6.5 to 22
      Dell XPS- i7-6700 @ 3.4Ghz, 16GB ram, GeForce GTX 960 (2GB), Windows 10
      Dell Precision M6800 - i7 4700MQ @ 2.40GHz, 16GB RAM, AMD FirePro M6100 (2GB), Windows 7 64bit

    • #18139
      Péter Baksa
      Keymaster

      I tried Jože’s example with hard-coded content[][], and it was good with the repeating paragraph name.
      The code working with content[1][1] and not with content[i][1] means the problem is after index [1][1].

      You can debug your data using print content before the loop.

      Péter Baksa
      Library Platform, Software Engineer
      GRAPHISOFT SE

    • #18140
      Barry Kelly
      Participant

      I missed that the RICHTEXT and TEXTBLOCK commands were inside the loop as well.

      I just tested and yes it does work – so the error must be in the data for the ‘content’ array.

      Barry.

      Versions 6.5 to 22
      Dell XPS- i7-6700 @ 3.4Ghz, 16GB ram, GeForce GTX 960 (2GB), Windows 10
      Dell Precision M6800 - i7 4700MQ @ 2.40GHz, 16GB RAM, AMD FirePro M6100 (2GB), Windows 7 64bit

    • #18141
      Jože Marinko
      Participant

      I finally find a mistake!
      My variable for loop was to big. It must be row-1
      I am sorry for interrupting you.

Viewing 6 reply threads
  • The forum ‘Documentation elements, text handling’ is closed to new topics and replies.