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

lozza1978 piresl at ...626...
Sat Jan 5 23:57:52 CET 2008


Hi there,

thanks for repling, and your example but, im new and dont really understand
your code, 
is there any chance that you could post an example with working code so that
i can understand?

what is going on here?
PRINT Scan("Pos:   0.1s      3f ( 100%)  0.00fps", "Pos: *s *f ( *%) *fps*") 
[2] 
ive checked out the scan command at  http://gambasdoc.org/help/lang/scan
gambas scan function  but cannot see how it will help as the 
PRINT Scan("Pos:   0.1s      3f ( 100%)  0.00fps", "Pos: *s *f ( *%) *fps*")
Pos:   0.1s      3f ( 100%)  0.00fps", "Pos: *s *f ( *%) *fps*") 

changes and I cannot predict the percentage. as shown in the file test88
test88 file:
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]
Pos:   0.2s      4f ( 0%)  0.00fps Trem:   0min   0mb  A-V:0.013 [0:0]
Pos:   0.2s      5f ( 0%)  0.00fps Trem:   0min   0mb  A-V:0.017 [0:0]
Pos:   0.2s      6f ( 0%)  0.00fps Trem:   0min   0mb  A-V:0.021 [0:0]
Pos:   0.3s      7f ( 0%)  0.00fps Trem:   0min   0mb  A-V:0.025 [0:0]
Pos:   0.3s      8f ( 0%)  0.00fps Trem:   0min   0mb  A-V:0.029 [0:0]
Pos:   0.4s      9f ( 0%)  0.00fps Trem:   0min   0mb  A-V:0.033 [0:0]
Pos:   0.4s     10f ( 0%)  0.00fps Trem:   0min   0mb  A-V:0.038 [0:0]

Am I reading to much into this? Its driving me mad, I know most programmers
do this?, as how else do they show a progress bar while installing a program
in windows for example..

I know I have a lot of reading and lessons to learn but I just love gambas
and the it works, well done guys. its genius

I have searched the universe for info and easy to follow examples but i get
lost! :-(


Fabien Bodard-4 wrote:
> 
> 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
> 
> 
> 
> -------------------------------------------------------------------------
> 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
> 

-- 
View this message in context: http://www.nabble.com/Grabbing-certain-data-from-a-stream%2C-help-a-newb-tp14638863p14640389.html
Sent from the gambas-user mailing list archive at Nabble.com.





More information about the User mailing list