ZenHAX
http://zenhax.com/

Solution for "greater than this and less than this" ?
http://zenhax.com/viewtopic.php?f=13&t=3952
Page 1 of 1

Author:  Acewell [ Tue Mar 14, 2017 7:56 am ]
Post subject:  Solution for "greater than this and less than this" ?

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:
get var long
if var < 4
    var = 4
elif var > 4 and < 8
    var = 8
elif var > 8 and < 12
    var = 12
endif


Code:
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:
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:
get var long
xmath check "var % 4"
if check != 0
    xmath var "var - check + 4"
endif


and even yet shorter way :)
Code:
get var long
math var x 4

Author:  aluigi [ Tue Mar 14, 2017 9:39 am ]
Post subject:  Re: Solution for "greater than this and less than this" ?

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

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Limited
https://www.phpbb.com/