Showing results for 
Search instead for 
Did you mean: 
Showing results for 
Search instead for 
Did you mean: 
Developer forum

Using a Text File result to change parameters

GDL Enthusiast
Hi GDL experts,

I am working with a simple txt. file to figure out how it can work. I have the code working that can search the first column of the text file and return a code based on the column number as below:

ch=OPEN("data",”Simple.txt”,"MODE=RO, DIALOG")
nr=INPUT(ch,searchfield,1,sheetname, sheetscale)
text2 1,0,sheetname

The output is text, in this case, 'Ground Floor'. If I enter numerical values into the txt. file in a third column, the output result seems to be still recognized by the GDL script as a text value.

My goal is to use the output result above to drive parameters such as the length of an object based on the row selected.

Is there a way to ask for a result, from a *txt file, that is in numerical format, so I can then use the result to change a parameter?

Thank you so much!

Not applicable
Hi, use "SPLIT" command as describes in GDL-Manual!
This makes STRING to NUMBERS.

See the discussion and especially the last answer here:

Basically Archicad automatically recognizes if the input is a number or a text and sets the variable type.
In my experience if you work with simple variables (not arrays) you have to initialize them correctly - if you do sheetscale="" and then use it in an input command which returns a number, Archicad changes it to a number but somehow gets confused and returns errors.
So either use sheetscale=0 when you expect numbers, do a "if vartype then split" or use arrays.

GDL Enthusiast
Hi Ma_Scht and Jan,

Thank you so much for responding. After reading your posts, I realise I can't use a *txt file for both numbers and text when importing into Archicad as it has trouble distinguishing 0 null. I wonder how I could go about this problem:

I would like to reference a list of GDL child part names to CALL i.e.
GDL Object Child Names

And for these GDL child part names, each would have a reference parameter such as an offset, or length that changes depending upon the part selected i.e.

Is there a way to create something like a lookup table (like Excel), where the first values list selects the child object, and then, based on the selected child object, parameters in the Main (Parent) object change accordingly?

Do you know of any links or scripts or example GDL objects that I could study for this too?

Thank you so much in advance!

Peter Baksa
Yes, there is an add-on to read XML.
It is not easy to use, but can get around the type problems.
Péter Baksa
Software Engineer, Library as a Platform
Graphisoft SE, Budapest

I agree with Peter; the XML add-on is the way to go.
I have been using this add-on for 6 or 7 years now and it is how I enable an internal catalogue where the parameters are locked to values in an XML file.

With TXT file you are selecting a specific cell based on it position, whereas with XML you a searching for a key/value pair which is far more intelligent, reliable and flexible.

In the early days I struggled to work it out and there was no documentation on the tool apart from the GDL Reference Guide. The difficult bit was understanding how to "traverse the XML tree". I eventually worked it out with some help from the experts at GSHQ, who as a result, created more detailed documentation on the "GDL Center". Do a search for XML and you find the information you need.
Creator of Cadswift's parametric GDL libraries
Creator of Infinite Openings and Component Catalogues
Push the envelope & watch it bend

Still looking?

Browse more topics

Back to forum

See latest solutions

Accepted solutions

Start a new discussion!