Re: lib$find_file on Pascal
On Aug 19, 10:21*am, Ramon Jimenez <rjime...@ford.com> wrote:[color=blue]
> We are porting a Pascal app from a 32 bit VAX to a new Integrity Itanium Box.[/color]
:.[color=blue]
> We are using lib$find_file ( outfile, dummy, context, 'DATAFILE.' );
> The outfile is always recovered correct but sometimes dummy has an
> strange name[/color]
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.
btw... If this gets too complicated for you, then serveral folks
reading this newsgroup will be eager to provide professional
consulting service to help. The Email you posted with looks 'for for
real' if it is not just reply with a slightly encrypted Email address
to use if you would like to solicit those folks for professional help.
Good luck!
Hein van den Heuvel
HvdH Performance Consulting
Re: lib$find_file on Pascal
On Aug 19, 10:21*am, Ramon Jimenez <rjime...@ford.com> wrote:[color=blue]
> We are porting a Pascal app from a 32 bit VAX to a new Integrity[/color]
fyi... This topic is cross-posted in the itrc OpenVMS forum:
[url]http://forums12.itrc.hp.com/service/forums/questionanswer.do?threadId=1260793[/url]
Hein.
Re: lib$find_file on Pascal
Thank you Hein.
I mispelled the input it called Xoutfile, yes the resultant file is
called dummy, that's how I found I changed it to another value with
the same result.
The way the program is calling the function is:
lib$find_file ( Xoutfile, dummy, context, 'DATAFILE.' ) = RMS
$_NORMAL;
lib$find_file_end ( context := context )
Data definitions are, (I've to use the same definition but I got
compilation error)
Xoutfile : VARYING[ 132 ] OF CHAR := ZERO;
dummy : PACKED ARRAY[ 1..200 ] OF CHAR;
I dont found any other place inside the code were "dummy" it's used.
Regards Ramon
Re: lib$find_file on Pascal
I'll answer it there.
John
"Hein RMS van den Heuvel" <heinvandenheuvel@gmail.com> wrote in message
news:8bcb150f-737f-4b99-b95e-2bee93bf252e@59g2000hsb.googlegroups.com...
On Aug 19, 10:21 am, Ramon Jimenez <rjime...@ford.com> wrote:[color=blue]
> We are porting a Pascal app from a 32 bit VAX to a new Integrity[/color]
fyi... This topic is cross-posted in the itrc OpenVMS forum:
[url]http://forums12.itrc.hp.com/service/forums/questionanswer.do?threadId=1260793[/url]
Hein.
Re: lib$find_file on Pascal
OK, make up your mind. Here or there... ?
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
Re: lib$find_file on Pascal
On Aug 20, 8:20*pm, "John Reagan" <johnrrea...@earthlink.net> wrote:[color=blue]
> OK, make up your mind. *Here or there... ?
>
> 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[/color]
Thank you the explicit use of %DESCR worked.
Xoutfile was defined as varyng and dummy as packed array, my first
guess was to align both definition, but I got compilation errors.
Xoutfile and dummy were defined on different sections of the code, so
I move and put them together, I also set context to zero begin
execution.
After that seems that it works properly.
Thank you all for your help
Re: lib$find_file on Pascal
"Ramon Jimenez" <rjimen37@ford.com> wrote in message
news:80e0530c-f794-41c0-b021-
Thank you the explicit use of %DESCR worked.
Excellent. For those of you keeping score at home, here is what happened:
The prototype that comes in PASCAL$LIB_ROUTINES has the output string
defined as a PACKED ARRAY OF CHAR. Even when passing a VARYING to it, the
compiler would have generated a CLASS_S fixed-length descriptor for the
body. So when LIB$FIND_FILE wrote the result, it wrote the whole body and
didn't know to write into the length word. Using %DESCR on an actual
parameter overrides the formal definition. %DESCR generates the appropriate
descriptor for the actual parameter, in this case, a VARYING string. Now
with a CLASS_VS descriptor, LIB$FIND_FILE (actually some STR$COPY or some
such) knows to update the body AND the length word. The variable now has
the correct result WITH the correct length.
John Reagan