How GetArray PutArray works?

Doubts, help and support about QuickBMS and other game research tools
n97t7f7b57f
Posts: 27
Joined: Tue Apr 21, 2015 2:15 pm

How GetArray PutArray works?

Post by n97t7f7b57f »

How can i get variable value from array?

Code: Select all

PutArray 0 Ncount 0
goto NToffset
// get name of File in Name Table
for i = 0 < Ncount
get Nsize long
getdstring Name Nsize
putarray 0 -1 Name
next i

GetArray cell 0 5
print "%cell%"

SCRIPT's MESSAGE: cell
but 5th array element is "Texture2D"
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: How GetArray PutArray works?

Post by aluigi »

The script seems correct, I don't see issues except a possible problem caused by the first instruction that may make "putarray 0 -1 Name" to work from Ncount instead of 0.

Then do you know that the first index of an array is 0 and not 1?
"GetArray cell 0 5" takes the 6th element, just like 'i'.
n97t7f7b57f
Posts: 27
Joined: Tue Apr 21, 2015 2:15 pm

Re: How GetArray PutArray works?

Post by n97t7f7b57f »

aluigi wrote:Then do you know that the first index of an array is 0 and not 1?
"GetArray cell 0 5" takes the 6th element, just like 'i'.

i'm ok with that

aluigi wrote:The script seems correct, I don't see issues except a possible problem caused by the first instruction that may make "putarray 0 -1 Name" to work from Ncount instead of 0.

You are right. I removed "PutArray 0 Ncount 0" and it works.
Thank you.

But how i should initialize an array?
Ncount is number of strings in Name table
aluigi wrote:It's highly suggested to pre-allocate the array if you know the max value, example: PutArray 0 FILES 0
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: How GetArray PutArray works?

Post by aluigi »

You can initialize it like you did but then you must specify the correct index with putarray and not -1 which appends the element at the end.
So you must use "putarray 0 i Name", just that.
n97t7f7b57f
Posts: 27
Joined: Tue Apr 21, 2015 2:15 pm

Re: How GetArray PutArray works?

Post by n97t7f7b57f »

aluigi wrote:You can initialize it like you did but then you must specify the correct index with putarray and not -1 which appends the element at the end.
So you must use "putarray 0 i Name", just that.

Got it. Thank you again