OpenDCL Forums

OpenDCL => Studio/Dialog Editor => Topic started by: andrew on December 02, 2009, 09:45:58 AM

Title: a little assistance please
Post by: andrew on December 02, 2009, 09:45:58 AM
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?

Title: Re: a little assistance please
Post by: Kerry on December 02, 2009, 09:51:42 AM

Just a guess ... I'd need the odcl  to test..
try
(setq datafile "c:\\test.txt")
or
(setq datafile "c:/test.txt")
Title: Re: a little assistance please
Post by: andrew on December 02, 2009, 10:18:50 AM
here is the odcl file

Title: Re: a little assistance please
Post by: andrew on December 02, 2009, 10:46:08 AM
i got it working, i just deleted the files and re-created them
Title: Re: a little assistance please
Post by: andrew on December 02, 2009, 12:04:37 PM
i created a new file and its not displaying the list again

good greif
Title: Re: a little assistance please
Post by: Kerry on December 02, 2009, 10:51:59 PM

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

Title: Re: a little assistance please
Post by: Kerry on December 02, 2009, 11:01:47 PM

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 ?
Title: Re: a little assistance please
Post by: andrew on December 03, 2009, 05:58:16 AM
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
Title: Re: a little assistance please
Post by: Kerry 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
Title: Re: a little assistance please
Post by: andrew on December 03, 2009, 08:08:44 AM
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
Title: Re: a little assistance please
Post by: Kerry on December 03, 2009, 08:24:36 AM
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 :
Title: Re: a little assistance please
Post by: andrew on December 03, 2009, 08:37:28 AM
i didnt think this would be so difficult but good lord...
i must have re-written this code at least 10 times
Title: Re: a little assistance please
Post by: Kerry on December 03, 2009, 08:45:13 AM
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.
Title: Re: a little assistance please
Post by: andrew on December 03, 2009, 08:54:12 AM
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?


Title: Re: a little assistance please
Post by: owenwengerd on December 03, 2009, 08:54:21 AM
Argument 0 is the control name.
Title: Re: a little assistance please
Post by: owenwengerd on December 03, 2009, 08:56:53 AM
Andrew, I recommend to spend some learning how to debug your code with the VLIDE.  You can step through the code with the VLIDE to see where it is failing rather than changing things randomly in hopes that it will suddenly work.
Title: Re: a little assistance please
Post by: andrew on December 03, 2009, 09:07:34 AM
Quote from: owenwengerd on December 03, 2009, 08:56:53 AM
Andrew, I recommend to spend some learning how to debug your code with the VLIDE.  You can step through the code with the VLIDE to see where it is failing rather than changing things randomly in hopes that it will suddenly work.

Owen, thanks for the help.

I ran the code alone thru vlide, and it works as it should.
but when i incorporate it into the odcl code it doesnt work

even when i use the following code in place of reading an external file it still dont list


(defun c:od-toolbox_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-toolbox_Form1_ListBox1 file_content_list) 
  (dcl_ListBox_AddList od-toolbox_Form1_ListBox1 "hello" "world")
)
Title: Re: a little assistance please
Post by: Kerry on December 03, 2009, 09:13:31 AM

The function expects a list

so, try
(dcl_ListBox_AddList od-toolbox_Form1_ListBox1 (list "hello" "world")  )
Title: Re: a little assistance please
Post by: Kerry on December 03, 2009, 09:30:11 AM
Try something like this for debugging..

Note I've added the findfile
(setq datafile (findfile "c:\\test.txt"))

Recording set to run once.  F5 refresh to replay.

Title: Re: a little assistance please
Post by: andrew on December 03, 2009, 10:08:25 AM
yep mine works the same way
???

here are my files can you run them and tell me if they work for you?
Title: Re: a little assistance please
Post by: BazzaCAD on December 03, 2009, 11:23:38 AM
You don't have the "Initialize" event checked on your form.
Remember to save your project after you do..
Title: Re: a little assistance please
Post by: andrew on December 03, 2009, 12:30:34 PM
Quote from: BazzaCAD on December 03, 2009, 11:23:38 AM
You don't have the "Initialize" event checked on your form.
Remember to save your project after you do..


wow that was simple heh

thanks everyone for the help