invalid non-declared variable

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā2008-12-02 12:48 PM
In a master script:
DEFINE TRANSLUCENT_FILL "test1" zero,2,3,4,5,6,7,8, 0.25
zero=0
DEFINE TRANSLUCENT_FILL "test2" zero,2,3,4,5,6,7,8, 0.25
when checking these instructions, ArchiCAD reports "insufficient parameters" for the first DEFINE, where a non-declared variable is used.
Thes second one is copy-pasted, to avoid any possible difference, but the zero is declared, and it works.
--Roberto Corona--
--Roberto Corona--
www.archiradar.com
AC18 - ITA full on Win10
_________________
_________________

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā2008-12-02 01:50 PM
My guess is that the first (undeclared) "zero" is read as a string expression (text) where ArchiCAD expects a numeric expression (number). Defining "zero" as a number corrects this error.
David
www.davidmaudlin.com
Digital Architecture
AC28 USA ā¢ Mac mini M4 Pro OSX15 | 64 gb ram ā¢ MacBook Pro M3 Pro | 36 gb ram OSX14

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā2008-12-02 03:16 PM
And, in fact, if I test it (at the script first line) with VARTYPE (zero) it says is "1" (number) not "2" (string).
Just discovered that an explicit use of "zero" as number (before the first DEFINE command) seems to "force" a declaration.
For examples, using a simple
x=zero+zero
the error message disappears.
--Roberto Corona--
www.archiradar.com
AC18 - ITA full on Win10
_________________
_________________
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā2008-12-02 04:57 PM
rocorona wrote:Roberto,
this could be true, but we know that undeclared variables are initialized as numbers.
And, in fact, if I test it (at the script first line) with VARTYPE (zero) it says is "1" (number) not "2" (string).
Just discovered that an explicit use of "zero" as number (before the first DEFINE command) seems to "force" a declaration.
For examples, using a simple
x=zero+zero
the error message disappears.
I would have answered the same as David, pat1 to pat8 are integers. Is there something else to understand?
But your second post makes more sense.
Yes, I get the same result/alerts.
May be zero is a reserved keyword for GS programmers. Anyway, thanks for the info.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā2008-12-03 02:49 PM
1. Add a new parameter to the part with the Variable "zero".
2. At the beginning of the Master Script add "zero=zero".
3. At the beginning of the Master Script add "Print zero".
I am sure there are more, for what it is worth.
David
www.davidmaudlin.com
Digital Architecture
AC28 USA ā¢ Mac mini M4 Pro OSX15 | 64 gb ram ā¢ MacBook Pro M3 Pro | 36 gb ram OSX14

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā2008-12-03 04:24 PM
isOkToStartFomZero = 0 shouldStartFrom3 = 3AC13 will have a GDL warning to warn developers about uninitialized variables. It helps you stay in picture about what is happening.
Regards,
Zsolt
ArchiCAD Development - GDL Team
AC13, AC14 and upwards...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā2008-12-03 04:39 PM
x = zero+zero is the same as writing zero = 0
zero can be replaced by any variable.
ztaskai wrote:Good point.
When using numeric variables, you should initialize them before their value is used for the first time. The good way to do this is the following for a variable which is OK to start from a given constant:
isOkToStartFomZero = 0 shouldStartFrom3 = 3AC13 will have a GDL warning to warn developers about uninitialized variables. It helps you stay in picture about what is happening.
Regards,
Zsolt
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā2008-12-03 06:47 PM
ztaskai wrote:Just to tease us a little... In a scale of -10 to 10 which do you think will be our impression about AC13 GDL new features?...
AC13 will have a GDL warning to warn developers about uninitialized variables. It helps you stay in picture about what is happening.

Thank you for the news!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā2008-12-03 07:06 PM
ztaskai wrote:That's great news, Zsolt.
AC13 will have a GDL warning to warn developers about uninitialized variables.
The old behavior of an uninitialized variable being treated as a zero-value has 'bitten' too many newcomers to GDL, and even old timers. A simple typo results in a variable with a zero value which can take considerable time to track down and debug. The warning will be a great help to everyone.
Certainly, some old (user written) library parts will need to have initialization statements added, but that is for the good IMHO. It was lazy programming to intentionally assume an uninitialized variable would be zero.
Thanks,
Karl

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā2008-12-04 12:04 PM
ztaskai wrote:What would also be good is to extend this behavior to all error cases in GDL, not just uninitialized variable. I could even imagine ArchiCAD giving an advice in the error message on how to fix it.
AC13 will have a GDL warning to warn developers about uninitialized variables.
For example, when the "Fill not found at line xxx" message, the message could also say that this and this parameter or line of code calls for a fill with this fill index, but it does not exist, check in your Fill Types Dialog or the Attribute Manager or whatever blablabla.
The point would be to enable people to solve the problem themselves.
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