We value your input!
Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey

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

VARTYPE line error

JGoode
Expert
I keep getting an error on the "IF n > 0 AND VARTYPE (var) = 2 THEN" line
I don't know what's causing it or how to fix it.
DIM sarray[]
! file in the library, containing parameter data
filename = "ProjectNotes.txt"
ch1 = OPEN ("text", filename, "MODE=RO, LIBRARY")
i = 1
j = 1
sarray[1] = ""
! collect all strings
DO
    n = INPUT (ch1, i, 1, var)
    IF n > 0 AND VARTYPE (var) = 2 THEN
        sarray = var
        j = j + 1
    ENDIF
    i = i + 1
WHILE n > 0
CLOSE ch1
! parameter popup with strings read from the file
VALUES "RefNote" sarray
ArchiCAD 23

Windows 10
3 REPLIES 3
Pertti Paasky
Expert
Works with me. Check parameter "RefNote" in the parameters' tab, it's type should be text.
-The text file must be in the loaded library.It must not be opened in any other application at the same time.
- AC-24 FIN - WIN 10 - HP Zbook -
“A winner is just a loser who tried one more time.”
George M. Moore, Jr.
Anonymous
Not applicable
JGoode wrote:
I keep getting an error on the "IF n > 0 AND VARTYPE (var) = 2 THEN" line
I don't know what's causing it or how to fix it.
Create var parameter, or declare var = 0 in the script. And there will be no mistakes.
Gergely Feher
Graphisoft
Graphisoft
If the input is not successful, then vartype will be uninitialized. So you should split it to two conditions:
if n > 0 then
    if vartype (var) = 2 then
        ...

_________________
Gergely Fehér
Team Leader, Library Team
GRAPHISOFT SE