What ideas do you need? How to create a temp file? How to read/write
a temp file?
When you are specific, you can get a good answer in 1 or 2 posts,
intead of in 30 posts.
Why? Is there some reason you can't use a TACL variable for the same purpose?
>Any ideas?
Sure.
1) concoct a name for your temp file (optional)
2) create it
3) write to it
4) read from it
Seriously, though -- what have you tried so far, and what happened when you
tried it? If you're actually working on this and run into problems, I'll help
you solve them, but I'm not going to do your job for you. If you're completely
baffled and have no idea where to start, check out the descriptions of the
#CREATEFILE and #REQUESTER builtins in the TACL Reference Manual, and read
chapter 4 ("Accessing Files") in the TACL Programming Guide.
He didn't actually say he wanted to create the file from TACL code. If the file is to be created from some other program, then read in a TACL routine, that is a possible reason for not using a TACL variable. Another possible reason could be that the amount of data is very large.
If the file is written in another program, and is not very large, then the FILETOVAR command followed by an #EXTRACT loop probably is easier than using #REQUESTER. If the file is large, then #REQUESTER probably is the best way.
This probably doesn't apply, but just in case: Guardian has a special sort of file called a temporary file, which is deleted immediately when it is closed. That kind of file is not appropriate for passing data from one program to another. It is useful only for temporarily holding data during the execution of a program when the data is too large to keep all in memory. I don't know whether one can create and use that kind of temporary file in TACL.
Anyway, temporary files can be created by any Tandem process and let
to die when the process expires However the process can choose to
make the temporary file permanent by formally renaming it.
Also a process can obtain (from Guardian) the name of the temporary
file and pass that name around without any restrictions.
The potential uses of a temporary file are up to the process that
creates it. The size of a temporary file does not depend solely on
the size of memory, it depends on the intentions of the creator
process.
TACL can create any type of file allowed by Guardian, Enscribe or
whatever database it is subscribing to.
No, but he did say that he wants to write to it, then read it, with a TACL
routine, which certainly implies that it *should* be created in the TACL code
as well.
> If the
> file is to be created from some other program, then read in a TACL routine,
> that is a possible reason for not using a TACL variable.
He's writing to it in the TACL routine.
>Another possible
> reason could be that the amount of data is very large.
Right, I understand that. I wanted to find out what his reasons were for
wanting a temp file. Those are valid reasons, but in the absence of such
reasons, he's probably better off using a TACL variable.
>
> If the file is written in another program, and is not very large, then the
> FILETOVAR command followed by an #EXTRACT loop probably is easier than using
> #REQUESTER. If the file is large, then #REQUESTER probably is the best way.
Again: he said he wants to write to it, then read it, in the TACL routine.
>
>This probably doesn't apply, but just in case: Guardian has a special sort of
> file called a temporary file, which is deleted immediately when it is closed.
> That kind of file is not appropriate for passing data from one program to
> another. It is useful only for temporarily holding data during the execution
> of a program when the data is too large to keep all in memory. I don't know
> whether one can create and use that kind of temporary file in TACL.
Yes, you can:
#CREATEFILE /FILENAMEV filevar/ $volume
creates a Guardian temp file $volume.#nnnnnnn and returns that name in
[filevar].
There are (at least) two ways to parse his statement. The way you interpreted it, the "in TACL" applies to all three preceding actions. My point was that he did not make it clear that the "in TACL" applied to all three actions. It might be that he only meant that the file would be read in TACL. Maybe that is what he meant; maybe not.
>
>>If the
>>file is to be created from some other program, then read in a TACL routine,
>>that is a possible reason for not using a TACL variable.
>
>
> He's writing to it in the TACL routine.
>
Maybe.
>
>>Another possible
>>reason could be that the amount of data is very large.
>
>
> Right, I understand that. I wanted to find out what his reasons were for
> wanting a temp file. Those are valid reasons, but in the absence of such
> reasons, he's probably better off using a TACL variable.
>
Right. I tried not to say that using a variable was not right. It probably is better, assuming all the action is from a single TACL process and the amount of data is modest. But we don't know those conditions hold.
>
>>If the file is written in another program, and is not very large, then the
>>FILETOVAR command followed by an #EXTRACT loop probably is easier than using
>>#REQUESTER. If the file is large, then #REQUESTER probably is the best way.
>
>
> Again: he said he wants to write to it, then read it, in the TACL routine.
>
Maybe that is what he meant. We don't know for sure.
>
>>This probably doesn't apply, but just in case: Guardian has a special sort of
>>file called a temporary file, which is deleted immediately when it is closed.
>>That kind of file is not appropriate for passing data from one program to
>>another. It is useful only for temporarily holding data during the execution
>>of a program when the data is too large to keep all in memory. I don't know
>>whether one can create and use that kind of temporary file in TACL.
>
>
> Yes, you can:
> #CREATEFILE /FILENAMEV filevar/ $volume
> creates a Guardian temp file $volume.#nnnnnnn and returns that name in
> [filevar].
Thanks for the information. I had never tried to use a Guardian temporary file in TACL. I could imagine TACL checking the parameter and deciding $volume wasn't an acceptable form of filename for #CREATEFILE. From what you say, TACL does not restrict it.
The other point I was trying to make is, even if you can create a Guardian temporary file in TACL, I imagine you have to be careful how you use it to make sure that TACL opens it only once. For example, I expect you would not be able to use it in a VARTOFILE, then later in a FILETOVAR, since I imagine TACL would close it after the VARTOFILE, at which point it would disappear. I imagine using #REQUESTER would be safe, though I don't know that for sure.
My guess is that he did not actually mean Guardian temporary file when he wrote his question, but meant just an ordinary disk file that he would purge when he was done using it. But I wanted to point out the possible limitations if he really wanted to use a Guardian temporary file.
Not exactly right. TACL can open it multiple times, as long as some of the
opens are simultaneous. For example, the sequence (open, open, close, open,
close, close) should work just fine, but (open, close, open, close, open,
close) won't because the file will go away after the first close.
>For example, I expect you would not
> be able to use it in a VARTOFILE, then later in a FILETOVAR, since I imagine
> TACL would close it after the VARTOFILE, at which point it would disappear.
Correct.
> I imagine using #REQUESTER would be safe, though I don't know that for sure.
Yes, it would, at least until a #REQUESTER /CLOSE/ command reduces the number
of opens on the file to zero.