CreateArray - Forum

Forum Navigation
You need to log in to create posts and topics.

CreateArray

GOOD MORNING
I HAVE A PROBLEM WITH THE CREATION OF
OF ARRAY, I TESTED IN DIFFERENT WAYS, FOLLOWING THE INSTRUCTIONS OF THE GUIDE AND THE FORUM BUT IT DOESN'T WORK.
FOR EXAMPLE BY INSERTING ONLY ONE ELEMENT IN THE ARRAY IT WORKS, WHEN I INSERT MORE ELEMENTS IT DOESN'T WORK, I NEED TO KNOW THE CORRECT SYNTAX TO USE.
THANK YOU

@llazzarian

Can you post the code that you tried ? ... and any errors you encountered ?

Hi Gaev

HOW IT WORKS

CreateArray [prova] "A "

-------------------------------------------------

THIS DOES NOT WORK

CreateArray [prova] "A,B,C "

Hi Gaev

HOW IT WORKS

CreateArray [prova] "A "

-------------------------------------------------

THIS DOES NOT WORK

CreateArray [prova] "A,B,C "

CreateArray [prov] "A "

If [RISP] = "[prov]"
MoveObject "Container3" "120px" "24px"
Endif

A CONTAINER
ONE INPUT BOX
ONE BUTTON

@llazzari

THIS DOES NOT WORK
CreateArray [prova] "A,B,C "

It does work ... try and follow it with ...

AlertBox "Element0" "[prova(0)]" ""

I think the reason you think it is not working is because of your command ...

If [RISP] = "[prov]"

... I don't know what [RISP] is, but you can't compare array contents like this ... also, your array is named [prova], but the If command says [prov].

What do you really want to compare ?

Thanks Gaev, my intent was to compare a value inserted in a text input (variable [resp]) with the values of the elements of the array [prov], I insisted on this method because inserting only one element in the array [prov ] confirmed the correspondence, but with more values in the array this did not work, I could not understand why, now I have used this method and it works
CreateArray [prov] "A, B, C"

Loop 0 2 [N]
If [RISP] = "[prov ([N])]"
AlertBox "Element0" "[prov ([N])]" ""
MoveObject "Container3" "120px" "24px"
Endif
EndLoop

Hello, good day

@llazzari

inserting only one element in the array [prov ] confirmed the correspondence, but with more values in the array this did not work, I could not understand why

I do not know the internals of the If command, but when you had just one element, it might have viewed [prov] as a simple variable (instead of an array with one element).

The Loop/EndLoop is the proper way to sequence through each of the elements.

Note that you can search through the loop a bit faster by using ExitLoop inside the If/EndIf code block ... details can be found  here

 

luishp has reacted to this post.
luishp