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

gdl scripts problems

Anonymous
Not applicable
I can not understand what a script does not work in GDL on
opening of file
Here sample program with gdl.pdf
pg 309

Example:
Object of GDL, which copies content of file of "f1" in the files of "f2" and "f3", however here writes down values "f1",
part character tabulations, in the separate lines of both files of "f2" and "f3".
-----------------------------------------------------------------------
ch1 = open ("TEXT", "f1", "mode = ro")
ch2 = open ("TEXT", "f2", "separator = '\n', mode = wo")
ch3 = open ("TEXT", "f3", "separator = '\n', mode = wo")
i = 1
1:
n = input (ch1, i, 1, var1, var2, var3, var4)
if n <> -1 then
output ch2, 1, 0, var1, var2, var3, var4
output ch3, 1, 0, var1, var2, var3, var4
i = i + 1
goto 1
else
goto 2
endif
2:
close ch1
close ch2
close ch3
--------------------------------------------------------------------------------
not FIND FILE f1....
but file I put in the root of archicad and in a
that place where GDL model located , the name of file was written by
f1, f1.txt and even f1.text

8 REPLIES 8
Anonymous
Not applicable
Hi Alex,

Its not enought to put the txt files in the AC root or where the project file is located...

You have to load them in the project file using the "Library Manager" as a regular object...

Did you do that?...

HTH
Anonymous
Not applicable
Braza wrote:
Hi Alex,

Its not enought to put the txt files in the AC root or where the project file is located...

You have to load them in the project file using the "Library Manager" as a regular object...

Did you do that?...

HTH
Anonymous
Not applicable
Ok Alex... Everything is on the right place.

Don't know much about I/O operations...

But... First thing I have noticed is that you are not using the appropriate filter... As told in the GDL Manual:

Specifying Folder
channel = OPEN (filter, filename, paramstring)
channel : folder id
filter :
the internal name of the Add-On, in this case "FileMan"
filename : - the name of folder to be scanned (OS dependent path) - folder id string (in
DIALOG mode - see later)
paramstring : Add-on specific parameter.
The parameters in paramString must be separated by commas (,).
1. parameter: FILES/FOLDERS
What would you like to search for?
2. parameter (optional): DIALOG
Indicates that the folder is given by a file id string instead of a file path.
When this is the case, at the first time (and each time when the corresponding file path seems
to be invalid) the user will be faced a dialog box to set the id string - file path
correspondence, which will be stored.


And you used "TEXT"...

If you post the object folder here I'll take a look later...
Anonymous
Not applicable
Braza wrote:
Hi Alex,

Its not enought to put the txt files in the AC root or where the project file is located...

You have to load them in the project file using the "Library Manager" as a regular object...

Did you do that?...

HTH
Anonymous
Not applicable
Braza wrote:
Ok Alex... Everything is on the right place.

Don't know much about I/O operations...

But... First thing I have noticed is that you are not using the appropriate filter... As told in the GDL Manual:

Specifying Folder
channel = OPEN (filter, filename, paramstring)
channel : folder id
filter :
the internal name of the Add-On, in this case "FileMan"
filename : - the name of folder to be scanned (OS dependent path) - folder id string (in
DIALOG mode - see later)
paramstring : Add-on specific parameter.
The parameters in paramString must be separated by commas (,).
1. parameter: FILES/FOLDERS
What would you like to search for?
2. parameter (optional): DIALOG
Indicates that the folder is given by a file id string instead of a file path.
When this is the case, at the first time (and each time when the corresponding file path seems
to be invalid) the user will be faced a dialog box to set the id string - file path
correspondence, which will be stored.


And you used "TEXT"...

If you post the object folder here I'll take a look later...
Anonymous
Not applicable
This example in PDF document does work?
Anonymous
Not applicable
Hello,

I do not know about the PDF manual, but would suggest declaring the file names first and then using the LIBRARY keyword meaning that the files are in the active libraries. I tested and this works, just remember to load the file library.

!--> file names added
f1= "File01.txt"
f2= "File02.txt"
f3= "File03.txt"

!--> LIBRARY keyword added
ch1 = open ("TEXT", f1, "mode = ro,LIBRARY")
ch2 = open ("TEXT", f2, "separator = '\n', mode = wo,LIBRARY")
ch3 = open ("TEXT", f3, "separator = '\n', mode = wo,LIBRARY")


!--> script continues as before
i = 1
1:
n = input (ch1, i, 1, var1, var2, var3, var4)
if n <> -1 then
output ch2, 1, 0, var1, var2, var3, var4
output ch3, 1, 0, var1, var2, var3, var4
i = i + 1
goto 1
else
goto 2
endif
2:
close ch1
close ch2
close ch3
end


Hope this helps.
Anonymous
Not applicable
Juha wrote:
Hello,

I do not know about the PDF manual, but would suggest declaring the file names first and then using the LIBRARY keyword meaning that the files are in the active libraries. I tested and this works, just remember to load the file library.

!--> file names added
f1= "File01.txt"
f2= "File02.txt"
f3= "File03.txt"

!--> LIBRARY keyword added
ch1 = open ("TEXT", f1, "mode = ro,LIBRARY")
ch2 = open ("TEXT", f2, "separator = '\n', mode = wo,LIBRARY")
ch3 = open ("TEXT", f3, "separator = '\n', mode = wo,LIBRARY")


!--> script continues as before
i = 1
1:
n = input (ch1, i, 1, var1, var2, var3, var4)
if n <> -1 then
output ch2, 1, 0, var1, var2, var3, var4
output ch3, 1, 0, var1, var2, var3, var4
i = i + 1
goto 1
else
goto 2
endif
2:
close ch1
close ch2
close ch3
end


Hope this helps.
It Works! Thank you!