USER (was Re: exists or similar command to work like grep on file system files)

Bruce Easton bruce at stn.com
Thu Feb 13 17:13:42 PST 2014


On 2/13/14 4:33 PM, Kenneth Brody wrote:
> On 2/13/2014 3:52 PM, Bruce Easton wrote:
>> On 2/13/14 3:30 PM, Kenneth Brody wrote:
> [...]
>>>        while read name
>>>        do
>>>            # The "real work" goes here.
>>>        done
>>>
>> Ken, that technique for the script worked fine for me for one iteration
>> from the processing table.  I don't know if it's that, in my example, I
>> was repeating the call within @menu or something else, but when I tried
>> repeating the "call" to the user program by start back at @menu (or even
>> just below the user command), it would fail on the first repetition
>> (using a while loop like you show here).
>
> What do you mean by "fail"?
In the debugger, clerk would just hang with no error - as if waiting for 
more input.
>
>>  By a lucky guess, removing the
>> while loop in the script to simply be:
>>
>> read pattern
>> ls -1
>>
>> and putting a "close [userprogname]" before cycling around to @menu
>>
>> enabled it to work repetitively.  It was the first time I've tried a
>> close for the user command label.
>
> You could also do it "the right way" :-) with:
>
>     while read pattern
>     do
>         ls -1
>         echo "**END**"
>     done
>
> (You need some way for your processing to know that it reached the end 
> of the output list.  Hence the echo.)

Yes that was the problem. The online manual page for this does have a 
warning at the bottom about looping till EOF, although not how to test 
EOF.  There is a line in the middle of that page that states "To test 
for an end-of-file or program termination, put the user program name on 
the condition line."  which is how I was trying to test for EOF in 
processing (and that didn't work without the close [userprogramname]).
>
>> The only other times I've used the user command was on Unix using the
>> method you described, but I know for certain those instances were not
>> part of @menu. These recent tests have been on 5.0.14 on RH Linux.
>
> Putting it in @MENU should have no effect on how it works.
>




More information about the Filepro-list mailing list