Communicator 3000 MPE/iX Release 6.0 (Platform Software Release C.60.00) (30216-90269)

136 Chapter 9
Year 2000 Enhancements
New Date Intrinsics for MPE/iX
writeln('HPDATECONVERT intrinsic returned error',status);
{Convert 'date1' to the YYYYMMDD integer format. With 50}
{as the cutoff year. }
outtype := hp_dt_int_yyyymmdd_fmt;
HPDATECONVERT(inptype,date1,outtype,date1_18,status,cutoff);
if( status <> 0) then
writeln('HPDATECONVERT intrinsic returned error',status);
{Convert the 'date2_pac' to a YYMMDD integer format.}
{Default cutoff is assumed (i.e., 50) }
HPDATECONVERT(hp_dt_ascii_yymmdd_fmt,date2_pac,
outtype,date2_18,status);
if( status <> 0) then
writeln('HPDATECONVERT intrinsic returned error',status);
{compute the difference between the two dates}
HPDATEDIFF(outtype, date1_18,date2_18,temp_date,status,cutoff);
if( temp_date < 0) then
writeln(date1,' is #',temp_date,
'days later compared to ',date2_pac)
else if (temp_date > 0) then
writeln(date2_pac,' is #',temp_date,
'days later compared to ',date1)
else writeln(date1,' is same as ',date2_pac);
{offset date1_18 by the difference to get the }
{value of date2_18 through HPDATEOFFSET intrinsic.}
HPDATEOFFSET(outtype,date1_18,temp_date,date3_18,status,cutoff);
if( (date3_18 <> date2_18 ) and (status = 0)) then
writeln('Error Malfunction of HPDATEOFFSET intrinsic');
{Use the flexibility in converting the date to a display }
{string. Use '#0' to NULL terminate the format }
{specification string. }
fmt_pac := 'YY.ZMM.ZDD'#0;
print_len := 11; { 11 characters including #0 in fmt_pac }
HPDATEFORMAT(outtype,date1_18,fmt_pac,print_pac,print_len,status);
if( status <> 0) then
writeln('HPDATEFORMAT intrinsic returned error',status);
writeln('The converted date is: ',print_pac);
{The following demonstrates how a byte array can be }
{passed in place of an integer. We are storing the }
{integer 230196 in a packed array of characters, which is}
{an equivalent of a byte array. We subsequently cast the }
{address of this array to an integer pointer to read the }
{integer value out of it. }
HPDATECONVERT(hp_dt_int_yyyymmdd_fmt,date1_18,
hp_dt_int_ddmmyy_fmt,fmt_pac,status);
$push, type_coercion 'storage'$
if( iptr_type (addr(fmt_pac))^ = date1 ) then
writeln( 'Program worked fine! ')
else writeln( 'Error, in using byte array parameters !');
$pop$
end.
The expected output from the program is:
230196 is # 2days later compared to 960121
The converted date is : 96.1.23
Program worked fine!