Learn to manage BIM workflows and create professional Archicad templates with the BIM Manager Program.
2024-02-28
11:15 PM
- last edited on
2024-09-26
01:14 PM
by
Doreena Deng
Hi,
I have a problem that is baffling me. I have simplified it down to how to deal with an Undefined line item in an array. Here is the script:
Parameter Script:
values{2} "bolt", 1, `Simple`,
2, `Complex`
values{2} "nut", 1, `Simple`,
2, ` Complex `
The 2D Script has a variety of bolt and nut types using IF statements with text notes for bolt or nut type. For each a different text result is given, i.e.
2D Script
IF Bolt = 1 THEN TextA1 = "IN1 String to test the text."
IF Bolt = 2 THEN TextA2 = "IN2 String to test the text."
IF Nut = 1 THEN TextA3 = "IN3 String to test the text."
IF Nut = 2 THEN TextA4 = "IN4 String to test the text."
If the user selects Bolt = 1 then TextA1 is defined, but TextA2 is undefined causing an error in the following array:
DIM ItemText[4]
ItemText[1] = TextA1
ItemText[2] = TextA2
ItemText[3] = TextA3
ItemText[4] = TextA4
! Show Result
Text2 0,0,ItemText[1]
Text2 0,0.05,ItemText[2]
Text2 0,0.1,ItemText[3]
Text2 0,0.15,ItemText[4]
I have tried this alternative code to handle the array using IF statements but I can't think of a way to write IF TextA1 = undefined THEN:
DIM ItemText[3]
IF TextA1 = "" THEN ItemText[1] = "" ELSE ItemText[1] = TextA1
IF TextA2 = "" THEN ItemText[2] = "" ELSE ItemText[2] = TextA2
IF TextA3 = "" THEN ItemText[3] = "" ELSE ItemText[3] = TextA3
...etc
Is there a way to make the array ignore undefined values?
Many thanks, Matt
Solved! Go to Solution.
2024-02-28 11:41 PM
TextA1 = ""
TextA2 = ""
TextA3 = ""
TextA4 = ""
IF Bolt = 1 THEN TextA1 = "IN1 String to test the text."
IF Bolt = 2 THEN TextA2 = "IN2 String to test the text."
IF Nut = 1 THEN TextA3 = "IN3 String to test the text."
IF Nut = 2 THEN TextA4 = "IN4 String to test the text."
DIM ItemText[4]
ItemText[1] = TextA1
ItemText[2] = TextA2
ItemText[3] = TextA3
ItemText[4] = TextA4
2024-02-28 11:41 PM
TextA1 = ""
TextA2 = ""
TextA3 = ""
TextA4 = ""
IF Bolt = 1 THEN TextA1 = "IN1 String to test the text."
IF Bolt = 2 THEN TextA2 = "IN2 String to test the text."
IF Nut = 1 THEN TextA3 = "IN3 String to test the text."
IF Nut = 2 THEN TextA4 = "IN4 String to test the text."
DIM ItemText[4]
ItemText[1] = TextA1
ItemText[2] = TextA2
ItemText[3] = TextA3
ItemText[4] = TextA4
2024-02-28 11:59 PM
Hi Joachim,
You are a genius!
Thank you, that worked perfectly and is most appreciated!
Best regards, Matt