gettingstarted
[Top] [All Lists]

Re: I don't get why this won't work

To: REALbasic Getting Started List <gettingstarted at lists dot realsoftware dot com>
Subject: Re: I don't get why this won't work
From: Paul Goodrich <lists at zonestation dot com>
Date: Thu, 28 Apr 2005 22:04:53 -0700
Delivered-to: gettingstarted at lists dot realsoftware dot com
on 4/28/05 5:34 PM, Brian Heibert wrote:

> On 4/27/05 11:05 PM, "Roger Meier" <roger dot meier at pobox dot com> wrote:
> 
>>>   Dim f as folderitem
>>>   Dim t as textinputstream
>>>   dim hp as string
>>>   f=preferencesfolder.child("InternetPal Settings")
>>>   if f <> Nil then
>>>     t = f.OpenAsTextFile
>>>     
>>>     settingsWIN.homepage.text= t.readline
>>>     hp = t.readline
>>>     settingsWIN.welcomespeech.text = t.readline
>>>     t.close
>>>   end if
>>>   SettingsWIN.close
>>>   
>>>   I am saving a file and it looks like the file gets saved
>>> Why won't this code above read the file?
> It doesn't put the text in the appropriate edit fields
> And doesn't load the saved homepage at startup
> Doesn't use the text I had saved to speak a string
> 
> Brian


Ok Brian, Look you have a variable called hp and you are reading a line into
this variable.  So you have two text fields, and a variable that are storing
info you read from the text file.

Ok but first you have this to write it:


>   Dim f as folderitem
>   Dim t as textoutputstream
>   f=preferencesfolder.child("InternetPal Settings")
>   if f <> Nil then
>     t = f.CreateTextFile
>     t.writeline settingsWIN.homepage.text
>     t.writeline settingsWIN.welcomespeech.text

Do you see this ^^^^^^ ? You write two lines but read three. So the hp
variable above is reading the welcomespeech.text that you saved.  And the
third .readline is reading what exactly?  According to what you wrote there
shouldn't be a third line.

Of course it is late and I may have gotten this all backwards because I am
typing from memory of my first program to use text files.

Have you tried opening the file in BBEdit or Texedit to see what it
contains?

-Paul



_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

<Prev in Thread] Current Thread [Next in Thread>