ZenHAX

Free Game Research Forum | Official QuickBMS support | twitter @zenhax | SSL HTTPS://zenhax.com
It is currently Thu Apr 19, 2018 9:40 am

All times are UTC




Post new topic  Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Sun May 10, 2015 11:10 am 

Joined: Tue Apr 21, 2015 2:15 pm
Posts: 26
How can i get variable value from array?
Code:
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"


Top
   
PostPosted: Sun May 10, 2015 4:09 pm 
Site Admin
User avatar

Joined: Wed Jul 30, 2014 9:32 pm
Posts: 7851
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'.


Top
   
PostPosted: Sun May 10, 2015 5:13 pm 

Joined: Tue Apr 21, 2015 2:15 pm
Posts: 26
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


Top
   
PostPosted: Sun May 10, 2015 5:22 pm 
Site Admin
User avatar

Joined: Wed Jul 30, 2014 9:32 pm
Posts: 7851
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.


Top
   
PostPosted: Sun May 10, 2015 5:29 pm 

Joined: Tue Apr 21, 2015 2:15 pm
Posts: 26
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


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 5 posts ] 

All times are UTC


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Limited