Convert simple text into Unicode?

Please use this Board for QBasic related requests ( file research, programming, etc.)

Moderators:Administrator, Global Moderator

Post Reply
Guest
Convert simple text into Unicode?

Post by Guest » Thu Feb 19, 2004 12:59 am

Hi
A quick question: How can I convert a simple Text from QBasic into Unicode and safe it in a file?

Thanks
FatalError

User avatar
yacinator
Full Member
Posts:33
Joined:Sun Dec 21, 2003 12:02 am

Re: Convert simple text into Unicode?

Post by yacinator » Thu Feb 19, 2004 2:35 am

if u mean to convert .txt format text to unicode (by that i  assume u mean uncoded text, on my computer unicode extonsion is TXT it might be diffrent on yours) then it's really simple.
u open the file for output and then u open a new file for
input and save it in there. u do it like this:

Code: Select all

OPEN "file1.TXT" FOR INPUT AS 1
INPUT#1,var$
CLOSE#1 
that opens the file and then this writes it to a new file:

Code: Select all

OPEN "file2.TXT" FOR OUTPUT AS 2
WRITE#2,var$
CLOSE#2
i think that should do the trick  ;)

Guest

Re: Convert simple text into Unicode?

Post by Guest » Thu Feb 19, 2004 3:03 pm

Yes, it runs!
But now I have a new problem:
Any Line in the file begins and ends with a >"<
What can I do against this?

User avatar
yacinator
Full Member
Posts:33
Joined:Sun Dec 21, 2003 12:02 am

Re: Convert simple text into Unicode?

Post by yacinator » Sat Feb 21, 2004 10:30 am

well u can't remove the >"<'s from the file but you can display the file withuout them. u do something like this

let var2$=mid$(var1$,3,varLEN) 'var1=file varLEN=last character of the file

;) &nbsp;

Dr_Davenstein
QBasic God
Posts:166
Joined:Tue Mar 25, 2003 12:45 am
Location:U.S.A.
Contact:

Here it is guys...

Post by Dr_Davenstein » Sat Feb 21, 2004 10:59 am

Code: Select all

CLS

A$ = "Dr_Davenstein Rules!"
FileNumber = FREEFILE

OPEN "Myfile.myf" FOR OUTPUT AS FileNumber
 PRINT #FileNumber, A$
CLOSE FileNumber



OPEN "Myfile.myf" FOR INPUT AS FileNumber
 INPUT #FileNumber, B$
CLOSE FileNumber

PRINT B$

KILL "MyFile.Myf"

...And here is a screenshot of my latest QB game,Pacenstein! It might take a second to download.
Image

http://www.QBNZ.com/dr_davenstein/Pacenstein.zip
Come check out [url=http://www.freebasic.net/forum/index.php]FreeBASIC[/url]. The syntax is based on QuickBasic, but it expands to use pointers, operator overloading, etc... The list goes on and on!

Post Reply