Posted: 24th Jun 2007 22:10
Hi, all! =) I'm having a bit of a problem with reading / writing to an FLV file, if anybody would be kind enough to help me fix this code, that'd be GREATLY appreciated! =)

Anyways, here is the code:

+ Code Snippet
sync on : sync rate 0 : hide mouse

gosub _readtoend

_readtoend:
 cls
 open to read 1,"My_FlashFile.flv"
 if file open(1)=1
  c=0
  while file end(1)=0
  B = asc(A$)
   read byte 1,B
   print ">";B
   if file exist("MyFlashFile_Data.txt")=1 then delete file "MyFlashFile_Data.txt"
    open to write 2, "MyFlashFile_Data.txt"
      write string 2, chr$(B)
    inc c
   sync
  endwhile
   close file 2
  close file 1
 endif
`wait key
return


Thanks ALOT, to whoever helps me! =)

~M.W~
Posted: 24th Jun 2007 22:16
Whats a FLV file?
Posted: 24th Jun 2007 22:24
What's a FLV file?


Hello, Sasuke! =)

Here is a description of an FLV file:

+ Code Snippet
An FLV is a Flash-compatible video file exported by the Flash Video Exporter plug-in (included with Macromedia Flash MX) or other program with FLV file support; consists of a short header, interleaved audio, video, and metadata packets; the audio and video data is stored in a similar format to the standard Flash (.SWF) format.


Hope that helps! =)

And thanks again to whoever helps me! =)

~M.W~
Posted: 25th Jun 2007 0:10
What problems are you having exactly? I'd imagine writing a whole flash file would take quite a while when reading it byte by byte an saving each byte as a string depending on the size.
Posted: 25th Jun 2007 0:35
For a start you are checking if the output file exists after reading every byte of the file, then deleting it. The file would never be more than 1 byte big in the end.
Secondly, you are opening up the output file every loop too but not closing it until the loop has finished. I would expect this would cause major problems.
Thirdly, you call the gosub and return from it, but I am pretty sure it will then carry on and run the code again. You need an 'end' command before it does this.
Forthly, I have no idea what you are trying to do by converting each byte to its character value but I am sure you have a good reason

It should probably be something more like this (although I haven't tried it):
+ Code Snippet
sync on : sync rate 0 : hide mouse

gosub _readtoend
end

_readtoend:
 cls
 open to read 1,"My_FlashFile.flv"
 if file open(1)=1
  if file exist("MyFlashFile_Data.txt")=1 then delete file "MyFlashFile_Data.txt"
  open to write 2, "MyFlashFile_Data.txt"
  c=0
  while file end(1)=0
   B = asc(A$) ` not sure what line is for???
   read byte 1,B
   print ">";B
   write string 2, chr$(B)
   inc c
   sync
  endwhile
  close file 2
  close file 1
 endif
`wait key
return