[Implemented] CGI and Console Support

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

[Implemented] CGI and Console Support

Post by BackupUser »

Restored from previous forum. Originally posted by ferryman.

It would be very useful to have CGI and command line console support, both under Windows and Linux. I am working on a library to read/write from stdin/stdout and to get the enviroment variables. I then use MKCON.exe to set the console mode flag on the EXE, but are problems with doing things this way. To have these features bulit-in shouldn't be hard to do.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by ferryman.

I been sent by Fantaisie Software a beta version of their new compiler with console support .

ferryman.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Franco.

Hi Folks,
didn't find some console mode commands like:

Print (prints stuff out on the command line)
Input (expects that you types some stuff in)
Beep (gives some sounds through the laudspeaker)
Cls (deletes the text screen)
Locate (moves the cursor to 'line,column' -> in text mode)
to be continued...

Would be nice to add some stuff like that to the language.



Have a nice day...
Franco
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by wavemaker.

Well, ferryman, I've written a CGI library for Purebasic that handles some basic CGI operations (I've been told it's useful; even if it doesn't replace Php or MySql, it works!). You can find these functions in the library, downloadable from Paul's site http://www.reelmediaproductions.com:

* URLEncode(string.s): Convert a string to URL format (i.e. to be sent to a server).
* URLDecode(string.s): Decode an URL encoded string (i.e. to be read by a CGI program).
* StdIn(buffer.l): Transfer data to a string variable. The data will likely be URLencoded if it comes from a web client (that's why there's an URLDecode function included in this 'package' :wink:.
* StdOut(string.s): Transfer data from a string variable to , i.e. from a web server to a web client, or from your application to the console screen. I think a similar function (PrintN?) is supposed to be included in next version of PureBasic, but, until then, this one will do no harm.
* StdInSplit(field.l,boolean.l,string.s): Extract information from an URLEncoded string variable generated by an HTML form. It *must* be URLEncoded so not to confound the library with "=" and "&" signs, so use this function before decoding StdIn data with URLDecode. Form data comes in value pairs, like in this example: "message=Hi+this+is+Wavemaker&author=Wavemaker". You may likely want to have those values in separated strings, and that's the reason for this function. The first parameter is the number of order of the field you want to separate. The second is a boolean: if it equals to 0, the left side of the pair will be taken. If it's grater, the right side will. The string is the URLEncoded form data you want to 'split'.
* StdInLen(string.s): Obtain the number of fields of an URLEncoded string variable generated by an HTML form. It *must* be URLEncoded so not to confound the library with "=" and "&" signs, so use this function before decoding StdIn data with URLDecode. Form data comes in value pairs, like in this example: "message=Hi+this+is+Wavemaker&author=Wavemaker". You may likely want to know how many value pairs are present, and that's the reason for this function.
* GetEnv(variablename.s,buffer.l): Get the value of an environment variable of the system. The second parameter allocates memory for the resulting string (needed by the API, ask her about the GetEnvironmentVariable function).
* SetEnv(variablename.s,value.s): Set the value of an environment variable of the system. The result is greater than 0 if the function succeeds, 0 if it doesn't.

I hope you can use it for yor needs.

Regards,

Wavemaker

Juan Calderón Alonso
Registered user
Post Reply