a little assistance please

Started by andrew, December 02, 2009, 09:45:58 AM

Previous topic - Next topic

andrew

i get the error message
Error: NIL value not allowed
Function: dcl_control_setlist
Argument: 0

here is my code


(command "OPENDCL")

(defun c:Hello ()

; call the method to load the HelloWorld.odcl file.
(dcl_Project_Load "od-test1" T)

; call the method to show the Hello World dialog box example
(dcl_Form_Show od-test1_Form1)
(princ)
)

(defun c:od-test1_Form1_TextButton1_OnClicked (/)
(dcl_Form_Close od-test1_Form1)
)

(defun c:od-test1_Form1_OnInitialize (/)
(setq datafile "c:\test.txt")
        (setq ofile (open datafile "r"))
        (while (setq curline (read-line ofile))
          (setq file_content_list (cons curline file_content_list))
        )
        (close ofile)

        (setq file_content_list (reverse file_content_list))
  (dcl_Control_SetList od-test1_Form1_ListBox1 file_content_list)
)


(defun c:od-test1_Form1_TextButton2_OnClicked (/)
  (dcl_Control_GetCaption od-test1_Form1_TextButton2)
)


the file test.txt does exist in the local C
what am i doing wrong?


Kerry


Just a guess ... I'd need the odcl  to test..
try
(setq datafile "c:\\test.txt")
or
(setq datafile "c:/test.txt")
Perfection is not optional.
My other home is TheSwamp

andrew


andrew

i got it working, i just deleted the files and re-created them

andrew

i created a new file and its not displaying the list again

good greif

Kerry


Andrew,
did you try changing
(setq datafile "c:\test.txt")
to
(setq datafile "c:\\test.txt")

Perfection is not optional.
My other home is TheSwamp

Kerry


and I think that
(dcl_Control_SetList od-test1_Form1_ListBox1 file_content_list)
should be
(dcl_ListBox_AddList od-test1_Form1_ListBox1 file_content_list)

but I'd need to see the contents of the Test.txt file.
You are trying to populate the list, yes ?
Is the file_content_list a list of lists ?
Perfection is not optional.
My other home is TheSwamp

andrew

Kerry,
I did try the other method and it still didnt work.

the txt file is just lines of directory paths of drawing

ex.
C:\Users\andrew\Documents\Drawing1.dwg
C:\Users\andrew\Documents\Drawing2.dwg
etc.

i didnt use the (dcl_ListBox_AddList od-test1_Form1_ListBox1 file_content_list)
because im not looking to append new items to the list, just to read a txt file and display what is in the txt file.

it works on 1 test file i made but not on another. i cant imagine why.

thanks for your help

Kerry


OK,
Here is your problem.

The ODCL file is named od-test1.ODCL
The Events in the editor are named od-test_Form1.xxxxx
The Events in the lisp file are named od-test1_Form1.xxxxx

So, the events in the ODCL are named differntly to the eventFunctions in the Lisp File

To fix this :
I unchecked and rechecked each event so that they were renamed to  od-test1_Form1.xxxxx

Changed the
(setq datafile "c:\test.txt")
to
(setq datafile "c:\\test.txt")


I changed the
(dcl_Control_SetList od-test1_Form1_ListBox1 file_content_list)
To
(dcl_ListBox_AddList od-test1_Form1_ListBox1 file_content_list)


Seems to work on the .TXT file I made ( a list of qualified DWG path/file names.)

Regards
Perfection is not optional.
My other home is TheSwamp

andrew

Quote from: Kerry Brown on December 03, 2009, 07:34:31 AM

OK,
Here is your problem.

The ODCL file is named od-test1.ODCL
The Events in the editor are named od-test_Form1.xxxxx
The Events in the lisp file are named od-test1_Form1.xxxxx

So, the events in the ODCL are named differntly to the eventFunctions in the Lisp File

To fix this :
I unchecked and rechecked each event so that they were renamed to  od-test1_Form1.xxxxx

Changed the
(setq datafile "c:\test.txt")
to
(setq datafile "c:\\test.txt")


I changed the
(dcl_Control_SetList od-test1_Form1_ListBox1 file_content_list)
To
(dcl_ListBox_AddList od-test1_Form1_ListBox1 file_content_list)


Seems to work on the .TXT file I made ( a list of qualified DWG path/file names.)

Regards


i appreciate your help
the fixing of the form1 helped but these other changes changes didnt help.

changed this line didnt make a difference
(setq datafile "c:\test.txt")
to
(setq datafile "c:\\test.txt")


in fact i get errors on my working model when i changed the

(dcl_Control_SetList od-test1_Form1_ListBox1 file_content_list)
To
(dcl_ListBox_AddList od-test1_Form1_ListBox1 file_content_list)


whats even more strange, and im certain its something im missing as it usually is, is that i re-created this same form in a modelss form and its not displaying the list again.

back to the drawing board... thanks again

Kerry

Quotein fact i get errors on my working model when i changed the .....

What error Message ??

Just for Info
Code (autolisp) Select

(command "OPENDCL")

(defun c:Hello ( / file_content_list)                                                
 (dcl_Project_Load "od-test1" T)                                
 (dcl_Form_Show od-test1_Form1)
 (princ)
)

(defun c:od-test1_Form1_TextButton1_OnClicked (/)
 (dcl_Form_Close od-test1_Form1)
)

(defun c:od-test1_Form1_OnInitialize (/ datafile ofile curline)
 (setq datafile "c:\\test.txt")
 (setq ofile (open datafile "r"))
 (while (setq curline (read-line ofile))
   (setq file_content_list (cons curline file_content_list))
 )
 (close ofile)
 (setq file_content_list (reverse file_content_list))
 (dcl_ListBox_AddList od-test1_Form1_ListBox1 file_content_list)
)


(defun c:od-test1_Form1_TextButton2_OnClicked (/)
 (dcl_Control_GetCaption od-test1_Form1_TextButton2)
)


The dialog piccy attached :
Perfection is not optional.
My other home is TheSwamp

andrew

i didnt think this would be so difficult but good lord...
i must have re-written this code at least 10 times

Kerry

#12
Looks to me as if the control names are wrong or file_content_list is nil ...

post(attach)  the LSP and ODCL that is a problem.
Perfection is not optional.
My other home is TheSwamp

andrew

i had a misspelling in the test lisp which caused that...
forgive my ignorance.

it does seem that my file_content_list is coming up nil
which is why its not displaying.

i cant understand why if it work on one file and not the other.
even if i rename the working test file to something else and change the proper lines to reflect the name change, the list box returns empty, if i rename it back to the original lines, it works.
is this something that you can not do with odcl?



owenwengerd