[Gambas-user] Grabbing certain data from a stream, help a newb

Fabien Bodard gambas.fr at ...626...
Sat Jan 5 22:00:48 CET 2008


Le Saturday 05 January 2008 21:43:05 lawrence pires, vous avez écrit :
> Hi All,
>
> I only recently found Gambas, but I got to say its amazing & addictive.
>
> This is what I have at the moment:
>
> EXEC [dvdmovie, Textbox1.Text] FOR READ AS "Contents"
>
> PUBLIC SUB Contents_Read()
>
> DIM hFile AS File
> DIM sLine AS String
>
>  READ #LAST, sLine, Lof(LAST)
>  sOutput &= sLine
>
> hFile = OPEN "/home/lop/Desktop/test88" FOR CREATE
> WRITE #hFile, sOutput, Len(sOutput)
> CLOSE #hFile
> END
>
> & this is stream written to test88
>
> VDec: vo config request - 616 x 252 (preferred colorspace: Planar YV12)
> VDec: using Planar YV12 as output csp (no 0)
> Movie-Aspect is 2.44:1 - prescaling to correct movie aspect.
> videocodec: libavcodec (720x576 fourcc=3267706d [mpg2])
> Pos:   0.0s      1f ( 0%)  0.00fps Trem:   0min   0mb  A-V:0.000 [0:0]
> Writing header...
> INITV: 0.200, 0.160, fps: 25.000
> Pos:   0.1s      2f ( 0%)  0.00fps Trem:   0min   0mb  A-V:0.004 [0:0]
> Pos:   0.1s      3f ( 0%)  0.00fps Trem:   0min   0mb  A-V:0.008 [0:0]
>
>
> the output from the shell is directed to the test88 file creating a new
> line every time.
>
> 'Pos:   0.1s      3f ( 0%)  0.00fps Trem:   0min   0mb  A-V:0.008 [0:0'
>
> Now I need to grab the percentage (0%) this will change as the exec command
> completes the process,
>
> The only command I can find close is Split, to spilt the string/stream, but
> this creates a massive array, so i dont think this is a good path to take,
> (What do you think?).
>

PRINT Scan("Pos:   0.1s      3f ( 100%)  0.00fps", "Pos: *s *f ( *%) *fps*")
[2]


> The reason why I want to grab the percentage is so that I can correctly
> setup the progress bar, Im thinking that the only way the progress bar will
> be correct in showing the progress of the exec command is to grab the
> percentage of completion from the stream, somehow convert the string into
> an integer and then do something like this
>
> ProgressBar1.Visible = TRUE
> ProgressBar1.Value += PERCENTAGE FROM STREAM
> ProgressBar1.Refresh
>
>
> ***The only reason im writing to file atm is so that I can debug, I would
> like to do this on the fly really.
>
>
> Has anyone got any ideas or tips?, how would you do it?, Am I going in the
> right direction?, im totally lost at spitting the stream, getting the right
> bit and then changing a string to an integer so I can use it for the
> progress bar? any help would be amazing
>
> Thanks 2 Gamabs

Really easy :
Dim aString as String[]
Dim fTime, fFps, fProgress  as Float


aString =  Scan(sMyString, "Pos: *s *f ( *%) *fps*")

fTime = CFloat(aString[0])
fProgress = CFloat(aString[2])
fFtp = CFloat(aString[3])
ProgressBar1.Visible = TRUE
ProgressBar1.Value = fProgress / 100


> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2005.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user






More information about the User mailing list