for - next Problem!

Programming related discussions related to game research
Shokoniraya
Posts: 416
Joined: Sat Sep 15, 2018 5:22 am

for - next Problem!

Post by Shokoniraya »

Seems like QuickBMS cant do a if <> endif like this

Code: Select all

get FILES long
get HEADER long
for i = 0 < FILES
get ID long
get TEST long
if TEST == -1
next i
endif
get SIZE long
get DUMMY long
get OFFSET long
log ID OFFSET SIZE
next i


what is the problem now? it really clear. when i run this script QuickBMS will always going to next i and dont read if and just do next i. but just have to do it when TEST == -1.
its wrong. QuickBMS just will find next i text in script and not matter there is a if option!
note: i am sure this problem never solve too :)

{
for i

if
next i
endif

next i
}
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: for - next Problem!

Post by aluigi »

Learn programming and learn the bms language.
I don't even know what you want to do but I guess you want the following:

Code: Select all

get FILES long
get HEADER long
for i = 0 < FILES
    get ID long
    get TEST long
    if TEST != -1
        get SIZE long
        get DUMMY long
        get OFFSET long
        log ID OFFSET SIZE
    endif
next i

Exists also a "continue" instruction that works like in C and other programming languages, it's something you can try in place of the "next i" of your wrong code.

Anyway PLEASE don't open topics for every single wrong usage you do of the bms language, I try to answer but it takes time and I prefer to dedicate it to other topics.
Delutto
Posts: 561
Joined: Tue Oct 13, 2015 1:26 pm

Re: for - next Problem!

Post by Delutto »

Why every time that you get stuck in something, you immediately assume that is a quickbms problem?!? Well, I don't kown about bms, but in general programming speaking, you are trying to do something against the logic, this your code will fail in any known programing language.
Every loop has a condition to end its cycle, in you case, the loop will ended when i = FILES, you can't override this, the only thing you can do is force to exit, breaking this loop, aluigi showed this to you a few days ago here.

Edit1: aluigi just answered...
Edit2: I think that you don't understand that is the "next" is part of the "for" instruction, and not another common instruction.
Last edited by Delutto on Sat Feb 02, 2019 9:18 pm, edited 2 times in total.
Shokoniraya
Posts: 416
Joined: Sat Sep 15, 2018 5:22 am

Re: for - next Problem!

Post by Shokoniraya »

Delutto wrote:Why every time that you get stuck in something, you immediately assume that is a quickbms problem?!? Well, I don't kown about bms, but in general programming speaking, you are trying to do something against the logic, this your code will fail in any known programing language.
Every loop has a condition to ended its ciclo, in you case, the loop will ended when i = FILES, you can't override this, the only thing you can do is force to exit, breaking this loop, aluigi showed this to you a few days ago here.

Edit1: aluigi just answered...
Edit2: I think that you don't understand that is the "next" is part of the "for" instruction, and not another common instruction.

so. i need to creat a dumper and i need to count header first for some reason
how can i do it when i cant put two different cycle? because last file will lost and i did it with calculating the header of first file and header of next file
Delutto
Posts: 561
Joined: Tue Oct 13, 2015 1:26 pm

Re: for - next Problem!

Post by Delutto »

aluigi's code works perfectly, so I don't understand what you're trying to do, but if for some reason you want to do the same thing using two loops, you just need store the values on first loop and recovery this values on second loop:

Code: Select all

get FILES long
get HEADER long
for i = 0 < FILES
   get ID long
   putarray 0 i ID
   get TEST long
   putarray 1 i TEST
   if TEST != -1
      get SIZE long
      get DUMMY long
      get OFFSET long
      putarray 2 i SIZE
      putarray 3 i OFFSET
   endif
next i

for i = 0 < FILES
   getarray ID 0 i
   getarray TEST 1 i
   if TEST == -1
      continue
   endif
   getarray SIZE 2 i
   getarray OFFSET 3 i
   log ID OFFSET SIZE
next i
GHOST DEAD
Posts: 218
Joined: Wed Jul 19, 2017 5:04 am

Re: for - next Problem!

Post by GHOST DEAD »

in some language, codes has an special id (it's up to your skill) and will find those id to do actors
but if you write [for $2], then actor will find first [next $2] in script, that is why can't run your work
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: for - next Problem!

Post by aluigi »

@GHOST DEAD
No sense, please don't post just for posting.
The topic has been already answered.
Thanks