Feature request: instrisic Defines for console / gui mode
-
- Posts: 564
- Joined: Sep 27, 2016 18:20
- Location: Valencia, Spain
Re: Feature request: instrisic Defines for console / gui mode
If the suggestion is implemented, additional features can be added like flagging as an error the use of SLEEP without parameters in an application compiled as a Windows GUI.
Re: Feature request: instrisic Defines for console / gui mode
and without any graphics windows defined by Screen[Res]().Josep Roca wrote:If the suggestion is implemented, additional features can be added like flagging as an error the use of SLEEP without parameters in an application compiled as a Windows GUI
Re: Feature request: instrisic Defines for console / gui mode
OK, no harm done.marpon wrote:i apologize if my formulation did hurt you, my intention was not to "insult" any people.
I am perfectly able to grasp that difference. I just don't believe that an intrinsic define console vs Gui provides a great added value. IMHO an application-defined switch is clearer, simple because it's explicit.paul doe wrote:I fail to see where the insult is (again). However, I do see that you're unable to grasp the difference between an intrinsic define and a #define provided by the application.jj2007 wrote:Why do simple questions so often trigger subtle insults here?
Right, I do that all the time.Intrinsic defines are a way for the compiler to expose internal state to the application being compiled, so that the app can branch differently depending on that state (to allow compiling to different platforms, say). A #define is something that the application defines; the preprocessor just replaces the definition with the appropriate text wherever the definition is referenced.
Where did I propose that?So, allowing for redefinition of an intrinsic (what you propose) makes the definition very non-intrinsic, and thus, pointless.
Re: Feature request: instrisic Defines for console / gui mode
sleep interception not so easyfxm wrote:and without any graphics windows defined by Screen[Res]().Josep Roca wrote:If the suggestion is implemented, additional features can be added like flagging as an error the use of SLEEP without parameters in an application compiled as a Windows GUI
but work-arround is possible in code
for graphics windows defined by Screen[Res]()
If ScreenPtr = 0 Then ... can check it
for Windows GUI using the __FB_GUI__ do the job
Re: Feature request: instrisic Defines for console / gui mode
Yes, of course, but it's a test at run-time while the test on "__FB_GUI__" will already be available at compile time.marpon wrote:but work-arround is possible in code
for graphics windows defined by Screen[Res]()
If ScreenPtr = 0 Then ... can check it
Re: Feature request: instrisic Defines for console / gui mode
that's why i've said it's not easy (inside compiler)fxm wrote:Yes, of course, but it's a test at run-time while the test on "__FB_GUI__" will already be available at compile time.marpon wrote:but work-arround is possible in code
for graphics windows defined by Screen[Res]()
If ScreenPtr = 0 Then ... can check it
i think we could use fb_GfxScreenPtr on the fb_sleep fonction
on the user code quite simple...
Last edited by marpon on Sep 13, 2018 19:09, edited 1 time in total.
Re: Feature request: instrisic Defines for console / gui mode
Under Windows, we can test at run time the presence of :
- a graphics window with "ScreenPtr",
- a console window with "GetConsoleWindow()".
- a graphics window with "ScreenPtr",
- a console window with "GetConsoleWindow()".
Re: Feature request: instrisic Defines for console / gui mode
sure
but it does not be what José is requesting , an error from the compiler on that wrong situation
for that we need to act at fb_sleep interception
i think we could use internally fb_GfxScreenPtr that is the source of ScreenPtr
and could have a function to get env.clopt.modeview (my added new var)
i will check this week end (if nobody has a solution of course)
it"s too late for me now.
but it does not be what José is requesting , an error from the compiler on that wrong situation
for that we need to act at fb_sleep interception
i think we could use internally fb_GfxScreenPtr that is the source of ScreenPtr
and could have a function to get env.clopt.modeview (my added new var)
i will check this week end (if nobody has a solution of course)
it"s too late for me now.
Re: Feature request: instrisic Defines for console / gui mode
Not sure where this topic is going on SLEEP or what all the ultimate needs are, but for the "__FB_GUI__" addition, it will tell the programmer, at compile time, if '-s gui' was passed on the command line, that's it. What programmers use it for, I leave up to them.
Hacking on SLEEP:
marpon, you can do whatever you want with your pull request while it exists as a pull request, including completely rewriting what is in the commits. It takes some practice to find out what you can do with git. In this case I would do a 'soft reset' to an early version and re-commit the changes. When you push (again) to the pull request, you will need to --force it.
Good stuff, keep at it. :)
Yea, SLEEP is a bit of an oddball, both a sub and a function, something not allowed in normal user code, but the compiler does it anyway.marpon wrote:sleep interception not so easy
Hacking on SLEEP:
Code: Select all
'' hack, undefine both versions of SLEEP, one is a function, other is a sub
#undef sleep
#undef sleep
'' declare the rtlib functions
declare sub fb_Sleep alias "fb_Sleep" ( byval amount as long = -1 )
declare function fb_SleepEx alias "fb_SleepEx" ( byval amount as long, byval keyflag as long ) as long
'' SLEEP interceptors
function Sleep overload ( byval amount as long = -1 ) as long
print " - SLEEP(1) intercepted!"
fb_Sleep( amount ) '' call original sleep command
return 0
end function
function Sleep overload ( byval amount as long, byval keyflag as long ) as long
print " - SLEEP(2) intercepted!"
return fb_SleepEx( amount, keyflag ) '' call original sleep command
end function
'' DEMO
print "Wait for keypress";
sleep
print "Wait for keypress, or 5 sec";
sleep 5000
print "Wait for keypress, or 5 sec";
sleep 5000, 0
print "Wait 5 sec";
sleep 5000, 1
marpon, as St_W points out, ENUM's are a good practice for this sort of thing, but I don't think there should be both fbc.subsystem and "modeview" options, tracking the same info. They can be combined.St_W wrote:You may also consider changing the "subsystem" member in FBCCTX type (in fbc.bas) to use your enum type instead of a string. The implementation of the "-gen" option may act as an implementation help for that too.
Good stuff, keep at it. :)
-
- Posts: 606
- Joined: Nov 28, 2012 1:27
- Location: CA, USA moving to WA, USA
- Contact:
Re: Feature request: instrisic Defines for console / gui mode
I program in Linux only, but ...
I simply ask SCREENINFO about the driver.
If it is an empty string, I am in console.
(Some of the other info also confirns NOT graphics, but this is the easiest.)
Does that work in Windows, also?
David
I simply ask SCREENINFO about the driver.
If it is an empty string, I am in console.
(Some of the other info also confirns NOT graphics, but this is the easiest.)
Does that work in Windows, also?
David
Re: Feature request: instrisic Defines for console / gui mode
Yes but the '(ScreenPtr = 0)' test must also work in Linux.
Re: Feature request: instrisic Defines for console / gui mode
@coderJeff
thank"s for my quick request implementation, now we have __FB_GUI__ on the rolling v1.06.0
thank"s for my quick request implementation, now we have __FB_GUI__ on the rolling v1.06.0
Re: Feature request: instrisic Defines for console / gui mode
@coderJeff,
I propose that I take into account the corresponding update of the documentation, if it is okay?
I propose that I take into account the corresponding update of the documentation, if it is okay?
Re: Feature request: instrisic Defines for console / gui mode
@marpon, you are welcome. I learned some new things too. In future I will try to give better guidance/instruction. The quality of pull request could be improved. But we all have to start somewhere.
@St_W, yea, having a merge from marpon:master to fbc:master was a little different than what I usually see. After merging, the source reference just disappeared, gone; that was unexpected. I think having a separate branch for the pull request would work a little cleaner.
@fxm, yes, thank-you. Please do.
@St_W, yea, having a merge from marpon:master to fbc:master was a little different than what I usually see. After merging, the source reference just disappeared, gone; that was unexpected. I think having a separate branch for the pull request would work a little cleaner.
@fxm, yes, thank-you. Please do.
Re: Feature request: instrisic Defines for console / gui mode
Done:
- KeyPgDdfbgui → fxm [Added new page]
- CatPgDddefines → fxm [Updated after '__FB_GUI__' page creation]
- CatPgFunctIndex → fxm [Updated after '__FB_GUI__' page creation]
- CatPgFullIndex → fxm [Updated after '__FB_GUI__' page creation]
- CompilerOpts → fxm [Updated after '__FB_GUI__' page creation]
- KeyPgDdfbgui → fxm [Added new page]
- CatPgDddefines → fxm [Updated after '__FB_GUI__' page creation]
- CatPgFunctIndex → fxm [Updated after '__FB_GUI__' page creation]
- CatPgFullIndex → fxm [Updated after '__FB_GUI__' page creation]
- CompilerOpts → fxm [Updated after '__FB_GUI__' page creation]