New topic: 

Append Text Function

<http://forums.realsoftware.com/viewtopic.php?t=30497>

       Page 1 of 1
   [ 2 posts ]                 Previous topic | Next topic         Author  
Message       Rivo           Post subject: Append Text FunctionPosted: Thu Oct 
15, 2009 12:44 pm                               
Joined: Tue Aug 29, 2006 4:04 am
Posts: 259
Location: Indonesia              Hi,
I've use this code below to load text file onto dropdownlist item.

Code:dim tis as TextInputStream
dim G as string
f = new FolderItem( "winelist.txt" )
if f <> nil and f.Exists then
  tis = f.OpenAsTextFile
  if tis <> nil then
  while not tis.EOF
  G=tis.ReadLine
  cWine.AddRow(nthfield(G,",",1 ))
  cHarga.AddRow(nthfield(G,",",2 ))
  cType.AddRow(nthfield(G,",",3 ))
  cYear.AddRow(nthfield(G,",",4 ))
  wend
  end if
end if

Now, I have a problem to do updating the winelist file time to time.
I just wondering if there any ways to add an option like "If the item is not on 
the list then append it to the winelist.txt file, then refresh the dropdownlist 
item".

I've use method to call the file, in dropdownlist_Change

Code:cPrice.ListIndex=cWine.ListIndex
cType.ListIndex=cWine.ListIndex
cYear.ListIndex=cWine.ListIndex
Dim s, total as Integer
For s=0 to cWine.ListCount-1
  sWine.caption=str (cWine.ListCount)+" wines"
next
xAdd.Enabled=true


The result is, if the item is not on the list, then cPrice,cType and cYear goes 
blank. 
My question is, how to compare dropdownlist.text with the item on winelist.txt 
file.


sorry for my poor english

Regards,
Rivo   
                            Top               Phil M           Post subject: 
Re: Append Text FunctionPosted: Fri Oct 16, 2009 2:19 am                        
Joined: Fri Sep 30, 2005 12:18 pm
Posts: 108              Rivo wrote:The result is, if the item is not on the 
list, then cPrice,cType and cYear goes blank.  My question is, how to compare 
dropdownlist.text with the item on winelist.txt file.

In most cases, all of the data that you display for the user is stored in 
memory until there is a reason to save the data to the disk.  Once you 
initially read the data from your text file, (unless the user wants to revert 
to the saved version) you do not need to read from it again while its loaded.  
Instead you just convert the data from the text file into memory that you use 
in your application.  Only when the user is finished or wants to save do you 
typically touch the text file again, and then its usually only to save the 
data.  Most applications -- instead of parsing the data file again and making 
changes to what needs to be changed, will just write the entire file all over 
again.

One thing to consider... it sounds to me like the data you are working with 
would be good to store into a REALSQLdatabase instead of a text file.  This 
would require more work to learn how to use databases, but if your 
application's users are adding or removing a lot of items from the wine list it 
might make things easier for you in the long run including the ability to make 
searches, sorts, etc.   
                            Top           Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 1
   [ 2 posts ]     
-- 
Over 1500 classes with 29000 functions in one REALbasic plug-in collection. 
The Monkeybread Software Realbasic Plugin v9.3. 
http://www.monkeybreadsoftware.de/realbasic/plugins.shtml

[email protected]

Reply via email to