Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PAUSE: FB instant keyword...
#1
I've found many of us using DO..LOOP to substitute =INKEY$ or waiting user input/respond before ending the program. Why not we make it as an official keyword called PAUSE. To simulate the success of DO..LOOP on handling this need here I made sub for it named PAUSE. Save this code as freebasic.bi and place it into \inc folder:

[syntax="FreeBasic.bi"]
#ifndef freebasic_bi
#define freebasic_bi

'------------------------
' PAUSE
'------------------------
sub pause
do until inkey$<>""
loop
end sub

'------------------------
' Add other commons used
' constants and routines
' in this file.
'------------------------

#endif 'freebasic_bi
[/syntax]

You could add some more useful commons thats you've always used while making FB application.

Here is the example of using it. Everyone should know already how to use it. Anyway, I just add it for this post completion:

[syntax="Pause.bas"]
'$include once: "freebasic.bi"

print "-------------------------"
print "FREEBASIC Compiler v0.11b"
print "-------------------------"
print "Press any key to exit...";
pause

[/syntax]

Any idea to add more commons routine and turn it as instant keywords are welcome. Wink
= inc(¢) Big Grin
Reply
#2
adding more stuff to the runtime ahg bad idea it's simpler to just make the function PAUSE and do it that way
Reply
#3
Doesn't SLEEP with no arguments do that?
color=blue]subxero - admin at this place.[/color]
Reply
#4
shadowwolf, IMHO FB front-end GNU compiler is quite eficient and wouldn't bloated the final output if any stuff is not being used or call within user's program. I'm not sure about this. May be a test could done to rectify the bloating issues. So, far I'm satisfied with FB output. Fast and slim and seem it doesn't put all stuff from the includes files. Smile


subxero, that would be a good option. I've not noticed that SLEEP can produce similar effect. This can be simplified with only a single line:

Code:
#define pause sleep

fantastic! Smile
= inc(¢) Big Grin
Reply
#5
it not that it would cause bloating it the pericable of the thing pluse you be setting presadent of adding new thing to fb runtime.

which could lead the evil mess other basic compilers suffer today it's a pause command tomorrow it's lillo gfx lib supporting built in direct3d and opengl.
Reply
#6
Personally I'm not a fan of adding any keywords whose functions could easily be duplicated by a few freeBASIC keywords that are already available; after all, the whole point of a programming language is to take the pieces that you're given and put them together so you can get the results that you want, and of all the tasks a BASIC programmer should have the privilege to enjoy, writing their own pause function ought to be one of them.

Besides, for some applications, " do while inkey$="":loop " might not be the best way to implement a pause for an FB program.
eese Witherspoon is so pretty
Her and Ryan Philippe make such a cute couple I think
My dream is that QB and all OSes share such a wonderful relationship
V Planet! QB Magazine
http://www.vplanetmag.com/
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)