How to create a pop-up menu from a list of files in a folder?

Klaus Major klaus at major-k.de
Sun Aug 3 06:53:00 EDT 2003


Bonjour François,

ca va bien? :-)

> Hello everybody!
> Fine today?
> I want to create a popup menu with all the users of my application.
> All the settings for this users are in separate files (.edb) (one for 
> each
> user) in a folder (Users).
> Where may I find how to do that?

if i understand you correctly you have the names of your users in theat 
menu a la:

(See the P.S. below ;-)

John Doe
Jane Doe
Jim Bo
...

And you need a script that will read in the prefs-file for that user?

Then try this in the script of that menu-button:

on menupick quoi
    ### "quoi" will now hold the selected name of your user

   put url("file:Users/" & quoi & ".edb") into my_userprefs
   ## will put the appropriate file into the var "my_userprefs"
   ## after creatin gthe string the engine will see somthing like:
   ## put url"file:Users/John Doe.edb" and will read in the correct 
file...

   ## do your prefs-stuff here
end menupick

Hope that helps...

> Or maybe one of the nice members of our list?:-)
> Thank you

De rien... :-)

> Friendly
> François

Regards

Klaus Major
klaus at major-k.de
www.major-k.de


P.S.
Sorry, its definitively tooooo hot (33 C° here in germany, mon dieu...)
I read the subject and i think my hint was not the correct one for your 
problem... :-(

But here is how to do THAT ;-)

on xxx
   ## maybe openstack, opencard or preopen...

   put the directory into olddir
   ## always a good idea to store the current folder and
   ## RE-store it afterwards... ;-)

   set the directory to "Users"
   put the files into foo
   repeat for each line l in foo
      if char -4 to -1 of foo = ".edb" then    ## valid user prefs-files
          put char 1 to -5 of foo & CR after foo_too
      end if
   end repeat
   ## will create a list of all the "valid" filenames in the folder 
without
  ### the suffix .edb

   delete char -1 of foo_too
   ## get rid of last CR

  put foo_too into btn "name of menubutton here"
  ## now fill the menu-button (its just text ;-)

  set the directory to olddir
  ## restore old directoy
end xxx


NOW you can use my first script :-)

Have a lazy sunday and don't move unecessarily ;-)




More information about the use-livecode mailing list