January 25, 2018 at 19:48 #3756Joachim SühloParticipant
I have issues in the following Script in AC 21:
When I uncomment one of the commented lines, I get different error messages in each case.
Because the values of the variables myText1 and myText2 are coming from a Textimport by INPUT,
their variable type is not known. But the types must be known to get the Strings lenght in case of numbers
and to be able to add the variable str_TEXT_trenner to build a String expression.
str_TEXT_trenner = ” – ”
DEFINE STYLE “textfeld_stil_2” “Arial”, 0.25, 1, 0
SET STYLE “textfeld_stil_2”
myText1 = “Textinhalt”
IF VARTYPE(myText1) = 2 THEN Text_Inhalt1 = myText1 + str_TEXT_trenner ! STRING
! IF VARTYPE(myText1) = 1 THEN Text_Inhalt1 = STR(myText1, 1, 0) + str_TEXT_trenner ! NUMBER
myText2 = 23
! IF VARTYPE(myText2) = 2 THEN Text_Inhalt2 = myText2 + str_TEXT_trenner ! STRING
IF VARTYPE(myText2) = 1 THEN Text_Inhalt2 = STR(myText2, 1, 0) + str_TEXT_trenner ! NUMBER
feldbreite_1 = STW(Text_Inhalt1)/1000*A_
feldbreite_2 = STW(Text_Inhalt2)/1000*A_
TEXT2 0, 0, Text_Inhalt1
TEXT2 0, -0.1, Text_Inhalt2
GDL Object Developer
MAC OSx 10.14
January 26, 2018 at 16:29 #3760Denny WongParticipant
hi Joachim, sharing your pain here. In fact this is a very old problem when the GDL interpreter make assumptions of what types the varilables are PRIOR to execution and over-zealously stop the script even if the problem was avoided by vartype conditions.
In my experience this gets a LOT worse when the variable in question is an array received from RETURNED_PARAMETERS, LIBRARY_GLOBAL and file operations. I see that GS themselves would give the first element of each array an arbitrary value immediately after dimensioning, so that the interpreter will pick up the vartype. However this does not work all the time. I cannot consistently work out when it works and when it doens’t – seems sporadic.
Bond Bryan Architects, Westerham, UK
January 26, 2018 at 17:18 #3762Gergely FehérKeymaster
It is caused by the bad design of the STR command, which can not be corrected, due to compatibility issues. Sorry, but I can’t help with a quick fix or a real workaround. Maybe you can try with usign spit command, but I’m really sure that can fit all the workflows you need.
Team Leader, Library Team
- The forum ‘Documentation elements, text handling’ is closed to new topics and replies.