@ Tony & Thomas
Thanks for reactions
To make things clear: the following lines are Gui4Cl command lines not arexx or DOS
say '\#7' // no flash screen or beep
Say "\#155\1;33;40;>0mText is now color 3" // nothing is written with OS4 compile
Gui4Cli indeed translates an argument string for any command.
A Gui4Cli argument string may contain variables such as $myvar or $myvar[0][6] and \n \t escape sequences with standard effect;
A typical argument string to the Gui4Cli command "say" (not the arexx "say") is seen below
say "my age is $age\nMy name is $name"
for \# the doc of the translate() function (joined) states:
"if there is a number following it, read in decimal value, otherwise disregard it, allowing concatenation of variables., such as $var1\#$var2 "
This is which makes possible command lines and argument strings such as
say '\#7' // flash screen & beep
Say "\#155\1;33;40;>0mText is now color 3" // text "Text is now color 3" is written in blue (or whatever colo 3 is on the screen)
This is the function Gui4Cli uses
Code: Select all
translate (char *buff, int length)
{
register UBYTE *p, *ba;
UBYTE *bufa, *bufb, *baend, *pend;
BOOL transflag, havetrans=0;
BOOL havebrak=0, hashflag;
LONG transloop = 0; // check against gd->maxtransloop
LONG lng;
int num, adv;
struct varparts *vp;
vp = &gd->vparts; // point to global varparts
lng = (LONG)length;
bufa = gd->membuff[1]; // gen buffers
bufb = gd->membuff[2];
do
{ transflag = 0;
havetrans = 0;
++transloop;
pend = &buff[length]; // end of src buff
baend = &bufa[length-1]; // end of dest buff
for (p=buff, ba=bufa; *p && (ba < baend); )
{
switch (*p)
{
case '$' : // VARIABLES
// keep bracketed expressions for the end - after the 1st
// pass and after all variables have been translated
if (p[1] == '(')
{ havebrak = 1;
*ba = *p; ++ba; ++p;
*ba = *p; ++ba; ++p;
}
else // Read in var name
{ havetrans = 1;
// Printf ("==========\nHave variable : %s\n\tSending : %s\n\ttransloop=%ld\n",
// p, &p[1], transloop);
if (!(p = transvar (&p[1], ba, baend-ba)))
return (0);
// Printf ("====>> After Transvar: %s\n", ba);
while (*ba) // go after var contents..
{ if (*ba=='$') transflag = 1; // checking for varINvar
++ba;
} }
break;
case '\\':
++p;
havetrans = 1;
hashflag = 0;
switch (*p)
{ case '\'': *ba='\''; break;
case 'n' : *ba='\n'; break;
case 't' : *ba='\t'; break;
case 'r' : *ba='\r'; break;
case '$' : *ba='$' ; break;
case '"' : *ba='"' ; break;
case '\\': *ba='\\'; break;
case '#' : // if there is a number following it, read
// in decimal value, otherwise disregard it
// allowing concatenation of variables.
if (!(adv = stcd_i(&p[1], &num)))
{ hashflag = 1; // to stop ++ba..
}
else
{ *ba=num;
p += adv; // skip number
}
break;
default : *ba = *p; break;
};
++p;
if (!hashflag) ++ba;
break;
default :
*ba = *p;
++ba; ++p;
break;
};
}
if (ba >= baend)
{ myerror (NULL, ERR_BUFF, 0, "\nTranslated string too long");
*buff = 0; // null the buffer & return it
return(0);
}
*ba = 0;
if (havebrak)
{ // if there are no more $ in string - goto eval.h & return
if (!transflag) return (dobrak (bufa, bufb, buff));
}
else // if no translation was done, return old buff as is..
if (!havetrans) return (1);
// continue with parsing..
strcpy (buff, bufa);
// return if deeptrans is off
if (gd->flags & gd_nodeeptrans)
return (1);
if (transloop > gd->maxtransloop) // trans is in wild loop..
{ Printf ("**ERROR: Can not translate %s\nSet MaxTransLoop higher.\n", buff);
*buff = 0;
return (0);
}
} while (transflag);
return (1);
}
This code is essentially the same for 68k & PPC (i did not modify it). The original 68k Gui4Cli sill reacts correctly under OS4
but with OS4 compile
say '\#7' // no flash screen or beep
Say "\#155\1;33;40;>0mText is now color 3" // nothing is written with OS4 compile
Given my understanding of the translate() function the '\#7' gui4cli string is translated to the unprintable character decimal 7 and thus presented to the Write() function.
The translated gui4cli string "\#155\1;33;40;>0mText is now color 3" presented to the Writ() function will be the unprintable decimal character 155 followed by the sequence "\1;33;40;>0mText is now color 3"
It should change the color and print the line "Text is now color 3"
I still don't see what is going wrong
I also looked into
file:///Datas:Manual/dos/book-main114.html
Esc[33m => switches on to blue , works OK
comparable to
Say "\#155\1;33;40;>0mText is now color 3" as with original 68k source
I also don't see where the 33 value in Esc[33m comes from
Bell or beep is not mentioned here, anybody ?