a week ago - last edited a week ago by Laszlo Nagy
Hi,
In a separate post, Jochen and AllanP showed how to use switches for arrays:
I wanted to do the same with text but for some weird reason it keeps returning an error when the type is changed to Parameter type is changed ABC. Could anyone advise what I am doing wrong in my code, so confusing?
Parameter Array Name: UI_Text_Array
!!Masterscript, 2D, 3D, Parameters Script - all empty
!!UI Script:
FOR i = 1 TO 6
ui_outfield "Text Parameter Array:", 0, 0 + (i - 1) * 20, 100, 14
ui_infield UI_Text_Array[i], 120, 0 + (i - 1) * 20, 220, 14
NEXT i
It returns the error " ' ' isn't a valid parameter name" from within the interface script.
From that error, I assume I haven't initialized the array. So I click on the button (1) in the Parameters beside the field UI_Text_Array to ensure it is set to array. Then in the little square box (2) I add 6 fields leaving them blank (3 and 4). Is this how one initializes an array, sorry for the super simple question.
I have attached the GSM file for ease of reference.
Many thanks and best regards, from Matt
Solved! Go to Solution.
a week ago
Your parameter being an array is the clue, but not in the way you might have thought:
You'd need to use version 2 of the infield: UI_INFIELD{2} UI_Text_Array[i], 120, 0 + (i - 1) * 20, 220, 14
Because UI_INFIELD only works with the parameter name being an actual string. Here however, because we have an array, we cannot do that; we need to pass a reference. So put in the param name without quotes.
a week ago
Your parameter being an array is the clue, but not in the way you might have thought:
You'd need to use version 2 of the infield: UI_INFIELD{2} UI_Text_Array[i], 120, 0 + (i - 1) * 20, 220, 14
Because UI_INFIELD only works with the parameter name being an actual string. Here however, because we have an array, we cannot do that; we need to pass a reference. So put in the param name without quotes.
a week ago
Hooray, thank you so much Runxel! It's amazing how many hours I sink into trying to get code working and how quickly you solve it, so so apreciated!!! Wishing you all the best, from Matt