Page 2 of 2
Re: Use of DOS Write command for writing to the console
Posted: Wed Sep 11, 2013 10:41 pm
by JosDuchIt
Thanks Thomas,
The hard part for me wal getting to identify the appropriate function (translate) . I suppose i was close to getting blind when writing the last lines of my previous post
Re: Use of DOS Write command for writing to the console
Posted: Thu Sep 12, 2013 1:07 am
by tonyw
Did you recompile the Gui4Cli interpreter for OS4 or are you using someone else's work? I ask only because I'm not sure if you are trying to debug your own work or someone else's.
To test the "\#" functionality, you could try something like:
say "ABC\#68EFG" and see if the '68' is printed as a "D".
It might also be illuminating to replace the "\#155" with "\#27[" and see if it makes any difference. It's just a thought, the CSI (9B hex, 155 decimal or 233 octal) has its sign bit set and that may be relevant. The console interprets the two representations "CSI" and "ESC[" identically.
The '7' character (ASCII BEL control character) is interpreted by the console device as an Intuition->DisplayBeep() library call. The WB screen title bar will flash and (if enabled in Sound Prefs) a beep will sound.
Re: Use of DOS Write command for writing to the console
Posted: Thu Sep 12, 2013 7:41 pm
by JosDuchIt
@TonyW
Did you recompile the Gui4Cli interpreter for OS4 or are you using someone else's work?
The original 68k code is from D Keletsekis. He left the Amiga around the year 2000.
He made a source available to be compiled with SAS/C.
The source did not compile straight away, but i was able to correct it, then made it compatible with gcc and compiled it for OS4, i added some functionality most noticable the ability to execute Gui4Cli commands from the shell. (switching between gui mode and shell mode).So yes, you could say i am debugging my own modifications to the code.
Thanks for your suggestions
Re: Use of DOS Write command for writing to the console
Posted: Fri Sep 13, 2013 9:22 am
by JosDuchIt
@Thomas
The relevant part begins after case '#':. The stcd_i function (which you did not quote) is probably the culprit.
Here is the code :
int stcd_i (
const char * in,
int * lvalue)
{
return sscanf(in, "%hd", lvalue);
} /* stcd_i */
This code does not appear in the original SAS/C source indeed, it is a function provided by SAS/C not by gcc or OS4, this could indeed be the culprit
Re: Use of DOS Write command for writing to the console
Posted: Fri Sep 13, 2013 11:07 am
by tonyw
That is the most horrible code! It has so many ways to go wrong, none of them tested.
The "%hd" (according to my SAS/C manual) refers to a half-word result, so will be completely mis-understood by an ANSI-based compiler like gcc.
I would suggest rewriting the function like this:
Old function:
int stcd_i (
const char * in,
int * lvalue)
{
return sscanf(in, "%hd", lvalue);
} /* stcd_i */
Rewritten version:
int32 stcd_i (
const char * in,
int32 * lvalue)
{
if ((in == NULL) || (lvalue == NULL))
return 0;
return sscanf(in, "%ld", lvalue);
} /* stcd_i */
Re: Use of DOS Write command for writing to the console
Posted: Fri Sep 13, 2013 11:40 am
by salass00
@JosDuchIt
There's an stcd_i() implementation here that you could try:
http://code.ohloh.net/file?fid=BqumfX_A ... ed=true#L0
Re: Use of DOS Write command for writing to the console
Posted: Fri Sep 13, 2013 6:14 pm
by JosDuchIt
@tonyw & salas00
Both your functions work OK
Many thanks