Argh! Programming help needed!

Trip

Registered
Simple REALbasic code for a program i'm trying to put together. The setup (in a nutshell) is as follows: I have a listbox that is suppost to load data into each column it has from a text file located in the preferences folder. But for some odd reason it's giving me an error. Take a look:


dim file as folderitem
dim filestream as TextInputStream
dim data as string
dim i as integer

file = PreferencesFolder.child("TEST Data")

if file <> nil then
filestream = file.openastextfile

While Not filestream.EOF «Unhandled NilObjectException Raised

data = filestream.ReadLine
ListBox1.addrow ""
i = ListBox1.LastIndex

ListBox1.cell(i, 0) = nthField(data, Chr(9), 1)


ListBox1.cell(i, 1) = nthField(data, Chr(9), 2)

Wend
end if
filestream.close
end if


Why is it giving me that? I really don't see where i've gone wrong!!! Can somebody comment on this or tell me how i can find out? Thanks! :)
 
I assume that file.openastextfile returns NIL which is why you get the NilObjectException.

Might be a permission problem, ie. PreferencesFolder.child("TEST Data") might return a valid file name but you might not be allowed to open it. Might be that file.openastextfile tries to open the file for writing. Since your intention is just to read the file, take care that you open the file on read-only mode.

I'm not a REALbasic expert but I assume you can apply a mode to the openastextfile method or use a different method for this purpose.

Anyway, you should check the return value of file.openastextfile as well.
 
I'd like to, really, but i don't have any developer tools and last time i tried working with cocoa it took me a year to get a simple degree changer application done. Plus it's abilities are very limited in my eyes (would take over 10 years to get something good done).
 
hmm...

well actually i found it easier to build GUI apps with interface builder.

and the cocoa api, is easy to use.

and well everyone knows how easy Java is.
 
to get the general idea, RB is ok

i personaly find that the only downside of the dev tools is that they dont have those little drop down lists to help you out.

but, they are free. I find that to me and alot of other people (ask apple :)) the dev tools and obj-c cocoa APIs are really easy to use and once you get the idea of how they interact, RB will seem really underpowered.

but then again, it is only OS X 10.1 carbon code.
 
Back
Top