Hi i was just wondering how i can do the following i have tryed it and had no luck
Function test( style:Int )
Local flag=0
Local a=1
Local b=2
Local c=3
Select style
Case fast
flag=flag|a
Case tall
flag=flag|b
Case big
flag=falg|c
End Select
Print flag
End Function
test( fast | tall )
Now what this is supposed to do is return Fast + Small by using |
Ok this is just a example that i just made up but you get the idea hopefully, any help will be good thanks.
I could be wrong so if I am, ignore my post. Isn't | a logical operator? So a | b would return a, b or ab but not a + b.
Nicolas.
I think Nicolas is right, without reading the docs it looks like a logical op..
I think to do what your trying you will have to use a tokened string. like return a+"/"+b if a was fast and b was big it would return "fast/big" you then where needed just split the string up based on the "/" token..
I may be wrong tho and I'm sure others will have much faster better ways of doing it.
nuh i am using it for my gui to do, example for font Bold | Underline
Any other help please ?
As i said that was just a example i just made up.
Thanks for you help guys
You need to set uo some consts for fast, tall etc. If flag is fast|tall, it won't equal fast and it wont equal tall. You can do something like this:
const fast=1
const tall=2
const big=4
flag=big|fast
If flag&fast
print("flag is fast");
endif
if flag&big
print("flag is big");
endif
This is untested. Your consts have to be powers of 2 - 1,2,4,8 etc.
It's just an idea.
Local a:Int = 1
Local b:Int = 2
aFunction(Int(String(a) + String(b)))
Function aFunction(aNumber:Int)
'Do something with aNumber
EndFunction
In this example aNumber would be 12 and if I'm not mistaking this is what your looking for.
Nicolas.
Falken, thanks mate i just have to go with the IF/EndIf
Nicolas De Jaeghere, nuh thats not exactly what i needed but its a very nice example thank you