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

Learn to manage BIM workflows and create professional Archicad templates with the BIM Manager Program.

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

Simulate the ON_ERROR command???

Anonymous
Not applicable
Hi all,

as described onto GDL CB3 by David N.C., the ON_ERROR command is not present in GDL...

So, is there a way to emulate that command...???

It's useful when, for example, the path of a file called by the "OPEN" command is wrong, without Archicad pops up tha dialog that says: "File not found...: "path" "
Instead of this dialog I would like to open a pop-up that says: "Error, the file you requested is not present on the server... Check the network state!"

Thank you
Marco
5 REPLIES 5
Laszlo Nagy
Community Admin
Community Admin
When opening a file, the OPEN command always returns a value.
If you have the following:

ch1 = OPEN ("DATA", "file1", "SEPARATOR=';', MODE = RO", DIALOG)

after this line in the Script, you can query the value of ch1 to see if the open operation was successful or not. The GDL Manual has the details on its values.
Loving Archicad since 1995 - Find Archicad Tips at x.com/laszlonagy
AMD Ryzen9 5900X CPU, 64 GB RAM 3600 MHz, Nvidia GTX 1060 6GB, 500 GB NVMe SSD
2x28" (2560x1440), Windows 10 PRO ENG, Ac20-Ac28
Anonymous
Not applicable
Thank you laszlo,
ch1 = OPEN ("DATA", "file1", "SEPARATOR=';', MODE = RO", DIALOG)
using FULLPATH instead of DIALOG, the parser does not visualize a dialog, and uses directly the given string as path of the file... if ch1 is different from 1 there is a problem and the operation was unsuccessful... so I could use:

IF ch1#1 THEN PRINT "Error!"

but this comes after the standard error dialog and my IF statement could not be processed.



h:"c:\win\doc\test.txt"


ch=OPEN ("TEXT", h, "FULLPATH")

!*******

IF ch#1 THEN
PRINT "DANGER! I'm unable to find the file on the server!"
EXIT
ENDIF



Using this code, the parser stops at line !******* and can't process my IF statement.

Have you any idea, please?
I'm writing anything wrong?

Thank you
Marco
Laszlo Nagy
Community Admin
Community Admin
I don't know if you can make the program display your error message after the program's error message, but I can help you display the Dialog:

h="c:\win\doc\test.txt"

ch=OPEN ("TEXT", h, "DIALOG, FULLPATH")

!*******

IF ch<>1 THEN
PRINT "DANGER! I'm unable to find the file on the server!"
EXIT
ENDIF

As you can see "DIALOG, FULLPATH" is the parameter string with two values within it. The parameter string is between quation marks. If it has more then one value, the values are separated by commas.

Also, your first line should be

h="c:\win\doc\test.txt"

and not

h:"c:\win\doc\test.txt"



As I can see in the GDL Help, not equal can be shown by both <> and #.
Loving Archicad since 1995 - Find Archicad Tips at x.com/laszlonagy
AMD Ryzen9 5900X CPU, 64 GB RAM 3600 MHz, Nvidia GTX 1060 6GB, 500 GB NVMe SSD
2x28" (2560x1440), Windows 10 PRO ENG, Ac20-Ac28
Anonymous
Not applicable
Thanks again Laszlo,

I understood that it couldn't be done...

The file not found error stops the entire program... I'll make something different to avoid this problem...
Also, your first line should be

h="c:\win\doc\test.txt"

and not

h:"c:\win\doc\test.txt"

of course... digitation error...
As I can see in the GDL Help, not equal can be shown by both <> and #.
Right...

Thanks a lot.
Marco
Laszlo Nagy
Community Admin
Community Admin
You are welcome.
Hope you can get around these limitations.
Otherwise you can do some great stuff with these GDL I/O operations.
Worth exploring.
Loving Archicad since 1995 - Find Archicad Tips at x.com/laszlonagy
AMD Ryzen9 5900X CPU, 64 GB RAM 3600 MHz, Nvidia GTX 1060 6GB, 500 GB NVMe SSD
2x28" (2560x1440), Windows 10 PRO ENG, Ac20-Ac28