BIM Coordinator Program (INT) April 22, 2024
Find the next step in your career as a Graphisoft Certified BIM Coordinator!
Libraries & objects
About Archicad and BIMcloud libraries, their management and migration, objects and other library parts, etc.

Invalid Parameter Name? What?!?

Anonymous
Not applicable
In the Master script of a door object I am building, I want to put the following code:
IF pFrameType = `HM` THEN 
	PARAMETERS pFrameGuage = `16` 
ELSE 
	PARAMETERS pFrameGuage = `18` 
ENDIF

Simple enough, right? When I check the script with the Check Script button, it complains that "'PFRAMEGUAGE' isn't a valid parameter name" on the fourth line -- the one that attempts to set it to `18`. This means that it accepted the second line which sets it to `16`. I've done this same code snippet with several other variables and they all work -- just not this one.

I tried:
IF pFrameType = `HM` THEN 
	PARAMETERS pFrameGuage = `16` 
ENDIF 
IF pFrameType <> `HM` THEN 
	PARAMETERS pFrameGuage = `18` 
ENDIF

...and Check Script complained.

I tried:
PARAMETERS pFrameGuage = `18` 
IF pFrameType = `HM` THEN 
	PARAMETERS pFrameGuage = `16` 
ENDIF

...and Check Script complained about the first line, but if I click Continue, it doesn't complain about the third line.

I tried:
IF pFrameType = `HM` THEN 
	temp = `16` 
ELSE 
	temp = `18` 
ENDIF 
PARAMETERS pFrameGuage = temp

...and Check Script complained about the last line.

Now for the strangest part. If I take the "ELSE" line out of the first example so the code looks like the following:
IF pFrameType = `HM` THEN 
	PARAMETERS pFrameGuage = `16` 
	PARAMETERS pFrameGuage = `18` 
ENDIF

The Check Script says everything is fine! WTH!?!

It seems that every time I write a GDL with a lot of decision-making code, some part of it is guaranteed to fail with no perceptible reason. In the past I've had one LOCK call out of 20 not lock it's variable. I've had random HIDEPARAMETER calls refuse hide their parameters. It's a complete crap-shoot.

I'm about to give up doing any more smart GDLs because I easily kill an hour trying to figure out just one of these stupid little problems with no success. Any ideas?
6 REPLIES 6
Aussie John
Newcomer
just an idea - try a completely new paramater. If that works abandon the old one. (better still delete the parameter and then add again)
Cheers John
John Hyland : ARINA : www.arina.biz
User ver 4 to 12 - Jumped to v22 - so many options and settings!!!
OSX 10.15.6 [Catalina] : Archicad 22 : 15" MacBook Pro 2019
[/size]
Rob
Graphisoft
Graphisoft
Jay,

try this:

pFrameGuage = ``
IF pFrameType = `HM` THEN
PARAMETERS pFrameGuage = `16`
ELSE
PARAMETERS pFrameGuage = `18`
ENDIF

I have noticed that in some cases you need to pre-format the string variable to 'string'
::rk
Anonymous
Not applicable
John had the winning answer. First I added a Test parameter and used Test in the code instead of pFrameGuage, and it worked. So I deleted the original pFrameGuage parameter and renamed Test to pFrameGuage -- it worked.

The moral of this story is...

If the GDL interpreter doesn't like one of your parameters -- even though it should -- throw the parameter away and try again. Don't question why -- it will just drive you crazy!
Karl Ottenstein
Moderator
One tangential tidbit, Jay, for you and all others learning GDL:

You spelled your variable name as "pFrameGuage", but I suspect you meant "pFrameGauge" (unless guage means something in Spanish or ...).

It's really good IMHO to use meaningful variable names as you have, but a very common error happens when these names are spelled (or typed) incorrectly. Suppose a future programmer works on your object and pronounces the name in his head correctly and spells it correctly as well? The correctly spelled version (which does not match your name) will be an undefined variable ... which GDL interprets as having the value zero (0). I'd suggests a 'replace all' to nip this in the bud.

Of course, typos happen in scripts all the time... resulting in incorrect script execution (because the name is valid, but the value of 0 screws things up). Somewhere on the wish list was a wish for requiring variables to be declared, as in many programming languages, so that these kinds of errors could be caught by "Check Script"...

Cheers,
Karl
One of the forum moderators
AC 27 USA and earlier   •   macOS Ventura 13.6.6, MacBook Pro M2 Max 12CPU/30GPU cores, 32GB
Anonymous
Not applicable
Karl wrote:
You spelled your variable name as "pFrameGuage", but I suspect you meant "pFrameGauge"


It looked kinda weird, but I was busy trying to keep my train of thought late on a Friday afternoon. On the positive side, I was consistently wrong everywhere I used that variable. Whenever I have a problem like this, one of the things I try first is to copy the variable name right out of the parameters list so I know it's identical.
Aussie John
Newcomer
Jay wrote:
John had the winning answer. First I added a Test parameter and used Test in the code instead of pFrameGuage, and it worked. So I deleted the original pFrameGuage parameter and renamed Test to pFrameGuage -- it worked.

The moral of this story is...

If the GDL interpreter doesn't like one of your parameters -- even though it should -- throw the parameter away and try again. Don't question why -- it will just drive you crazy!
Good to hear Jay
Just a tip - make sure you dont save the object while the parameter is missing and open a project as any modified parameters of that variable (in a placed object) will be lost.
Cheers John
John Hyland : ARINA : www.arina.biz
User ver 4 to 12 - Jumped to v22 - so many options and settings!!!
OSX 10.15.6 [Catalina] : Archicad 22 : 15" MacBook Pro 2019
[/size]
Learn and get certified!