Home › Forums › Problems and solutions in GDL › Documentation elements, text handling › loop and richtext2
Tagged: text2 richtext2 textblock
- This topic has 6 replies, 3 voices, and was last updated 5 years, 5 months ago by Jože Marinko.
-
AuthorPosts
-
-
August 26, 2019 at 14:02 #18135Jože MarinkoParticipant
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]
endparagraphtextblock “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?
-
August 26, 2019 at 16:54 #18136Péter BaksaKeymaster
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 -
August 27, 2019 at 10:35 #18137Jože MarinkoParticipant
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.
-
August 28, 2019 at 07:01 #18138Barry KellyParticipant
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 -
August 28, 2019 at 07:15 #18139Péter BaksaKeymaster
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 -
August 28, 2019 at 08:19 #18140Barry KellyParticipant
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 -
August 29, 2019 at 07:13 #18141Jože MarinkoParticipant
I finally find a mistake!
My variable for loop was to big. It must be row-1
I am sorry for interrupting you.
-
-
AuthorPosts
- The forum ‘Documentation elements, text handling’ is closed to new topics and replies.