realbasic-nug
[Top] [All Lists]

Re: Adding Menu Items From Text File

To: "REALbasic NUG" <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: Adding Menu Items From Text File
From: "Dennis Birch" <dsbirch at qwest dot net>
Date: Wed, 30 Jun 2004 19:11:38 -0700
Delivered-to: realbasic-nug at lists dot realsoftware dot com
List-help: <mailto:realbasic-nug-request@lists.realsoftware.com?subject=help>
List-id: REALbasic NUG <realbasic-nug.lists.realsoftware.com>
List-post: <mailto:realbasic-nug@lists.realsoftware.com>
References: <BD08D91C dot 3189%maury at mccowns dot us>
At 8:54 PM -0500 6/30/04, Maury McCown wrote:
Hey all

Time for another embarrassing question about something I should already know
how to do: generate a menu containing a list from a data file.

I have a text file with a list of city names, and when the app starts, I
want to load the list of names into my Locations menu item. However, all I
can get it to do is load the last item in the list - and I've tried all
kinds of stuff to try and get this to work, but I can't. =(

Here's my code (c is dimmed as new MenuItem):

  File = blablabla....
  input = file.OpenAsTextFile

  do until input.EOF
    c.Text = input.ReadLine
    MenuBar1.Child("LocationsMenu").Insert(0,c)
  Loop

  input.Close

All this does is list the last item in the file for each instance of an
item.

Any help would be appreciated!

I just tried the following in the Open event of a test application, with success. It ought to get you back on track:

  dim i, u As Integer
  dim item As MenuItem
  dim menu As MenuItem
  const s = "Arizona, California, Montana, Colorado, Utah, Idaho, Washington"

  menu = MenuBar1.Child("LocationsMenu")
  u = CountFields(s, ",")
  for i  = 1 to u
    item = new MenuItem
    item.Text = NthField(s, ",", i)
    menu.Append Item
  Next
_______________________________________________
Unsubscribe or switch delivery mode:
<http://support.realsoftware.com/listmanager/>

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

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