[Gambas-user] auto detect pipe |

Bruce Steers bsteers4 at gmail.com
Wed Nov 1 15:44:43 CET 2023


Thanks Bruce/Jussi

I think i am getting somewhere.
i now use a Wait 0.1 in Sub Main()
this allows Application_Read() to happen before moving on, then in
Application_Read() i set a string value.

then in Main() if the string value has been set then i use it

Problem was without using Wait 0.1 the Main() sub would run to the end
before Application_Read() happened

Respects
BruceS


On Wed, 1 Nov 2023 at 13:39, Jussi Lahtinen <jussi.lahtinen at gmail.com>
wrote:

> No time to think, but I guess "if (isatty(STDIN_FILENO))" would work when
> translated into Gambas. However, my gut feeling is that you are doing
> something in non-standard way.
> IE there should be another approach for the desired end result. Why do you
> need this?
>
>
> Jussi
>
>
> On Wed, Nov 1, 2023 at 2:36 PM Bruce Steers <bsteers4 at gmail.com> wrote:
>
>> i have made a command that supports piping using Application_Read()
>>
>> Static Public Sub Application_Read()
>>
>>   $bReading = True
>>
>>   While Lof(Last)
>>     $aArgs[0] = Last.ReadLine()
>>     ProcessString()
>>     If Not Eof(Last) And If Not $bNewLine Then Print ""
>>   Wend
>>
>>   $bReading = False
>>
>> End
>>
>> it works but i have added an arg -p that if i use -p then the pipe is
>> read.
>> Eg.
>> echo "This text" | mycommand -p
>>
>> can i detect if a pipe is to be used or not automatically?
>>
>> Respects
>> BruceS
>>
>>
>> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
>>
>
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20231101/2ab734d4/attachment.htm>


More information about the User mailing list