MPE V Migration Routines [ HP Pascal/iX Reference Manual ] MPE/iX 5.0 Documentation
HP Pascal/iX Reference Manual
MPE V Migration Routines
baddress
Usage
baddress(v)
Parameters
v A variable, procedure, or function.
Description
The function baddress(v) returns the byte address of v when v is a
variable name, and the entry point when v is a procedure or function
name. This variable may not be type file or a file type component of a
structured variable. Also, v cannot be a component of a packed
structure, except if it is a component of a PAC.
baddress is useful for calling certain intrinsics which require byte
addresses for parameters.
baddress returns an integer in the range minint..maxint.
NOTE [REV BEG]
baddress does not work correctly with the $OPTIMIZE compiler option
for addresses of variables. Use type coercion and addr[REV END]
instead. Refer to the HP Pascal/iX Programmer's Guide or to the HP
Pascal/HP-UX Programmer's Guide, depending on your implementation,
for more information on optimizer assumptions.
Example
TYPE
rec_type = RECORD
f1: integer;
f2: boolean;
f3: char;
END;
VAR
n: integer;
r: rec_type;
p: ^rec_type;
a: ARRAY [1..10] of 0..255;
pac: PACKED ARRAY [1..10] OF char;
pab: PACKED ARRAY [1..10] OF boolean;
Calls
baddress(n)
baddress(r)
baddress(r.f3)
baddress(p)
baddress(p^)
baddress(p^.f3)
baddress(a)
baddress(a[4])
baddress(pac)
baddress(pac[2]) { Legal since component type is char. }
baddress(pab)
baddress(pab[2]) { Error. }
cmpbytes
Usage
cmpbytes (s1, s2, l)
Parameters
s1 A PAC or string variable that contains a byte string to
compare.
s2 A PAC or string variable that contains a byte string to
compare.
l A shortint or bit16 expression that indicates the number of
bytes to be compared.
Result
A shortint indicating the result of the comparison:
0 : s1 is less than s2.
1 : s1 is greater than s2.
2 : s1 is equal to s2.
Description
The function cmpbytes compares the s1 and s2 byte strings for l bytes.
The result is a shortint value indicating that the s1 byte string is less
than, greater than, or equal to the s2 byte string.
NOTE This feature requires the compiler option STANDARD_LEVEL
'EXT_MODCAL'.
Example
$STANDARD_LEVEL 'EXT_MODCAL'$
program asmb005 (output)
type
pac20 = packed array[1..20] of char;
var
pac,pac1 : pac20;
i : integer;
s : shortint;
c,m : char;
b : boolean;
result : shortint;
begin
s := 4;
pac := 'abcd';
pac1 := 'abcd';
result := cmpbytes( pac,pac1,s );
writeln(result); {2}
pac := 'aacd';
pac1 := 'abcd';
result := cmpbytes( pac,pac1,s );
writeln(result); {0}
pac := 'abcd';
pac1 ;= 'aacd';
result := cmpbytes( pac,pac1,s );
writeln(result); {1}
end.
movebyteswhile
Usage
movebyteswhile (s, t, a, n, u, p)
Parameter
s A PAC or string variable that contains the source string to be
copied.
t A PAC or string variable to which the source is to be copied.
a An ordinal constant expression whose ordinal value is 0 or 1,
indicating whether the copy is to continue while the
characters are alphabetic (1).
n An ordinal constant expression whose ordinal value is 0 or 1,
indicating whether the copy is to continue while the
characters are numeric (1).
u An ordinal constant expression whose ordinal value is 0 or 1,
indicating whether the copied characters remain the same (0),
or whether all lowercase characters are upshifted (1).
p A shortint variable which will indicate the index in the
source array where the test condition, alpha or numeric,
failed.
Description
The procedure movebyteswhile moves a byte from the source array to the
target array if the byte meets the test conditions set by a or n. Once
the condition fails, the p of the byte is returned. If u is set, each
alphabetic character moved to the target array is upshifted. Either or
both of a and n must evaluate to 1. If neither evaluates to 1, then the
results are unpredictable.
The length field of a target string variable is not updated.
NOTE This feature requires the compiler option STANDARD_LEVEL
'EXT_MODCAL'.
Example
$STANDARD_LEVEL 'EXT_MODCAL'$
program asmb005(output);
type
pac20 = packed array[1..20] of char;
const
apac = pac20[20 of ' '];
var
pac,pac1 : pac20
s : shortint;
result : shortint;
begin
pac1 := apac;
pac := 'thisoisoaotest56789 ';
movebyteswhile( pac, pac1, true, true, true, s );
writeln (s); {20}
writeln('"',pac1,'"'); {"THISOISOAOTEST56789 ")
pac1 := apac;
movebyteswhile( pac, pac1, #1, true, false, s );
writeln (s); {20}
writeln('"',pac1,'"'); {"thisoisoaotest56789 "}
pac1 := apac;
movebyteswhile( pac, pac1, true, #0, false, s );
writeln (s); {15}
writeln('"',pac1,'"'); {"thisoisoaotest "}
end.
scanuntil
Usage
scanuntil (s, t1, t2, p)
Parameters
s A PAC or string variable that contains the source string to be
scanned.
t1 An expression whose value is of any char type.
t2 An expression whose value is of any char type.
p A shortint variable which will indicate the position in the
source byte string where t1 or t2 was found.
Result A boolean value.
true : indicates t2 was found.
false : indicates t1 was found.
Description
The function scanuntil scans the source byte string until either the t1
or t2 is found. The position at which the t1 or t2 was found is
returned. The result is a Boolean value indicating whether t2 or t1 was
found.
NOTE This feature requires the compiler option STANDARD_LEVEL
'EXT_MODCAL'.
Example
$STANDARD_LEVEL 'EXT_MODCAL'$
program asmb005(output);
type
pac20 = packed array[1..20] of char;
var
pac : pac20;
s : shortint;
c,m : char;
b : boolean;
begin
pac := 'thisoisoaotest56789 ';
c := '6';
m := ' ';
b := scanuntil( pac, c, m, s );
writeln (s); {16}
writeln (b); {false}
b := scanuntil( pac, 'x', m, s );
writeln (s); {20}
writeln (b); {true}
b := scanuntil( pac, #101, ' ', s );
writeln (s); {12}
writeln (b); {false}
end.
scanwhile
Usage
scanwhile (s, t1, t2, p)
Parameters
s A PAC or string variable that contains the source string to be
scanned.
t1 An expression whose value is of any char type.
t2 An expression whose value is of any char type.
p A shortint variable into which an index is returned which
indicates at which position in the source array the t2 was
found or the t1 was not found.
Result
A boolean value:
true : indicates t2 was found.
false : indicates t1 was not found.
Description
The function scanwhile scans the source byte string until a byte is found
that does not match the t1. The position where the match failed is
returned. The result is a boolean value indicating whether t2 was found
or t1 was not found.
NOTE This feature requires the compiler option STANDARD_LEVEL
'EXT_MODCAL'.
Example
$STANDARD_LEVEL 'EXT_MODCAL'$
program asmb005(output);
type
pac20 = packed array[1..20] of char;
var
pac : pac20;
s : shortint;
c,m : char;
b : boolean
begin
pac := 'aaaaaaaaabaaaaaaaaaa';
c := 'a';
m := 'c';
b := scanwhile( pac, c, m, s );
writeln (s); {10}
writeln(b); {false}
b := scanwhile( pac, 'a', m, s );
writeln (s); {10}
writeln(b); {false}
b := scanwhile( pac,#98 ,'a', s );
writeln (s); {1}
writeln(b); {true}
end.
waddress
Usage
waddress (i)
Parameters
i The name of a variable, procedure, or function.
Description
The function waddress(i) returns the byte address of i when i is a
variable name, and the entry point when it is a procedure or function
name. This variable cannot be type file or a file type component of a
structured variable. Also, i cannot be a component of a packed structure
as an argument, except when this component is an element of a PAC.
The waddress function is useful for calling copy text from baddress.
waddress returns an integer in the range minint..maxint.
NOTE [REV BEG]
waddress does not work correctly with the $OPTIMIZE compiler option
for addresses of variables. Use type coercion[REV END] and addr
instead. Refer to the HP Pascal/iX Programmer's Guide or the HP
Pascal/HP-UX Programmer's Guide, depending on your implementation,
for more information on optimizer assumption.
TYPE
rec_type = RECORD
f1: integer;
f2: boolean;
END;
VAR
n: integer;
r: rec_type;
p: ^rec_type;
a: ARRAY [1..10] OF integer;
pac: PACKED ARRAY [1..10] OF char;
pab: PACKED ARRAY [1..10] OF boolean;
PROCEDURE pro;
BEGIN
END;
FUNCTION f: integer;
BEGIN
END;
Calls
waddress(n)
waddress(r)
waddress(r.f2)
waddress(p)
waddress(p^)
waddress(p^.f2)
waddress(a)
waddress(a[4])
waddress(pac)
waddress(pac[3]) { Legal since component type is char. }
waddress(pab)
waddress(pab[3]) { Error. }
waddress(pro)
waddress(f)
MPE/iX 5.0 Documentation