popup items from ini file

Discussion in 'MATLAB' started by Jason, Mar 8, 2008.

  1. Jason

    Jason Guest

    Is it possible to populate the strings in a popup menu from
    an ini (text file).

    The number of items will increas eovertime and rather than
    going into the code, it would be really useful to have some
    config file.
    Jason, Mar 8, 2008
    1. Advertisements

  2. A .m file is just an ini file with an unusual name
    and a very flexible initialization syntax. But you do
    not have to use the full power of the initialization syntax;
    you could, for example, have

    set(m17_file_SaveAs_handle,'String','Save As')

    Or you could have in your ini file

    m17_file_SaveAs_string = 'Save As';

    and then in your code after you had processed the ini file you
    could have


    If these were perhaps not what you had in mind, it might
    help to be more specific about the format you were thinking of.
    Walter Roberson, Mar 9, 2008
    1. Advertisements

  3. Jason

    Jason Guest

    -cnrc.gc.ca (Walter Roberson) wrote in
    thinking of.

    I was thinking more along the lines of having a text file
    with a list of items that I can add to (in my case
    fluorescence filters)




    and then from the text file, when I run my matlab program,
    it automatically populates the popup menu. (At some stage I
    will want to compile it to an EXE and then have the users
    able to just change a text file to add more filters).

    I guess I would have to tell the popupmenu how many items
    where in the list?
    Jason, Mar 10, 2008
  4. You can use textscan() or any of several other I/O routines
    to read the contents of the file. Once you have the file read
    into a cell string, set() the 'String' property of the popup
    to be that cell string. You will not need to tell the popup
    menu how many items were in the list: it will count them automatically.
    Walter Roberson, Mar 10, 2008
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.