Herbert said:
To whomever may assist,
I am trying to code an index (TLE - Tagged Logical Element)
identifier to load a customer statement into OnDemand (an
archival system created by IBM).
That is all fine and good, but is too far detached from anything
directly related javascript and its use to be of any help. And it
certainly is doing nothing to explain the what and why of the code you
have posted.
The TLE is defined as such:
idx = new index();
tle = new String("AcctNumber"); <!-- AcctNumber is an array
that can have one or more values -->
Javascript has end-of-lien and multi-line comment syntaxes, which should
be the only comment syntaxes used to comment javascript.
The comment here is false. I can see the quote marks around AcctNumber
and so I can see that it is a string literal not an Array.
tle.name = 'AcctNo';
tle.sequence = "\x80\x0A\x7F\xFF\xFF\xFF\xFF\xFF";
tle.level = "\xFF\xFF"
My issue is whether the syntax of "\x80" is the correct format
to code a hex value. Any assistance would be appreciated.
The problem here is that "to code a hex value" has little meaning in
javascript. The source code character sequence - \xNN -(where NN are two
characters from the digits 0 to 9 and the letters A, B, C, D, E and F
(in upper or lower case)), when they appear in a string literal or
regular expression literal, are a Hex escape sequence that defines the
character code (16 bit Unicode code point) of the character that will be
used in the sting or regular expression in place of the escape sequence.
However you go about defining the characters used in a string literal
the string primitive value that is the result is just (and only) a
sequence of 16 bit Unicode code points.
(Note: Hex escape sequences in string literals and regular expression
literals are a left-over from before javascript was standardised to use
16 bit Unicode code points in its string literals, and Unicode escape
sequences now exist (in the form \uNNNN) to allow the rest of (all of)
the code points to be expressed as escape sequences.)
Numeric literals may also be expressed in Hexadecimal, in the form:-
var n = 0xE4A2; //the number of hex digits used can vary considerably
- but the result is a numeric value that is a 64 bit IEEE double
precision floating point number (even if that number represents an
integer). (The handling (interpretation of and translation into IEEE
double precision floats) of HexIntegerLiteral numeric literals is
defined in ECMA 262, 3rd Ed. Section 7.8.3).
Generally javascript is not a language in which you work with (or think
about) bit sequences or Hex values.
Richard.