Search the Knowledge Base Report a bug
Post new topic   Reply to topic   printer-friendly view   .    ArchiCAD-Talk Forum Index >>> Libraries / Library Parts / GDL >>> VARTYPE line error
View previous topic :: View next topic
Author Message
JGoode
Junior member
Junior member

Joined: 21 Apr 2017
Posts: 159
Location: Norwich

PostPosted: Fri Nov 24, 2017 11:33 am    Post subject: VARTYPE line error Reply with quote

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.

Code:
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[j] = var
        j = j + 1
    ENDIF
    i = i + 1
WHILE n > 0
CLOSE ch1
! parameter popup with strings read from the file
VALUES "RefNote" sarray
Code:

_________________
ArchiCAD 17, 19 and 21
Windows 8
Back to top
View user's profile Send private message    
Pertti Pääsky
Junior member
Junior member

Joined: 16 Dec 2008
Posts: 92
Location: Finland

PostPosted: Sat Nov 25, 2017 8:35 am    Post subject: Re: VARTYPE line error Reply with quote

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-14-19 FIN - WIN 7 - HP Elitebook -
Back to top
View user's profile Send private message    
SL_GDL
New member
New member

Joined: 12 Mar 2013
Posts: 46
Location: Russia

PostPosted: Sat Nov 25, 2017 8:55 pm    Post subject: Re: VARTYPE line error Reply with quote

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
Back to top
View user's profile Send private message Visit poster's website    
Gergely Feher
Graphisoft

Joined: 24 Jan 2009
Posts: 28
Location: Budapest, GSHQ

PostPosted: Thu Nov 30, 2017 7:51 am    Post subject: Re: VARTYPE line error Reply with quote

If the input is not successful, then vartype will be uninitialized. So you should split it to two conditions:
Code:
if n > 0 then
    if vartype (var) = 2 then
        ...


_________________
_________________
Gergely Fehér
Team Leader, Library Team
GRAPHISOFT SE
Back to top
View user's profile Send private message SKYPE ID  
Display posts from previous:   
View previous topic :: View next topic
Post new topic   Reply to topic   printer-friendly view       ArchiCAD-Talk Forum Index >>> Libraries / Library Parts / GDL >>> VARTYPE line error All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Copyright © 2012 - Graphisoft SE. All rights reserved worldwide. Terms of Use | Privacy Policy