Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / DBP Tips and Tricks

Author
Message
Sasuke
18
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 16th Apr 2009 23:07 Edited at: 17th Apr 2009 00:16
Hi guy's, thought I start a tips and tricks thread if thats ok. If you've encounter mad skillz out there please post away.

Tip - User Defined Types (UDT)

UDT's have many uses but oddly I've seen two of the main advantage's not being put into play, so I though I shed some light on the two elusive methods.

Method One - Pass/Calc/Return (Yeah, you try and come up with a name)

This is a handy method of reducing work load, not only that, it's much cleaner. So for example I wanted to shift and object within an array abit, so this would be the usual method:



See, tedious right, but through the miracle of UDT's you can do this:



See what I mean.

The Pass: pos.XYZ equals whatever _object( index ).vector.XYZ equals.
The Calc: then we do whatever we need to do with pos.
The Return: then return it back to the array.

This might not be the best example but it shows how it works and believe me, this cuts down on a ton of work with arrays that have many parameters.

Method Two - Stuff that in your Function!

This is a great way of reducing the length of function lines, like this:

function Object( Number as integer, Type as integer, Name as string, PosX as float, PosY as float, PosZ as float, Size as float, RotX as float, RotZ as float, RotY as float , Color as Dword... and so on.

Instead you can shove that in a UDT and do this:



To use it just do this:



There's my two methods for ya, hope you take them under you wing, Sasuke Out

Edit: If a Mod sees this, can you please add and 's' on the end of Tip in the thread title, forgot to write it, silly me.

A dream is a fantasy, if you achieve that fantasy it was never a dream to begin with.
Bursar
16
Years of Service
User Offline
Joined: 17th Sep 2008
Location:
Posted: 17th Apr 2009 13:52
You know there's a built in Vector3 data type? I can't see why you'd build a UDT for it over using the built in one.
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 17th Apr 2009 14:42
Quote: "You know there's a built in Vector3 data type? I can't see why you'd build a UDT for it over using the built in one."


True - but Sasuke's method works if you want 5 or more elements as well.

Quote: "This is a great way of reducing the length of function lines, like this:

function Object( Number as integer, Type as integer, Name as string, PosX as float, PosY as float, PosZ as float, Size as float, RotX as float, RotZ as float, RotY as float , Color as Dword... and so on.

Instead you can shove that in a UDT and do this:"


Thanks. I didn't know you could do that.
Sasuke
18
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 17th Apr 2009 14:55
Also it's an example, it can be used for anything. Also note that the reason I make a vec3 type is to store the data in variables rather than how DBP stores them. There's a thread about this called 'Vector type' I think (just search for vector) which talks about this, it's a good read.

Thanks GG.

A dream is a fantasy, if you achieve that fantasy it was never a dream to begin with.
calcyman
17
Years of Service
User Offline
Joined: 31st Aug 2007
Location: The Uncertainty Principle
Posted: 21st Apr 2009 19:03
These three tips should help you speed up any calculation-intensive code:


Tip - Don't repeat calculations

Code can be accelerated by removing un-necessary calculations. For example, how many of you have done something like this?



When really, you should do this:



Another example is the formula for the hyperbolic tangent:

y# = (EXP(x#)-EXP(-x#))/(EXP(x#)-EXP(-x#))

Which can be optimised to:



This means you only need to do one exponentiation, instead of four!



Tip - Don't divide by constants

You might have put something like this in your code:

a# = b# * h# / 2.0

You can improve speed like this:

a# = b# * h# * 0.5



Tip - Precalculate constants

Have you ever wrote something like this in your code?

diagonal# = sqrt(2)*sidelength#


If you've noticed, sqrt(2) is a constant. It can be replaced with the value of sqrt(2), which is 1.414214, accurate to 6 decimal places.

The optimist's right, The pessimist's right.
AndrewT
17
Years of Service
User Offline
Joined: 11th Feb 2007
Location: MI, USA
Posted: 21st Apr 2009 21:53
Quote: "Another example is the formula for the hyperbolic tangent:

y# = (EXP(x#)-EXP(-x#))/(EXP(x#)-EXP(-x#))

Which can be optimised to:
"


Or you can just use htan().

Anyways this is an interesting thread, I'll be sure to try and come up with some tips and post them here.

i like orange
Sasuke
18
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 21st Apr 2009 22:29
Thanks guys for the input, keep up the great work. Give me a sec to define what a Trick would be though, I think tips should be common practice, so maybe a trick would be uncommon practice, something that would be used to bypass common practice limitations, like when I found you could use text substitution at the precompile stages via constants, I think thats right, if so heres the first Trick for the thread.

Trick - Command like Functions using Constants

Awhile ago I was playing around with functions and constants like this which you've most likely encounter before:



So with that in mind I wondered if that could be taken further and you wouldn't believe what I stumbled on:



See what I mean, how COOL is that, even to find that just by playing around. But there's only one issue using this method, you can't use brackets on the line like: MakeCube 1,(100+50)... and this is why I think this should be a trick. It's perfect for functions that don't need any arguments though.

I made a thread about this awhile go so there's more information there on how this actually works: Something Interesting with Functions

A dream is a fantasy, if you achieve that fantasy it was never a dream to begin with.
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 21st Apr 2009 23:07
This is a cool thread. I'm gonna stick it in the Tutorials Thread, in Newcomers' Corner, if you don't mind.
BMacZero
18
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ NA / USA
Posted: 22nd Apr 2009 05:24
Quote: "Trick - Command like Functions using Constants"


!!!

That's cool!



Garion
16
Years of Service
User Offline
Joined: 7th Dec 2007
Location: Poland
Posted: 22nd Apr 2009 17:12
These are very good tips! I shall check this tread regularly now. I think it ought to be sticky, btw
BMacZero
18
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ NA / USA
Posted: 24th Apr 2009 01:14 Edited at: 24th Apr 2009 01:15
I just remembered a little timesaver that I think was mentioned by TDK a while ago.

Normally if you wanted to switch the value of a boolean, you'd have to do this:



Well, you can save four lines of code by doing this:





GIDustin
16
Years of Service
User Offline
Joined: 30th May 2008
Location:
Posted: 24th Apr 2009 07:53
Last time I checked you couldn't pass a UDT variable to a function so its interesting to find out that you can. Can you return one?

Either way, great thread. Gonna check back here often and try to add some of my own tips to this post later.
CuCuMBeR
21
Years of Service
User Offline
Joined: 11th Jan 2003
Location: Turkey
Posted: 24th Apr 2009 13:43
Here is a tip that really shortens your code (Using IanM's Matrix plugin)

You can pass array name into a function and set its properties.



There is always one more imbecile than you counted on.
Sasuke
18
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 24th Apr 2009 20:00 Edited at: 24th Apr 2009 20:04
Great stuff guy's, keep it up.

Tip/Info – Variables

Variables are parts of memory set aside for data that can be changed at any time. They are referenced with a name (identifier). For example x = 1, x would be the identifier. An identifier can’t be a reserved word (DBP command) like do, loop, if, end etc...

I think anyone getting into programming has a good grasp of mathematics so I don’t need to describe Numerical Values to you, just note, DBP can’t calculate powers (numbers multiplied by themselves) in the way other programming language for example 3 ** 4. That calculation equates to 3*3*3*3. The DBP way would be to use ‘^’ squared, so 3^4.

Info - Variable Assignment

Variable assignment is a fancy way of saying ‘setting up a variable’, for example x = 1. The =, or assignment operator basically is saying “the variable on the left points to the value on the right hand side”. So the example above assigns variable ‘x’ with a value of 1.

When we do this, a = x or a = x + x, we reference the value assigned to the variable, so if x = 4, a = x becomes a = 4 and a = x + x become a = 4 + 4.

Info - Self Assignment

In this case DBP can’t do self assignment in which a variable modifies itself based on a given value, so:



The first line in that snippet would look like this x =x+7, this would be the DBP equivalent.


Tip – Variable Naming

Ok guys, I seen some ridicules names for variables in my time like this: ObjMesh_RedWall01a_LevelSectionD2_Floor55_NearStairs02a_01... yeah you know who you are. This is madness, if you want to keep track of where your objects are chuck that into comment rather than the variable.


Tip – Undocumented Command – Mod

Mod, which is short for ‘Modulus’ is the name belonging to this sign, %. This is the DBP way of finding remainders, so x = 14 mod 4 or 14/4 would return the remainder which is 2, you can also do use the mod sign twice for mod like 14 %% 4.
Have a play with it, here’s one to start with:

X = 200 Mod 100
X = 200 %% 100


Tip – Global Variables

A Local variable in that when execution goes outside the method, example main loop, function etc... the value is lost. A Global variable retains its value and can be referred to from anywhere in the program. So for example:

Non-Global:


Since variable A is not local to the function nor global to the program, PrintA() would always print 0.

Global :


Now our variable A is global, it can be used anywhere in our program and PrintA() will print 2.


Tip – Global Identifier (Recommend)

Because there is no Identifier for a global the common method is writing it like this: gVariable or G_Variable, the reason we do this is so we can identify which variable is a local or global, because if we didn’t it can make understanding the program very difficult, not just to you but to anyone else look at it.


Tip - Conditional Execution

The operation that determines whether or not a specified set of conditions have been satisfied is called conditional execution.

Comparison Operators

These operators compare the given values, either numerical or string, and return the result.

These are DBP’s:
< - Less than
If 2 < 3
`do something
Endif

> - Greater than
If 2 > 1
`do something
Endif

<= - Less than or equal to
If 2 <= 2
`do something
Endif

>= - Greater than or equal to
If 2 >= 2
`do something
Endif

Oddly two were left out, not sure why though:
== - Equal to
!= - Not equal to

For the last two, you can use the = to see if something is equal to for example:

X = (10/5 = 1+1).

X would return 1 if it is equal, 0 if not, but personally it’s doesn’t look right, I think they should adopt the == into the DBP banks.

For != there’s a simple way of checking if something is not equal:

X = -(10/5 = 1+2)+1 .

Ok I might need to explain that one in more detail.

Let’s work out the brackets first,so: 10/5 = 2 and 1+2 = 3.

So there not equal and it would look like this X=(2 = 3), that would equal 0 or false. But we want to see if something is not equal, so we turn the answer into a minus -(2=3). Now that would equal -0, then we add a 1 to finish the formula -0 + 1 = 1 means it is true that it is not equal. If the brackets had produced a -1, again 1 is added which would make 0, which means it is false that it is not equal. Simple.


Tip - Logical Operators

Same as before just that these deal with logic:

and - &&
X = (4 > 3 and 1 + 1 = 2)
X = (4 > 3 && 1 + 1 = 2)

or – II
X = (1 + 1 = 2 or 2 + 2 = 4)
X = (1 + 1 = 2 II 2 + 2 = 4)

not –!

For not DBP doesn’t use ! and ‘not’ doesn’t work as a Logical operator in the way other languages, so:

True = 1
X = (not True) (would equal False or 0)

DBP can’t do this.


Things of Interest

My few odd finds while I was paying about, did you know that if you initialize an array with an – you get and array size of 12099488. Also if you use and string you get an array size of 19296400, so:

Dim Array(-) = 12099488
Dim Array("") = 19296400

Something odd:
x = -- = -2089877568 (the more – the value changes)
x = . = -2147483648
x = -.-..- = -2147483648
x = -..-... = 3
And there's a few more.

Hmm... I have no clue whats going on here, but .. and ... is used for range in other languages but I’m sure it doesn’t work for range in DBP.

A dream is a fantasy, if you achieve that fantasy it was never a dream to begin with.
BMacZero
18
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ NA / USA
Posted: 25th Apr 2009 02:51
Quote: "Oddly two were left out, not sure why though:
== - Equal to
!= - Not equal to "


They weren't left out, = is the same as == and <> is the same as !=.



Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 25th Apr 2009 07:46
Quote: "For not DBP doesn’t use ! and ‘not’ doesn’t work as a Logical operator in the way other languages, so:

True = 1
X = (not True) (would equal False or 0)

DBP can’t do this."


But note the behaviour of logical operators inside IF statements:



Sasuke
18
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 25th Apr 2009 14:29
BMacZero, really, cause I get an error if I use == using CodeSurge. But thanks for <>, totally forgot about that.

Benjamin, whoops, forgot to mention that, I was just thinking of it in variables which it doesn't work the same, but if statements then yes it does.

Thanks for the corrections guy's

A dream is a fantasy, if you achieve that fantasy it was never a dream to begin with.
Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 25th Apr 2009 14:41
Quote: "BMacZero, really, cause I get an error if I use == using CodeSurge. But thanks for <>, totally forgot about that."


He's saying that = can be used to the same effect instead of == in DBP. I think most BASIC languages do it this way.

Sasuke
18
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 27th Apr 2009 03:13
Oh I see, my mistake.

A dream is a fantasy, if you achieve that fantasy it was never a dream to begin with.
bobbel
15
Years of Service
User Offline
Joined: 5th Jan 2009
Location: In my DBPro case xD
Posted: 1st May 2009 09:19
Good thread, gonna check this regulary! Thansk for all the tips!

(\__/)
(O.o )
(> < ) This is Bunny. Copy Bunny into your signature to help him on his way to world domination!
Sasuke
18
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 5th May 2009 21:38 Edited at: 5th May 2009 21:39
YaY, this made the Newsletter, so come guy's, if you have anything to add please chuck it on, also you Mods out there must have some sneaky tips 'n' tricks up your sleeve

A dream is a fantasy, if you achieve that fantasy it was never a dream to begin with.
ulogix
15
Years of Service
User Offline
Joined: 1st May 2009
Location:
Posted: 6th May 2009 14:07 Edited at: 6th May 2009 18:12
You can do an equivalent of a self-assign in DBPro...

If you want to achieve this:

x += 1

you do it like this:

INC x

If you want to increment by a different value, just specify it as the second parameter. So for example, the equivalent of this:

x += 3

is this:

INC x, 3

The DEC command is similar except that it decreaes the value of x.
bobbel
15
Years of Service
User Offline
Joined: 5th Jan 2009
Location: In my DBPro case xD
Posted: 6th May 2009 18:29
and if you wanted something like
?

(\__/)
(O.o )
(> < ) This is Bunny. Copy Bunny into your signature to help him on his way to world domination!
Chris K
21
Years of Service
User Offline
Joined: 7th Oct 2003
Location: Lake Hylia
Posted: 6th May 2009 20:46
Here's a little time saving piece of code I always chuck in if I want to tweak a variable during the program.

Instead of saying...


say...


-= Out here in the fields, I fight for my meals =-
AndrewT
17
Years of Service
User Offline
Joined: 11th Feb 2007
Location: MI, USA
Posted: 7th May 2009 02:10
Quote: "and if you wanted something like + Code Snippet

x *= 3"




Of course at that point you might as well right out X = X * 3.

i like orange
bobbel
15
Years of Service
User Offline
Joined: 5th Jan 2009
Location: In my DBPro case xD
Posted: 7th May 2009 08:42
ok, i thought there was some special multiply code i didn;t knew about, like MUL x or something

(\__/)
(O.o )
(> < ) This is Bunny. Copy Bunny into your signature to help him on his way to world domination!
Sasuke
18
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 19th May 2009 23:35
Tip - Drag and Drop Content

If your using the U73 editor, you can drag a text file and drop it anywhere in the editor window, apon dropping a new tab will be created using the name of the text file, any text within the file will now be in your newly created tab. This is very handy if you have stored snippets or text backups of your code, you don't have to open the text file and copy and paste which sometime has errors with alot of code (very rare), just drag and drop, simple and efficient.

More Tips on the way soon, been really busy.

A dream is a fantasy, if you achieve that fantasy it was never a dream to begin with.
bobbel
15
Years of Service
User Offline
Joined: 5th Jan 2009
Location: In my DBPro case xD
Posted: 5th Jun 2009 09:47
A little tip when you have to divide a value

Sometimes when you have a for loop that reaches from -100 to 100, you have to possibility that the for loop returns a 0. when you divide this by 2, you'll get an error. to avoid this, you can do instead of this:

X = ForPosition/2

this":

X = ForPosition*.5

you just multiply with a half, and that way you can just halve everything

*ding ding*
Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 5th Jun 2009 11:12
Quote: "Sometimes when you have a for loop that reaches from -100 to 100, you have to possibility that the for loop returns a 0. when you divide this by 2, you'll get an error. to avoid this, you can do instead of this:"


No, you won't. A divide by zero error is when you divide by zero. Dividing 0 by 2 (or any other number except for 0) is fine.

Alfa x
18
Years of Service
User Offline
Joined: 1st Jul 2006
Location: Colombia
Posted: 8th Jun 2009 21:04 Edited at: 8th Jun 2009 21:04
Quote: "Method Two - Stuff that in your Function!

This is a great way of reducing the length of function lines, like this:

function Object( Number as integer, Type as integer, Name as string, PosX as float, PosY as float, PosZ as float, Size as float, RotX as float, RotZ as float, RotY as float , Color as Dword... and so on.

Instead you can shove that in a UDT and do this:

+ Code Snippet

type UDT_Object
Number as integer
Type as integer
Name as string
Job as string
PosX as float
PosY as float
PosZ as float
Size as float
RotX as float
RotZ as float
RotY as float
Color as Dword
`and so on
Endtype

function Object( temp as UDT_Object )

endfunction



To use it just do this:

+ Code Snippet

tObject as UDT_Object
tObject.Number = 1
tObject.Name = "Me"
tObject.Job = "Face Plant Specialist"

Object( tObject )



There's my two methods for ya, hope you take them under you wing, Sasuke Out "


I have a question.

From which version of DBPRO can you make this type of things.
It's a feature request i have been fighting for ages.
Math89
20
Years of Service
User Offline
Joined: 23rd Jan 2004
Location: UK
Posted: 8th Jun 2009 21:38
I think that passing an UDT to a function is a rather old feature. Unfortunately, returning an UDT from a function remains impossible.
Sasuke
18
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 15th Jul 2009 12:21
User Defined Types (UDT) Again!

If this doesn't make any sense, read my frist post.

Ok, there are a handful of useful ways to use UDT's, one being resetting other UDT's. For example, there might come a time when you need to reset all the variable in an array and most commonly people will do this:



Now it's time to throw this out and replace it with are Reset Method, here it is in action:



See that, now we've reset everything in two lines, cool beans. Another advantage to this is if you want to reset it but want to either retain a varible or alter a variable and for everthing else to reset. So if I wanted the Bullet ID to remain the same you could do this:



This will reset everything while retaining the a variable. And:



This will reset everything while altering a variable.

Now the major advantage to this is pre-defined UDT's or in other words a template that can be stored to be passed on to an array or variable later.

A dream is a fantasy, if you achieve that fantasy it was never a dream to begin with.
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 15th Jul 2009 14:33 Edited at: 15th Jul 2009 14:34
Multiplying is faster than dividing, by about 25% or more. If you want to do this:

x# = y# / 10

do this instead:

x# = y# * 0.1

Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 15th Jul 2009 18:18
Nice tips!

Gonna sticky this as it's far more relevant than some of the stickies here IMO.

Ohh, a little tip... worlds smallest cursor key movement code:

Inc x,rightkey()-leftkey() : inc y,downkey()-upkey()


Health, Ammo, and bacon and eggs!
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 16th Jul 2009 09:30
Wow, stickying this thread was like hanging it out to dry!

Gonna unsticky, then sticky again when traffic slows down, sorry for the WTF moment.


Health, Ammo, and bacon and eggs!
feiting shadow
18
Years of Service
User Offline
Joined: 12th Sep 2006
Location:
Posted: 16th Jul 2009 12:16
Sasuke, the string array's size, I would guess, is because we use strings to read just about everything, including files. So it has to be large enough to read anything we put into it. I always wondered how big it was, since I'm used to handling it using Char's (bytes) in other Basics.

And yeah, BV, I personally skip my eyes down and ignore all the stickies. They don't exist very much for me.

Signed
------
Sasuke
18
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 24th Jul 2009 02:27 Edited at: 24th Jul 2009 02:29
My first ex-Sticky, i'm so honoured... just kidding, but still it was nice while it lasted. I also sometimes skip the sticky, maybe it the color. Hmm... they should make a new kind of sticky, like if this was stickied again I want it to be pulsing red and blue... we shall call it the "Uber Sticky"... yeah, that's the dream

A dream is a fantasy, if you achieve that fantasy it was never a dream to begin with.
BMacZero
18
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ NA / USA
Posted: 24th Jul 2009 02:31
I remember not too long ago when we convinced them to give us a the green ones...it was a slight improvement for a while, but now the stickies are ignored one again...



Diggsey: I have a spine and memory, but one memorable guy says he hates me. What am I?
calcyman
17
Years of Service
User Offline
Joined: 31st Aug 2007
Location: The Uncertainty Principle
Posted: 24th Jul 2009 19:09
Quote: "Multiplying is faster than dividing, by about 25% or more. If you want to do this:"


I've already said that.

The optimist's right, The pessimist's right.
Sasuke
18
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 7th Oct 2009 23:26
Just thought I'd bump this back up again. Maybe others would like to contribute tips and advice.

A dream is a fantasy, if you achieve that fantasy it was never a dream to begin with.
thenerd
15
Years of Service
User Offline
Joined: 9th Mar 2009
Location: Boston, USA
Posted: 7th Oct 2009 23:39
yup, these are great tips!


forever loading...
Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 8th Oct 2009 00:01
Quote: "and if you wanted something like + Code Snippet

x *= 3"


Quote: "Of course at that point you might as well right out X = X * 3."


That's a nice idea AndrewT. But this is also possible:
inc x, x << 1
which is faster (not faster than x = x * 3 though)...

Which is my tip: using bitwise operators can also improve your code:

Bitwise operators and an example

shifting << or >>
Useful for: fast dividing or multiplying by 2 (Does not work with floats) << for multiplying, >> for dividing. The result is rounded down when uneven.

AND &&
Useful for: masking several bits. Like masking the color RGBA values:
red: (0x00FF0000 && Color) >> 16

OR ||
Useful for: Using multiple flags in one parameter (you can disassemble them by using AND)
#constant FLAG_A %0001
#constant FLAG_B %0010
#constant FLAG_C %0100
PassParameter(FLAG_A || FLAG_B || FLAG_C)
Then you can retrieve them again by using
if Param && FLAG_A > 0 then ...
if Param && FLAG_B > 0 then ...
if Param && FLAG_C > 0 then ...
This is typically used in windows commands.

XOR ~~
Useful for: fast subtraction of a value consisting of only 1's (bitwise).
For example, typically an image is inverted by the equation
255 - ColorComponent
But because 255 = %11111... you can write
New = %FF ~~ ColorComponent
We can expand this to (because bitwise operator only works on its corresponding bit) the even faster equation:
NewColor = %FFFFFFFF ~~ FullColor

NOT ..
Useful for: Well, for inverting I guess.

Sven B

Login to post a reply

Server time is: 2024-11-23 05:18:54
Your offset time is: 2024-11-23 05:18:54