Displaying array elements

Ask gaming related questions
larabee
Posts: 8
Joined: 06 Aug 2018, 16:06

Displaying array elements

09 Aug 2018, 14:14

Hi, I could do with some help.

I have a snippet of code, where I am at a point where my pointer shows that i wanna inform the user that we are working with the variable NrOfFound pointing to the first occurance of the array (ie. NrOfFound = 1). Does not matter, it could as well be 2 or 3... but it was 1 when i noticed. The line FoundArray[NrOfFound] was suddenly not usable. The code follows:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



So sorry, the snippet was originally meant to contain only like two the lines: FoundLine = FoundArray[NrOfFound] and then MsgBox FoundLine = %FoundLine% but has swelled because of alll the extra info when debugging.

The program has reached a point where it has found the occurance when the variable NrOfFound = 1. Now the code should assign he value of FoundArray[1] (which I think should be the word "Resists") to the variable FoundLine. However no code - except the unusable FoundLine := "Resists" does that. Any help would be highly appreciated. Anybody, please? How can I display the value of FoundArray[NrOfFound] (= Resists) ?? :thumbdown:
swagfag
Posts: 1103
Joined: 11 Jan 2017, 17:59

Re: Displaying array elements

09 Aug 2018, 14:59

FoundLine := FoundArray[NrOfFound] already does just that:

Code: [Select all] [Download] GeSHi © Codebox Plus

Array := ["Resists", "NoMore", "Died"]
Nr := 1
Line := Array[Nr]
MsgBox % Line
larabee
Posts: 8
Joined: 06 Aug 2018, 16:06

Re: Displaying array elements

09 Aug 2018, 16:33

Yes indeed, very smart. The declaration of an array must ofc come before it is used. I thought i had gotten the syntax with arrays all wrong. Anyways, thanks a lot for your help.

Return to “Gaming”

Who is online

Users browsing this forum: No registered users and 6 guests