Use of DOS Write command for writing to the console

A forum for general AmigaOS 4.x support questions that are not platform-specific
JosDuchIt
Posts: 291
Joined: Sun Jun 26, 2011 6:47 pm
Contact:

Re: Use of DOS Write command for writing to the console

Post 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
User avatar
tonyw
AmigaOS Core Developer
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

Post 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.
cheers
tony
JosDuchIt
Posts: 291
Joined: Sun Jun 26, 2011 6:47 pm
Contact:

Re: Use of DOS Write command for writing to the console

Post 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
JosDuchIt
Posts: 291
Joined: Sun Jun 26, 2011 6:47 pm
Contact:

Re: Use of DOS Write command for writing to the console

Post 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
User avatar
tonyw
AmigaOS Core Developer
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

Post 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 */
cheers
tony
User avatar
salass00
AmigaOS Core Developer
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

Post 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
JosDuchIt
Posts: 291
Joined: Sun Jun 26, 2011 6:47 pm
Contact:

Re: Use of DOS Write command for writing to the console

Post by JosDuchIt »

@tonyw & salas00

Both your functions work OK

Many thanks
Post Reply