gettingstarted
[Top] [All Lists]

Re: Reading in text from a file into a ListBox with 2 columns

To: Getting Started <gettingstarted at lists dot realsoftware dot com>
Subject: Re: Reading in text from a file into a ListBox with 2 columns
From: Paul Young <youngpr at myactv dot net>
Date: Sat, 29 Jan 2005 17:11:55 -0500
Delivered-to: gettingstarted at lists dot realsoftware dot com
References: <BE21605F dot 1A0BC%pheycock at bellsouth dot net>
Phil,

Nice coding.  Thanks.  Can you improve on my code to save the info per:

  dim f as FolderItem
  dim t as TextOutputStream
  dim s as String
  dim cr as String
  dim n as Integer
  cr=Chr(13)+Chr(10)
  f=PreferencesFolder.Child("filename.plist")
  t=f.CreateTextFile
  For n=0 to Players.ListBox1.ListCount-1
    s=Players.ListBox1.Cell(n,0)+","+Players.ListBox1.Cell(n,1)+cr
    t.Write s
  next n
  t.close

Paul

On Jan 29, 2005, at 3:46 PM, Phil Heycock wrote:

   dim f as FolderItem
   dim t as TextInputStream
   dim s as String
   f=PreferencesFolder.child("filename.plist")
   t=f.OpenAsTextFile
   while not t.eof
    s = t.ReadLine
    ListBox1.AddRow NthField(s, ",",1)
    ListBox1.Cell(ListBox1.LastIndex, 1) = NthField(s, ",", 2)
   Wend
   t.close

P.
*********************

on 1/29/05 12:16 PM, Paul Young at youngpr at myactv dot net wrote:

I'm a new RB 5.5.4 programmer using Mac OS 10.3.7.

I'm trying to read a simple text file into a ListBox with two columns.
The text file has two lines; name1,score1 and name2,score2.

The following Method code fills the first column cells properly but I
cannot get the second column to fill properly:

 dim f as FolderItem
 dim t as TextInputStream
 dim s as String
 dim Name as String
 dim Score as String
 dim Comma as Integer
 f=PreferencesFolder.child("filename.plist")
 t=f.OpenAsTextFile
 while not t.eof
   s=t.ReadLine
   Comma=Instr(s,",")
   Name=Left(s,Comma-1)
   Score=Mid(s,Comma+1)
   Players.ListBox1.InsertRow 1,Name 'this puts the name in the first
row, column 1 as desired
   Players.ListBox1.Cell(0,1)=Score 'this puts score2 in the first
row, column 2; nothing is put in row 2 column 2
 wend
 t.close

When I delete the second row in the text file, both row 1 cells are
filled correctly.  Score2 is writing over Score1.

What am I doing wrong?

Thanks for the assistance.

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

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


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

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

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