Provide a self-description, how-to?

Forum for discussion about the documentation project.
Post Reply
Tourist Trap
Posts: 2958
Joined: Jun 02, 2015 16:24

Provide a self-description, how-to?

Post by Tourist Trap »

Hi

Just an idea that spawned recently in a corner of my head. I don't know if it is where it can be posted, sorry if I'm wrong in this anyway.

So it's about an issue that every beginner may meet, namely telling what version of fb he is running, on what platform exactly (and so on). I started a small code that could maybe be added as an example somewhere, ranking just after the classic "hello world" in my opinion, and more useful.

Code: Select all

 'source code for giving self-description of fb and its current running environment

var osState	=> "_"
var fbVer		=> __FB_VERSION__
var fbSig		=>  __FB_SIGNATURE__
var fbLng		=>  __FB_LANG__
var fbArg		=>  __FB_ARGC__

#ifDef __Fb_64Bit__
	osState &= "64bits_"
#else
	osState &= "32bits_"
#endIf

#ifDef __FB_LINUX__
	osState &= "Linux_"
#else
	#ifDef __FB_ARM__
		osState &= "ARM_"
	#else
		osState &="WIN_"
	 #endIf
#endIf

? "freebasic compiler version number "; fbVer, """"& fbSig &""""
? "freebasic current dialect in use "; uCase(fbLng)
? "number of arguments passed to this application "; fbArg
? "state of the OS currently running "; osState


getKey()
'eof
That's very simple at first sight, but hard to reach for the very beginner, and although so useful (in particular to communicate in the forum about a personal issue).

What I would like to add before leaving this to the appreciation of everyone, is that it could be extended to provide the current available stack size (I remember fxm having posted a how-to about this somewhere), and maybe thing like the graphics drivers names and all basic details, yet not having to be intrusive, that can help protraying the user's configuration in order to help him know what is going on, and ask for help more efficiently.


Thanks for the attention! Feel free to comment on this, or no ;)

edit: oh and something like this could also help:

Code: Select all

var s => "unicode test!"
#print typeOf(s)
Imortis
Moderator
Posts: 1924
Joined: Jun 02, 2005 15:10
Location: USA
Contact:

Re: Provide a self-description, how-to?

Post by Imortis »

You could also run do this on the command line:

Code: Select all

fbc -version
Tourist Trap
Posts: 2958
Joined: Jun 02, 2015 16:24

Re: Provide a self-description, how-to?

Post by Tourist Trap »

Imortis wrote:You could also run do this on the command line:

Code: Select all

fbc -version
Useful, thanks.

I wanted to ask something precisely about the switches. Can someone run a command that would tell him the switches that have been used in the compilation? Sometimes they are hidden in the IDE build menu (for instance a young beginner may compile to a dll due to a switch and not see why if hidden in somewhere dark in the IDE). Not sure it is possible at all. For instance -pp results in no real execution as it seems, so fbc "myfile" -pp would maybe be unable to return "-pp" in the console, even if asked to return the switches inside "myfile".

Other thing I would like to be added is a standard procedure to test the performance in a basic way. All of that reminds me the end of the installation of a game. There will be generally some information about the system in use, and some benchmark of the expected performances.
Imortis
Moderator
Posts: 1924
Joined: Jun 02, 2005 15:10
Location: USA
Contact:

Re: Provide a self-description, how-to?

Post by Imortis »

You can just call fbc without any parameters on the command line to get the flag list.

There is a -profile option, but that allows you to profile your code, not the computer or the compiler.
Post Reply