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

Uninitilaized variable Error Message on VARDIM1 and VARDIM2

Hoa Tu
Newcomer
I think this is a bug of the GDL program that produce this error message when using the VARDIM functions. I find it very annoying when running the check script.

! Example from GDL Reference Guide Page 237
DIM f1 [5]
FOR i = 1 TO VARDIM1(f1) ! Uninitialized variable Error Message here
f1 = i
NEXT i

But if I do this, the Error Message will not come up:

DIM f1 [5]
f1[1] = 0
f1[2] = 0
f1[3] = 0
f1[4] = 0
f1[5] = 0

FOR i = 1 TO VARDIM1(f1)
f1 = i
NEXT i

Is there any way to overcome this problem ?

Regards,

Hoa
1 REPLY 1
Barry Kelly
Moderator
"From the GDL manual wrote:
VARDIM1(expr)
VARDIM1(expr)
VARDIM2(expr)
VARDIM2(expr)
These functions return as integers the actual dimension values for the (array) expression specified as a parameter. They must be used if you want
to handle correctly all actual elements of a dynamic array or an array parameter. If no element of a dynamic array was previously set, the return
value is 0
. For one-dimensional arrays VARDIM2 returns 0.



So you are saying to go FOR i = 1 to 0

But in you second part of the example you have given values to tha array so it now works.

Why don't you just say ...
FOR i = 1 TO 5
f1 = i
NEXT i


Barry.
One of the forum moderators.
Versions 6.5 to 27
Dell XPS- i7-6700 @ 3.4Ghz, 16GB ram, GeForce GTX 960 (2GB), Windows 10
Lenovo Thinkpad - i7-1270P 2.20 GHz, 32GB RAM, Nvidia T550, Windows 11

Didn't find the answer?

Check other topics in this Forum

Back to Forum

Read the latest accepted solutions!

Accepted Solutions

Start a new conversation!