Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - ketil

#46
Same thing happens with me on XP sp3 when i try to compile, but after 2-3 tries it compiles and runs fine.
It's almost as the program hangs until i try to compile it a couple of times, and then get released.
For me this error is periodically ...
#47
Quote from: MrTAToad on 2010-Nov-15
SELECT always generates one or more IF statements, rather than a jump table of some sort.

Sorry then, my mistake.

I thought SELECT would act like the switch command in C/C++ since GLBasic do convert the basic code to C++.
Therefore my answer was related to what happens when c++ is compiled into native code.

From your answer, I guess that GLB then uses it's own templates when converting the code to c++, and not necessairily using obvious C/C++ commands.

Because in C/C++ jump-tables is generated when compiling SWITCH statements and nested IF statements whit a nesting depth of n ( n depending of compiler optimization configuration ).

Have a look at this: http://books.google.no/books?id=qug840wejVQC&pg=PA500&lpg=PA500&dq=nested+if+statements+jump-table&source=bl&ots=egUoUadMW6&sig=KRN3uROG5c97hU8CxyzpU_8FYWY&hl=no&ei=GyLhTMugBpChOqOM-dcO&sa=X&oi=book_result&ct=result&resnum=5&ved=0CEQQ6AEwBA#v=onepage&q=nested%20if%20statements%20jump-table&f=false

Then again ... I guess i should not comment such threads as this one since I really don't know anything about the GLBasic's internal working, and you obviously do. I do probably think to much in the lines of C/C++, and made the assumption that i could draw a line between GLB and C++ since GLB seem to be an preprocessor ... SORRY  :(

But optimization is a very interesting area, so i guess i will fire up the good old IDA Pro disassembler and have a look a the code behind some functionality. It might not be a very useful thing to do in this case, but it's a lot of fun :)
#48
Quote from: Synthetic on 2010-Nov-15
Switches (Select in this case) are generally faster, though not by a lot, and it depends on the situation and compiler. It also can help with readability of your code. As a general rule, if you have a variable that may have 3 or more different potential results to deal with, a Select should be used. Also, a Select will only use the first matching case from the list and bypass any others that may also match so if that is an issue for what your trying to do, If statements would be the route to go.

I guess that depends on how many evaluations that is performed.
Is a jump-table (generated by switch) really faster if there's just one or two evaluations ?
A SELECT (that generates a jump-table) will in some cases be a lot faster the IF/ELSEIF (or several IF's) "if the probable positive evaluation" is not among the first few evaluations. That because all IF's will evaluated until true, and therefore an jump-table has a shorter path.

Confusing explaination ... eh ?
I'll let it be with that. It's a bit late now.

If you are going for optimised code, it will really pay of reading up on compiler construction.
Anyway ... I guess IF/SELECT is quite trivial when i comes to optimization. A good compiler should even that one out. :)
#49
Do posts like this really belong in our forum  :giveup:
Why not delete them at once, and give the poster an explanation (ex. that it's inapropriate) ?
#50
Quote from: erico on 2010-Nov-10
Thanks, get in touch.
Now those drawings from your friend are really awesome... Does he use PDpro 5?

Nope ... an old version of photoshop.
#51
That's not mine gfx, but my partner in crime (or was it business) Raymond's.

#52
Quote from: erico on 2010-Nov-09
if gfx needed I might be able to help...if time allows


VERY good 3d and logo work  =D
I might use you to outsource some logo-stuff for an consultant business i run.

For our 2d-gfx, you can have a look at theese (the two first one is for a almost finished iPhone game):

http://shockbolt.deviantart.com/art/Shrooms-concept-art-108166752
http://shockbolt.deviantart.com/art/Shrooms-concept-03-57262588?q=favby:DavidCoombes/39968360&qo=0
http://digitalartwork.no/

#53
What kind of terms are you offering ?
We can provide very high-class gfx and music.
#54
Cool  :)

I checked it out, and it's always ok to have good editors, but I quess i'll continue using the free windows-build for bluefish.
Anyway ... Thanks for the tip, Bigsofty.
#56
This is fast ...

Code (glbasic) Select

LOCAL s$ = "- OK -"

PRINT s$, 10, 10

POKE(s$, 1, "P")
POKE(s$, 4, "E")

PRINT s$, 10, 30

SHOWSCREEN
MOUSEWAIT

END



FUNCTION POKE: BYREF src$, pos%, ch$
// return FALSE if pos% is out of bounds
LOCAL rc% = TRUE
INLINE
unsigned int n = src_Str.len();
if(n >= pos) {
// Do getbuffer() not allocate if already initialized(and allocated) ? if i set length to 0 or 1, it still returns textbuffer and is writable. anybody ?
char * tmp_ = src_Str.getbuffer(n);
tmp_[pos]= ch_Str[0];
// Unless getbuffer() just return an pointer when DGStr is initialized, we have to use this (i don't know if that's the case)
src_Str.releasebuffer();

} else {
rc=0;
}

ENDINLINE
ENDFUNCTION



#57
Quote from: MrTAToad on 2010-Nov-07
Peek & Poke has already been done!

No.
It has not. At least not as default commands in GLB.
Maybe in an external library ?
If so, is there anybody that could provide a link ?
#58
PEEK and POKE :)

And then we would need GETPTR/READBUFFER (or something like that) to get an pointer to the databuffer of certain objects.
It could be used with the mentioned PEEK (as READ) an POKE.
Just like basic back in the days on the microcomputers :)
#59
Bullet with the oolong engine a couple of years ago: http://www.youtube.com/watch?v=_8h8yqcTdn8
#60
With a SETBMP X,Y function, I could load several background at one time, and change positioning. Or do a simple scroll when the background is larger than the screen, but not big enough to bother using a tile-scroller.