[Date Prev][Date Next][Subject Prev][Subject Next][Date Index][Subject Index]

Re: way to tell if a S/G is a string vs number, and way to for XPL to determine XY version of execution platform



>>Harry Binswanger said: I think there's a length differences between something stored as a
number and as a string. Does Xy3 have a length function?<<

Yes, but @SIZ() only takes an <ISnn> argument, which could change the length of the input if
it was a NUMBER. There generally can be a length difference: the way a number is encoded as a NUMBER
data type is N N N N N N E S, where the N's are all of the digits in the number encoded as ASCII's
(30h to 39h), E is a binary value that tell us how many digits should follow a decimal point to be
inserted in the N N N N sequence (if E is not 00h) when displaying the number, and S is the sign
(0FFh for minus, 01h for positive/unsigned). In effect, the value of a NUMBER item is the N N N N
N's taken as an integer, times 10 to the minus E power, and then the sign added. So,
computationally, it is similar to "scientific notation" which displays things as N.NNN
times 10 to some power.

The NUMBER representation is faster than with strings represented in NN.NN form, because the latter
requires a "search" (slow) just to "find" the decimal point, and after the
decimal point is found, one really wants it removed from the string so the +, -, *, or / calculation
can be done on integers with no decimal point to muck things up during the digits part of the
computation.

The fact that this sequence ends with a 0FFh byte for negative numbers has, I think, caused havoc
for people who have tried to figure out the encoding. If you copy that string anywhere to look at it
(like into a edit buffer), it can cause XyWrite to go nuts, because a 0FFh byte in an edit buffer is
"always" (under normal conditions) followed by the two bytes that complete a 0FFh
triggered 3 byte encoding, and XyWrite code "breaks" in various ways when those next two
bytes are "not there." 

>>Harry Binswanger said: As to version check, you could easily construct one. E.g., check for
whether [BX ]wait[Q2 ] is acceptable.<<

I don't think so. Firstly, [BX ] doesn't even decode in XyWrite 3, and you can't create the [BX ],
not even with PFUNC. Keep in mind that those letters like BX only have a meaning if they exist in
the PRIMITIVE table for a given XyWrite version. And secondly, seeing "what is acceptable"
doesn't reduce to something that is easily testable in an <IF...> clause. I think you need to
try "completing" any suggestion you make, all the way down to the <IF..> statements
that can make decisions.

But in thinking about that, it is true that XY3 and XY4 do have different encodings for some
PRIMITIVE (i.e. function) names, and also, sometimes have different PRIMITIVE names for the same
encoding. The XYENC-TR.TXT file from the XYENC096.ZIP file at https://basspad.com/xywrite is probably the quickest way to
illustrate that, and it tells us that the PRIMITIVE encoding of 0FFh,82h,37h is an encoding of a
"DK" primitive in XyWrite 3, but the same encoding is associated with a "MW"
primitive in XyWrite 4. Working backward from the encoding using the @CNV() function on the
0FFh,82h,37h 3 byte value thus tells that we are running XyWrite 3 if @CNV() returns "DK",
and we are running XyWrite 4 if @CNV() returns "MW". That is stuff we can easily use in a
<IF..> statement, for the XPL code to make decisions without the user having to do anything.
However, it is bit tricky to create the 0FFh,82h,37h value to decode, because, no matter how we do
it with an 0FFh,82h,37h sequence in th!

In fact, let me propose that as "one way" to make the version determination, and lets see
if we can come up with a better one that tests for the XyWrite version that an XPL program is
running on in a way that can be used in an IF statement. 

Wally Bass

----- Original Message -----
From: "Harry Binswanger" <hb@xxxxxxxxxxxx>
To: "xywrite" <xywrite@xxxxxxxxxxxxx>
Sent: Tuesday, November 5, 2024 7:48:23 AM
Subject: RE: Any way to tell if a save/get is a string vs number?

Yes, decimal.
I think there's a length differences between something stored as a number and as a string. Does Xy3
have a length function?
As to version check, you could easily construct one. E.g., check for whether [BX ]wait[Q2 ] is
acceptable.
In Xy4 and maybe Xy3, there is a distinction between <ex> and <ex1>. The former will
generate a return from a subroutine but not exit the program. <ex1> will exit the whole
program it's in.
Regards,
Harry


-----Original Message-----
From: xywrite-bounce@xxxxxxxxxxxxx [mailto:xywrite-bounce@xxxxxxxxxxxxx] On Behalf Of
wbass@xxxxxxxxxxxx
Sent: Monday, November 4, 2024 10:01 PM
To: xywrite
Subject: Re: Any way to tell if a save/get is a string vs number?

Thanks, Harry.

>>Harry Binswanger said: ... another way is <VA{ASCII21}nn> <<

Harry, is that 21 decimal (which would be the "section sign" character)?  21 hex would be
the exclamation point character, which is what you indicated in you previous post, but the return
values were different for that VA function.

So what I am really still after is an Xy3 way to do it. The only way I know how to do it under Xy3
is to give the S/G id as the first argument to an XS command, which rejects a NUMBER type argument
as an error (but not an error that stops execution). There is then a (weird) way to tell that the XS
command was not happy -- you can read all about that on page 137 of Herbert Tyson's "XyWrite
Revealed" tome. (What Xy3 does when this error occurs is to inject a {ASCII-19} character at
the current cursor location!!!. And that is something that one can check and detect with XPL code.

If some Xy4 user is willing to see if XY4 does the same thing that Xy3 does for this error, that
would also be useful information to me.

Which raises the question: is there an approved way for an XPL program to tell whether it is running
on Xy3 vs Xy4? It seems like a serious flaw not to have such a version check designed in.

Wally Bass



----- Original Message -----
From: "Harry Binswanger" <hb@xxxxxxxxxxxx>
To: "xywrite" <xywrite@xxxxxxxxxxxxx>
Sent: Monday, November 4, 2024 2:52:06 PM
Subject: RE: Any way to tell if a save/get is a string vs number?

Wally,
Besides <VA!nn> another way is <VA{ASCII21}nn>. Replace "{ASCII21}" with the
section symbol that ASCII21 denotes. I can't show it here, probably because Outlook is Unicode.
Anyway, this method returns 1 for a number and 0 for a string. 
Regards,
Harry


-----Original Message-----
From: xywrite-bounce@xxxxxxxxxxxxx [mailto:xywrite-bounce@xxxxxxxxxxxxx] On Behalf Of
wbass@xxxxxxxxxxxx
Sent: Monday, November 4, 2024 4:32 PM
To: xywrite
Subject: Any way to tell if a save/get is a string vs number?

Sorry for the last msg. finger check, msg got away when half done

When a string representing a number is <SV..>ed or <SX..>ed, it is stored in a string of
bytes in either case, but the representation is different. So a S/G has a 'flag' that tells it which
representation is in use. Which means that there are two "data types" for a S/G, which
indicates the data type of the current representation being STRING or NUMBER.

What I'm after is some way were the FLAG setting (STRING or NUMBER) can be tested with an
<IF..> statement. No human intervention allowed.

I know of one XY3 way, but it's pretty kludgy and I don't know if it will work on XY4. If there is
way to do it on XY4 with some newly introduced function, I'd like to know about that, but an Xy3 way
to do it is what I'm really after.

Wally Bass


-- 
This email has been checked for viruses by Avast antivirus software.
www.avast.com