IT-Berater: Theo Gottwald (IT-Consultant) > SDK and Third Party Know-How

Visual Designers and SELECT CASE AS LONG

<< < (2/9) > >>

Patrice Terrier:
It all depends of the type of code you are writing.
For example in a real time application like BassBox, everything must be processed at the fastest speed, especialy the WM_TIMER message, then the use of select case long as well as other optimizations is highly recommended.

Dominic Mitchell:
Sorry, but SELECT CASE AS LONG is not goint to make a dent in any of the examples quoted.
This is a misconception that is also prevalent on the PB forums.
Input from the user is a slow process.  It does not matter how fast the user types or moves
the mouse, the program still has alot of idle time between each message.  Updating the screen,
however, is a painfully slow process for a program. 
To the user, objects on the screen appear to move faster when their movement is smooth rather
than jerky. Therefore, for smooth animation the timer trick works very well because the program
is not tying up the system with many BitBlt's in a short period of time with small changes in position
shape or color that, by the way, are not discernible to the human eye.  That is the reason why
WM_PAINT is a low priority message.
WM_TIMER is the message with a priority even lower than that of WM_PAINT. The timers that cause
this message to be generated by the system have a resolution of about 10 to 52 milliseconds.
That is a long time that will significantly cut the number of BitBlt's done by animation code.

Edwin Knoppert:
In a *rare* occasion i need speed in code what the enduser will use.
I don't recall any important SELECT CASE statement used in such functions.

Most of my com functions are late bound, guess what that could have an impact if i needed speed.

Most of the things in my designer just can be slow.

Eros Olmi:
I use a lot SELECT CASE AS LONG in thinBasic engine.
Using it with or without AS LONG makes a lot of difference due to the use I make of it, mainly are loops with big SELECT CASE AS LONG ... executed many thousands of times per seconds.

But if SELECT CASEs a not much (let's say less that 10 CASEs) IF/ELSEIF clause is much faster than SELECT CASE AS LONG

Patrice Terrier:
Another benefit of using SELECT CASE LONG is its small exe size reduction.  :)

SELECT CASE has a lot of work to do, to branch onto the good case, especialy when they are not in order.

And one of the worst case, is using a STRING to select the good CASE (even using SELECT CASE STRING). 



[0] Message Index

[#] Next page

[*] Previous page

Go to full version