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

VARTYPE line error

JGoode
Contributor
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 P__sky
Newcomer
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.

SL_GDL
Newcomer
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.
Intel Core i7-2600 3.4GHz; RAM: 8 GB
http://sl-gdl.com

Gergely Feher
Newcomer
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

Still looking?

Browse more topics

Back to forum

See latest solutions

Accepted solutions

Start a new discussion!