• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Community Forums
  2. Allegro X PCB Editor
  3. Adding lines to a listbox from a text file

Stats

  • Replies 2
  • Subscribers 159
  • Views 13632
  • Members are here 0
More Content

Adding lines to a listbox from a text file

joma
joma over 9 years ago

Hi, I am trying to populate a listbox from a text file but I get an error:
E- *Error* axlFormSetField: argument #1 should be any user-defined (other) type (type template = "otg") - nil

I use the following to read my file:

        putd('pmGetListOfNotas nil)
        (defun pmGetListOfNotas ()
            axlUIWPrint(nil " Get List" "(" ")")
                notas_port = axlDMOpenFile("ALLEGRO_TEXT" "./nota_list.txt" "r")
                        while(
                        notas=gets(notas notas_port)
                        ;notas=lineread(notas_port)
                            l_notas=tconc(l_notas notas)
                            println(l_notas)
                        ); end while
                    l_notas=car(l_notas)
                            println(l_notas)
                            axlDMClose(notas_port)
                            l_notas
        ); defun pmGetListOfNotas

The  text file I use for testing is simply:
NOTE1 and -text
NOTE2 and +more text
NOTE3

and the println(l_notas) command returns the list:
("NOTE1 and - text\n" "NOTE2 and +more text\n" "NOTE3\n")

My code for adding the list to a listbox is:

         putd('pmAddnotasToForm nil)
         (defun pmAddnotasToForm (l_notas)

             axlUIWPrint(nil "liste de notas " "(" ")")
             if(zerop(notas) then
                 axlFormSetField(NoteForm "NotaList" "No Notas Found")
            axlUIWPrint(nil "No notas found" "(" ")")
             else
                 foreach(note l_notas
                    axlUIWPrint(nil " Foreach Notas" "(" ")")
                     axlFormSetField(NoteForm "NotaList" note)
                 ); foreach
             );if
;        );let

         ); defun pmAddnotasToForm

        axlUIWPrint(nil "** Gathering notas , please wait. **" )
        pmAddnotasToForm(pmGetListOfNotas())
        axlUIWPrint(nil " -Get list of notas Done - " )

I then have two problems to resolve. One is the error that come from the "axlFormSetField" in the foreach loop and the other is to remove the last two characters (\n) from each list element before inserting in the "axlFormSetField" line. The \n characters come from the gets command but if I use the lineread command instead I get my input line broken up if I have any special characters in it.

Any help appreciated.
Jim O'Mahony

  • Sign in to reply
  • Cancel
Parents
  • eDave
    eDave over 9 years ago

    Hi Jim,

    1/

    You need to pass the NoteForm variable from the calling function. Your function should start with:

    (defun pmAddnotasToForm (NoteForm, l_notas)

    2/

    You can use axlStringRemoveSpaces to strip the \n characters.

    An alternative is to use the substring command:

    substring(note, 1, strlen(note) - 1)

    Dave

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Reply
  • eDave
    eDave over 9 years ago

    Hi Jim,

    1/

    You need to pass the NoteForm variable from the calling function. Your function should start with:

    (defun pmAddnotasToForm (NoteForm, l_notas)

    2/

    You can use axlStringRemoveSpaces to strip the \n characters.

    An alternative is to use the substring command:

    substring(note, 1, strlen(note) - 1)

    Dave

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Children
No Data
Cadence Guidelines

Community Guidelines

The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.

© 2025 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information