ZenHAX

Free Game Research Forum | Official QuickBMS support | twitter @zenhax | SSL HTTPS://zenhax.com
It is currently Thu Feb 20, 2020 11:26 pm

All times are UTC




Post new topic  Reply to topic  [ 403 posts ]  Go to page Previous 117 18 19 20 21
Author Message
PostPosted: Sun Feb 09, 2020 1:24 pm 

Joined: Fri Dec 15, 2017 1:42 pm
Posts: 35
Issue with the "continue" instruction:
Code:
set Flag long 0
set i long 0
set j long 0
for i = 0 < 3
   print "i = %i%"
   if Flag == 0
      math Flag = 1
      continue
   else
      math Flag = 0
   endif
   print "*** Message before embedded loop ***"
   for j = 0 < 4
      print "\tj = %j%"
   next j
next i

Image

Of course it's easy to bypass it by placing the code withing an If...EndIf.


Top
   
PostPosted: Sun Feb 09, 2020 4:46 pm 

Joined: Fri Dec 15, 2017 1:42 pm
Posts: 35
aluigi wrote:
The problem is related to the pre-allocation of the arrays like "putarray 0 totalFileNum 0 # fileID" that indeed adds a new element in the array.
...
If you remove pre-allocation everything is ok...

Usually pre-allocation is not necessary for arrays.

Sorry that I didn't see this in time. It's just that the doc of QuickBMS says "it's highly suggested to pre-allocate the array if you know the max value, example: PutArray 0 FILES 0". I've tested that if you allocate (totalFileNum - 1) elements and adjust the counter afterward it can produce the correct result. So for performance reasons is this routine still necessary?


Top
   
PostPosted: Fri Feb 14, 2020 3:11 am 

Joined: Tue Dec 20, 2016 8:18 pm
Posts: 20
BCGhost wrote:
Issue with the "continue" instruction:
Code:
set Flag long 0
set i long 0
set j long 0
for i = 0 < 3
   print "i = %i%"
   if Flag == 0
      math Flag = 1
      continue
   else
      math Flag = 0
   endif
   print "*** Message before embedded loop ***"
   for j = 0 < 4
      print "\tj = %j%"
   next j
next i

You can use this solution: break to label.
Code:
set Flag long 0
for i = 0 < 3
   print "i = %i%"
   if Flag = 0
      math Flag = 1
      break here
   else
      math Flag = 0
   endif
   print "*** Message before embedded loop ***"
   for j = 0 < 4
      print "\tj = %j%"
   next j
here:
next i

Though labels are also broken in some cases, for example, when you use them in functions then jump backwards doesn't work properly.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 403 posts ]  Go to page Previous 117 18 19 20 21

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