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

VARTYPE line error

JGoode
Advocate
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 17, 19, 21 and 23
Windows 8
3 REPLIES 3

Pertti Paasky
Enthusiast
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

Didn't find the answer? Start a new discussion

Labels

Still looking?

Browse more topics

Back to forum

See latest solutions

Accepted solutions

Start a new discussion!