Operating System - OpenVMS
cancel
Showing results for 
Search instead for 
Did you mean: 

lib$find_file on Pascal

 
R. Jimenez
Occasional Visitor

lib$find_file on Pascal

We are porting a Pascal app from a 32 bit VAX to a new Integrity Itanium Box. We are compiling with ALIGN=VAX/ENUM=BYTE options and compilation run fine. However we have noticed that process that uses lib$find_file does not work as expected and did not recover filename as expected. We are using lib$find_file ( outfile, dummy, context, 'DATAFILE.' );
The outfile is always recovered correct but sometimes dummy has an strange name (find_binary_file:Dummy = ␤121␤␤␤␤␤␤␤␤123ORT123␤␤␤␤␤␤d␤␤Rz␤␤␤␤␤␤␤␤0␤␤␤␤␤␤␤␤␤␤␤␤␤␤␤␤␤␤␤␤␤␤␤␤␤␤␤␤␤␤␤␤␤␤␤␤␤ ␤{␤␤␤␤␤%␋♦
so the task fails.
Any help or any place I can find information related to this error?
4 REPLIES 4
Wim Van den Wyngaert
Honored Contributor

Re: lib$find_file on Pascal

Could you post the concerned source code (with declarations) ?

Wim
Wim
Hein van den Heuvel
Honored Contributor

Re: lib$find_file on Pascal

This question is cross-posted in the comp.os.vms newsgroup under the same title.

Over there I answerred:

> We are porting a Pascal app from a 32 bit VAX to a new Integrity Itanium Box.
:.
> We are using lib$find_file ( outfile, dummy, context, 'DATAFILE.' );
> The outfile is always recovered correct but sometimes dummy has an
> strange name


I guess that worked on VAX, so it should be OK, but those names
selected are certainly 'odd'

The first argument to find_file is in fact an INPUT specification...
called outfile?
The second argument is the output and typically the most important
part, but called dummy?


- Is the find_file return status being checked before using dummy?
You can only look into 'dummy' on succes.


- How is the descriptor for 'dummy' set up?


- Is LIB$FIND_FILE_END used, like it should be?


It might be a 'tricky' memory corruption problem which was always
there, but never seen.
For example, the 'context' roughly corresponds with an RMS FAB.
If you manager to accidently flip the 'low' bit in the fap options
longword, then RMS will be told to work asynchroneously givign
surprise results... sometimes it 'seems' to works. Sometimes not.


This problem may require profession porting expertise.

Regards,
Hein van den Heuvel
HvdH Performance Consulting

R. Jimenez
Occasional Visitor

Re: lib$find_file on Pascal

I'm going to follow the thread in comp.os.vms.
John Reagan
Respected Contributor

Re: lib$find_file on Pascal

You didn't get enough information on how "dummy" is declared. VARYING OF CHAR? PACKED ARRAY OF CHAR?

You also didn't say where you got the prototype of LIB$FIND_FILE from? SYS$LIBRARY:PAS$LIB_ROUTINES? Your private version?

Here's an example that works:

[inherit('sys$library:starlet',
'sys$library:pascal$lib_routines')]
program find_file(input,output);

var
file_spec : varying [132] of char;
result_spec : varying [132] of char;
context : unsigned;
ret_stat : unsigned;

begin
context := 0;

write('Enter filespec to parse: ');
while not eof do
begin

{ Read the filespec from the user }
readln(file_spec);

{ Loop and parse the file spec }
repeat

{ Parse it... }
ret_stat := lib$find_file(
file_spec,
%descr result_spec, { Use %DESCR to get CLASS_VS }
context);

if (not odd(ret_stat)) and
(ret_stat <> RMS$_NMF) and
(ret_stat <> RMS$_FNF)
then
lib$stop(ret_stat);

if (ret_stat <> RMS$_NMF) and
(ret_stat <> RMS$_FNF)
then
writeln(result_spec);

until (ret_stat = RMS$_NMF) or (ret_stat = RMS$_FNF);

{ Clear LIB$FIND_FILE context }
lib$find_file_end(context);

{ Get another file spec }
write('Enter filespec to parse: ');

end;
end.

Note the explicit use of %DESCR on the output argument for LIB$FIND_FILE.

John