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

Using a Text File result to change parameters

GDL Enthusiast
Participant
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")
searchfield="A01"
nr=INPUT(ch,searchfield,1,sheetname, sheetscale)
text2 1,0,sheetname
CLOSE ch

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.

Question:
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!
5 REPLIES 5

Ma_Scht
Newcomer
Hi, use "SPLIT" command as describes in GDL-Manual!
This makes STRING to NUMBERS.
With best regards
Mario

jan_filipec
Booster
See the discussion and especially the last answer here:
https://archicad-talk.graphisoft.com/viewtopic.php?f=49&t=74023&start=10

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
Participant
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
01Part
02Part
03Part
...


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.
01PartLength=0.01
02PartLength=0.04
03PartLength=0.03
...


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
Graphisoft
Graphisoft
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
website: https://cadswift.com.au/
YouTube: https://www.youtube.com/user/CADSwift/playlists

Still looking?

Browse more topics

Back to forum

See latest solutions

Accepted solutions

Start a new discussion!