Libraries & objects
About Archicad and BIMcloud libraries, their management and migration, objects and other library parts, etc.

Make GDL TEXT I/O ADD-ON read values as strings

Karl Wir_n
Enthusiast
Hello,
I have a tab-separated text file with numbers and expressions that I'm using in a GDL-object I made. It works good but now I want to modify it to read the values as strings. For example 3-4 should be returned as a string "3-4" and not as -1. For some reason I can't find a solution. Anyone out there with a suggestion?
/Karl W
4 REPLIES 4
Barry Kelly
Moderator
Does it help if you declare the variable as a text variable firs before you read the value into?
For example if your text variable is 'string_name' then declare it as a string variable before reading the value in.
string_name = ""
Barry.
One of the forum moderators.
Versions 6.5 to 27
i7-10700 @ 2.9Ghz, 32GB ram, GeForce RTX 2060 (6GB), Windows 10
Lenovo Thinkpad - i7-1270P 2.20 GHz, 32GB RAM, Nvidia T550, Windows 11
Karl Wir_n
Enthusiast
No, unfortunately not. I thought of that too.
Thank's anyway, Barry.
Anonymous
Not applicable
Hello,

You can test if the program thinks that the
input string is a number or string with the VARTYPE
parameter. If the VARTYPE = 1 then it is a
number and you should convert it to a string first.

Hope this helps.
Karl Wir_n
Enthusiast
Found a solution! In my case I wanted to read values from an external text file as strings, even numerical expressions like 3-4. 3-4 should return as "3-4" and not as -1. By using a dash instead of a minus, writing 3–4 instead of 3-4, the problem was solved.
//Karl W