[Gambas-user] SHELL is more faster than SUB Process_Read()

Demosthenes Koptsis demosthenesk at ...626...
Mon Aug 16 07:52:52 CEST 2010


ok , i got it.

Thanks both of u!

2010/8/15 Benoît Minisini <gambas at ...1...>

> > Hi i wrote a test program that "ls -1" a directory with 1700 and more
> files
> > (mp3).
> >
> > i wanted to make a string as following
> >
> >   Content = "/mnt/store/MUSIC/free/new age/webradio recs/Trancemission.FM
> > Radio 128K- New Age 2- new experience of meditation and new age music -
> > livestream 128k/" & sLine
> >
> > in order to list with full path the files.
> >
> > but i dont get the wanted result.
> >
> >
> > The SHELL command runs faster than Process_Read.
> >
> > This mess up the result of concatenation.
> >
> > The code is the following:
> >
> >
> ---------------------------------------------------------------------------
> > ----- ' Gambas class file
> >
> > PUBLIC SUB Button1_Click()
> >   SHELL "ls -1 \'/mnt/store/MUSIC/free/new age/webradio
> > recs/Trancemission.FM Radio 128K- New Age 2- new experience of meditation
> > and new age music - livestream 128k/\'" FOR READ
> >
> > END
> >
> > PUBLIC SUB Process_Read()
> >
> >   DIM sLine AS String
> >   DIM Content AS String
> >
> > '  IF Eof(LAST) THEN RETURN
> >
> >   READ #LAST, sLine
>
> That line is not correct, because you are reading the string from the
> stream
> in the internal Gambas format (length stored in one, two or four bytes,
> followed by the string contents), whereas the process just send characters
> on
> its standard output. See the documentation on READ for more details.
>
> You must do that to read the standard output of a process:
>
> PRIVATE $sBuffer AS String
>
> PUBLIC SUB Process_Read()
>
>  READ #LAST, sData, Lof(#LAST)
>  $sBuffer &= sData
>
>  DO
>    iPos = Instr($sBuffer, "\n")
>    IF iPos = 0 THEN BREAK
>    sLine = Left($sBuffer, iPos - 1)
>    $sBuffer = Mid$($sBuffer, iPos + 1)
>
>    ' Do what you need with sLine
>
>  LOOP
>
> END
>
> Regards,
>
> --
> Benoît Minisini
>
>
> ------------------------------------------------------------------------------
> This SF.net email is sponsored by
>
> Make an app they can't live without
> Enter the BlackBerry Developer Challenge
> http://p.sf.net/sfu/RIM-dev2dev
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>



-- 

Γεια χαρα σε όλους!!!

Regards,

Demosthenes Koptsis



More information about the User mailing list