[Gambas-user] Write to file is adding strange characters
lozza1978
piresl at ...626...
Wed Dec 26 22:09:46 CET 2007
I would like to thank you all for the explanations it has cleared up why i
was adding the length of the string to the Write command. in future i will
be using print instead of Write as write is for binary.
Anyway, Here is a pic of my DVD converter / recorder Project..(Still early
days)
At the moment it converts avi/mpg files ready for dvd then works out movie
length and creates chapters, creates TOC and then you can burn the movie..
its a quick and easy way to create DVD'S (Any Comments?)
http://www.nabble.com/file/p14506463/snapshot8.png
nando-7 wrote:
>
> When you use the WRITE statement, there are two ways to use it:
> 1) WRITE #hFile, test
> 2) WRITE #hFile, test, LEN(test)
>
> Explanation...
>
> 1) Gambas adds the length of the string as part of the written data.
> This one will cause you problems because it adds lenght automatically.
> 2) Gambas adds nothing and writes only the quantity of bytes
> specified by LEN(test) WITHOUT adding anything else to the file.
>
> Use 2) by adding ,LEN(string var) and the file will be as you expect.
>
> -Fernando
>
>
> ---------- Original Message -----------
> From: Benoit Minisini <gambas at ...1...>
> To: mailing list for gambas users <gambas-user at lists.sourceforge.net>
> Sent: Wed, 26 Dec 2007 20:32:28 +0100
> Subject: Re: [Gambas-user] Write to file is adding strange characters
>
>> On mardi 25 décembre 2007, lawrence pires wrote:
>> > Im trying to automate the writing of a dvd.xml file.
>> >
>> > Im trying to create and write the following text into a file:
>> >
>> > <dvdauthor> <vmgm /> <titleset> <titles> <pgc>
>> > <vob file="your_video.mpg" chapters="0,0:20,0:30,0:40,0:50,0:60" />
>> > </pgc> </titles> </titleset></dvdauthor>
>> >
>> >
>> > Heres the code im using:
>> >
>> > PUBLIC SUB Button2_Click()
>> > DIM hFile AS File
>> > DIM test AS String
>> > DIM test1 AS String
>> > DIM test3 AS String
>> >
>> > test = "<dvdauthor> \n<vmgm /> \n<titleset>\n<titles>\n<pgc>\n"
>> > test1 = "<vob" "file=\"your_video.mpg\""
>> > "chapters=\"0,0:20,0:30,0:40,0:50,0:60\"" "/>"
>> > test3 = "\n</pgc>\n</titles>\n</titleset>\n</dvdauthor>"
>> >
>> > hFile = OPEN "/home/don/Desktop/dvd" FOR CREATE
>> >
>> > WRITE #hFile, test
>> > WRITE #hFile, test1
>> > WRITE #hFile, test3
>> > FLUSH #hFile
>> > CLOSE #hFile
>> > END
>> >
>> > And this is the contents after the above has been executed:
>> >
>> > 1<dvdauthor>
>> > <vmgm />
>> > <titleset>
>> > <titles>
>> > <pgc>
>> > @<vobfile="your_video.mpg"chapters="0,0:20,0:30,0:40,0:50,0:60"/>*
>> > </pgc>
>> > </titles>
>> > </titleset>
>> > </dvdauthor>
>> >
>> >
>> > As you can see is writing strange characters to the dvd.xml file.
>> >
>> >
>> > can anyone please help me?
>> >
>> > Kind regards & Happy Christmas
>>
>> WRITE is for writing binary data. Use PRINT to write text data.
>>
>> Regards,
>>
>> --
>> Benoit Minisini
>>
>> -------------------------------------------------------------------------
>> 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
> ------- End of Original Message -------
>
>
> -------------------------------------------------------------------------
> 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/Write-to-file-is-adding-strange-characters-tp14494615p14506463.html
Sent from the gambas-user mailing list archive at Nabble.com.
More information about the User
mailing list