Solution for "greater than this and less than this" ?

Doubts, help and support about QuickBMS and other game research tools
Acewell
Posts: 706
Joined: Fri Aug 08, 2014 1:06 am

Solution for "greater than this and less than this" ?

Post by Acewell »

Hi i am trying to read an integer and maintain a multiple of 4,
i need something like this but is invalid syntax in Quickbms

Code: Select all

get var long
if var < 4
    var = 4
elif var > 4 and < 8
    var = 8
elif var > 8 and < 12
    var = 12
endif


Code: Select all

elif var greater than this and less than this
    var equals this

so is there another way to put that so it works in a bms script?
thanks for any help! :)


edit
nevermind i found another way :D

Code: Select all

get var long
xmath check "var % 4"
if check == 3
    math var + 1
elif check == 2
    math var + 2
elif check == 1
    math var + 3
endif


another shorter way :)

Code: Select all

get var long
xmath check "var % 4"
if check != 0
    xmath var "var - check + 4"
endif


and even yet shorter way :)

Code: Select all

get var long
math var x 4
Last edited by Acewell on Mon Apr 24, 2017 11:08 pm, edited 1 time in total.
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Solution for "greater than this and less than this" ?

Post by aluigi »

Your original solution was ok except that you forgot to repeat "var" in the second check:
elif var > 4 and var < 8