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
Use of DOS Write command for writing to the console
- tonyw
- AmigaOS Core Developer
- Posts: 1483
- Joined: Wed Mar 09, 2011 1:36 pm
- Location: Sydney, Australia
Re: Use of DOS Write command for writing to the console
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.
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.
cheers
tony
tony
Re: Use of DOS Write command for writing to the console
@TonyW
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
The original 68k code is from D Keletsekis. He left the Amiga around the year 2000.Did you recompile the Gui4Cli interpreter for OS4 or are you using someone else's work?
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
@Thomas
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
Here is the code :The relevant part begins after case '#':. The stcd_i function (which you did not quote) is probably the culprit.
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
- tonyw
- AmigaOS Core Developer
- Posts: 1483
- Joined: Wed Mar 09, 2011 1:36 pm
- Location: Sydney, Australia
Re: Use of DOS Write command for writing to the console
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:
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:
Rewritten version:int stcd_i (
const char * in,
int * lvalue)
{
return sscanf(in, "%hd", lvalue);
} /* stcd_i */
int32 stcd_i (
const char * in,
int32 * lvalue)
{
if ((in == NULL) || (lvalue == NULL))
return 0;
return sscanf(in, "%ld", lvalue);
} /* stcd_i */
cheers
tony
tony
- salass00
- AmigaOS Core Developer
- Posts: 534
- Joined: Sat Jun 18, 2011 4:12 pm
- Location: Finland
- Contact:
Re: Use of DOS Write command for writing to the console
@JosDuchIt
There's an stcd_i() implementation here that you could try:
http://code.ohloh.net/file?fid=BqumfX_A ... ed=true#L0
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
@tonyw & salas00
Both your functions work OK
Many thanks
Both your functions work OK
Many thanks