Please help Visual Basic Programer with simple read/write text file routine---Real Basic 2.1 
Author Message
 Please help Visual Basic Programer with simple read/write text file routine---Real Basic 2.1

HELP
I've been programming in VB for about 10 years and am interested in
RealBasic. All i want to do is create a file, write some values and close
the file. Thats no problem but
when i go to read the file, the OPEN file dialog pops up and does not show
one file anywhere in any file. Even the tutorial files do this. Any way, my
window as 2 buttons
READ and WRITE. WRITE writes data from 4 different text boxes to any place
you want. READ is supposed to open the file, and read each line into a
listbox.
here is my code
-----write stuff
Sub Action ()
Dim file as FolderItem
dim filestream as TextOutputStream
file=GetSaveFolderItem("djjj","Untitled")
fileStream=file.CreateTextFile
file.MacCreator="djjj"
file.mactype="djjj"
filestream.Writeline EditField1.text
filestream.Writeline EditField2.text
filestream.Writeline EditField3.text
filestream.Writeline EditField4.text
filestream.close
end if
End Sub

-----Read Stuff into listbox
Sub Action()
dim f as FolderItem
Dim stream as TextInputStream
f=GetOpenFolderItem ("djjj/djjj")
EditField1.text="Empty"
EditField2.text="Empty"
EditField3.text="Empty"
EditField4.text="Empty"
if f<>nil then
stream=f.openastextfile
while not stream.eof
listbox1.addrow stream.readline
wend
stream.close
end if
End Sub

My system is as follows:
AMD 1000Mhz, 768 MB RAM running Windows 2000, I run REALbasic in an emulator
called Basilisk II. Basilisk is set up to emulate a Quadra 950 with a 68040
CPU with 384 MB RAM. It only runs 68k code and i wish to develope
Windows/Mac programs. My "hello world" test worked with no problems. I
wanted to write DB stuff, but had problems so i decided i would try
something easier like binary files, but had problems so now i'm trying text
files and still having problems. If someone could just test my code and tell
me if it works or not on their machine i would greatly appreciate it. I just
don't want to keep chasing this problem if the MacOS emulator is causing it.

Thanks for all your time and i think RB is a great program, even if i am
having problems.

David



Thu, 19 Feb 2004 12:29:40 GMT  
 Please help Visual Basic Programer with simple read/write text file routine---Real Basic 2.1

Quote:

> HELP
> I've been programming in VB for about 10 years and am interested in
> RealBasic. All i want to do is create a file, write some values and close
> the file. Thats no problem but
> when i go to read the file, the OPEN file dialog pops up and does not show
> one file anywhere in any file. Even the tutorial files do this. Any way, my
> window as 2 buttons
> READ and WRITE. WRITE writes data from 4 different text boxes to any place
> you want. READ is supposed to open the file, and read each line into a
> listbox.
> here is my code
[..]
> -----Read Stuff into listbox
> Sub Action()
> dim f as FolderItem
> Dim stream as TextInputStream
> f=GetOpenFolderItem ("djjj/djjj")

It looks and sounds like you need to set up a valid file type. What's a
djjj/djjj?

Under Edit->File Types set up a file type, and call it 'text' (any name
will do; text is easy to remember). Give it a MacCreator of ???? (four
question marks) and a MacType of TEXT (all caps). Then call:

f = GetOpenFolderItem("text")

You can let the user open any file by making a file type with MacCreator
and MacType of ????.

The MacType is a four-character code that's roughly equivalent to the
.ext of a Windows file name. The MacCreator is a four-character code
that's unique to the app that made the file. GetOpenFolderItem doesn't
take the MacType and MacCreator directly; you have to make a file type
and then specify *that.*

Quote:
> My system is as follows:
> AMD 1000Mhz, 768 MB RAM running Windows 2000, I run REALbasic in an emulator
> called Basilisk II. Basilisk is set up to emulate a Quadra 950 with a 68040
> CPU with 384 MB RAM. It only runs 68k code and i wish to develope
> Windows/Mac programs.

Heh. REALbasic on Windows. You can compile for windows and two flavors
of Mac, all from your emulated 68k machine. Spiff.

Quote:
> My "hello world" test worked with no problems. I
> wanted to write DB stuff, but had problems so i decided i would try
> something easier like binary files, but had problems so now i'm trying text
> files and still having problems. If someone could just test my code and tell
> me if it works or not on their machine i would greatly appreciate it. I just
> don't want to keep chasing this problem if the MacOS emulator is causing it.

I'd wager it's the file type, instead of the

--
"In a world full of lies/That tug at the truth
 I'm taking no sides/Now I recognize you.." --DS



Thu, 19 Feb 2004 14:59:49 GMT  
 Please help Visual Basic Programer with simple read/write text file routine---Real Basic 2.1
Thanks alot!!! That did it. Although i am having trouble getting a database
going, this helps alot. I was messing around with the file types but i just
had the wrong settings.
Dave


Quote:

> > HELP
> > I've been programming in VB for about 10 years and am interested in
> > RealBasic. All i want to do is create a file, write some values and
close
> > the file. Thats no problem but
> > when i go to read the file, the OPEN file dialog pops up and does not
show
> > one file anywhere in any file. Even the tutorial files do this. Any way,
my
> > window as 2 buttons
> > READ and WRITE. WRITE writes data from 4 different text boxes to any
place
> > you want. READ is supposed to open the file, and read each line into a
> > listbox.
> > here is my code
> [..]
> > -----Read Stuff into listbox
> > Sub Action()
> > dim f as FolderItem
> > Dim stream as TextInputStream
> > f=GetOpenFolderItem ("djjj/djjj")

> It looks and sounds like you need to set up a valid file type. What's a
> djjj/djjj?

> Under Edit->File Types set up a file type, and call it 'text' (any name
> will do; text is easy to remember). Give it a MacCreator of ???? (four
> question marks) and a MacType of TEXT (all caps). Then call:

> f = GetOpenFolderItem("text")

> You can let the user open any file by making a file type with MacCreator
> and MacType of ????.

> The MacType is a four-character code that's roughly equivalent to the
> .ext of a Windows file name. The MacCreator is a four-character code
> that's unique to the app that made the file. GetOpenFolderItem doesn't
> take the MacType and MacCreator directly; you have to make a file type
> and then specify *that.*

> > My system is as follows:
> > AMD 1000Mhz, 768 MB RAM running Windows 2000, I run REALbasic in an
emulator
> > called Basilisk II. Basilisk is set up to emulate a Quadra 950 with a
68040
> > CPU with 384 MB RAM. It only runs 68k code and i wish to develope
> > Windows/Mac programs.

> Heh. REALbasic on Windows. You can compile for windows and two flavors
> of Mac, all from your emulated 68k machine. Spiff.

> > My "hello world" test worked with no problems. I
> > wanted to write DB stuff, but had problems so i decided i would try
> > something easier like binary files, but had problems so now i'm trying
text
> > files and still having problems. If someone could just test my code and
tell
> > me if it works or not on their machine i would greatly appreciate it. I
just
> > don't want to keep chasing this problem if the MacOS emulator is causing
it.

> I'd wager it's the file type, instead of the

> --
> "In a world full of lies/That tug at the truth
>  I'm taking no sides/Now I recognize you.." --DS



Fri, 20 Feb 2004 04:53:13 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Help on Reading & Writing to Text File

2. Q: simple example of read file->convert char(s)->write file needed

3. How to read a text file - please help

4. please help with lindex reading from text file

5. Simple directory copy routine - need help please

6. Reading large text files with Real basic

7. Reading fortran text files / Parsing ascii files/ Help!!

8. chmod advice please writing to text files

9. Reading a DOS text file and writing out Mac

10. fortran program reading an external text (and numbers) file and writing with edits

11. Reading and then Writing to a file - small newbie question - please

12. Read/Write text to a File

 

 
Powered by phpBB® Forum Software