Author Topic: OnClicked doesn't execute unless I run routine twice  (Read 1636 times)

0 Members and 1 Guest are viewing this topic.

jhadams82

  • Mosquito
  • Posts: 18
OnClicked doesn't execute unless I run routine twice
« on: June 26, 2017, 05:25:12 PM »
So here's a weird one.  I've been putting time on it here and there as I can for a few weeks now and I'm baffled.  But I'm pretty new so I bet one of you guys will look at this and see it right away.

I have a template file for our plan border and I want to change certain text objects based on user input from an OpenDCL form.  So I copy the template file to the job folder, open it, and run the routine.  It shows the ODCL form just fine, but when I click the submit button, nothing happens.  You can see I created "debug" messages to see if any of the code executes inside the OnClicked function and none of it does.  Now here's the weird part that will probably give you a clue.  If I re-run the routine without closing the file, most of it works.  But the last text change gives an error "bad function name:  JOB NO." or something like that.

Let me know if you need any further info.  Any hints you could give me would be much appreciated.

Code - Auto/Visual Lisp: [Select]
  1. (command "-insert" "P:/CSDG Standards/AutoCAD STD/CSDG Blocks/Stamps/Jim Stamp.dwg" '(34.4163 17.5196) "" "" "")
  2.  
  3. (command "OPENDCL")
  4.  
  5. ; not sure if i need this
  6.  
  7. (setq ob_planType (vlax-ename->vla-object (ssname (ssget "_X" '((0 . "TEXT,MTEXT")(1 . "TYPE OF PLANS"))) 0)))
  8. (setq ob_projName (vlax-ename->vla-object (ssname (ssget "_X" '((0 . "TEXT,MTEXT")(1 . "PROJECT NAME"))) 0)))
  9. (setq ob_address (vlax-ename->vla-object (ssname (ssget "_X" '((0 . "TEXT,MTEXT")(1 . "ADDRESS"))) 0)))
  10. (setq ob_cityCountyState (vlax-ename->vla-object (ssname (ssget "_X" '((0 . "TEXT,MTEXT")(1 . "CITY*"))) 0)))
  11. (setq ob_jobNum (vlax-ename->vla-object (ssname (ssget "_X" '((0 . "TEXT,MTEXT")(1 . "JOB*"))) 0)))
  12.  
  13. (dcl_Project_Load "P:/CSDG AutoCAD Civil/Lisp Routines/Justin/OpenDCL/border_text" T)
  14.  
  15. (dcl_Form_Show border_text/Form1)
  16.  
  17. (defun c:border_text/Form1/btn_submit#OnClicked (/)
  18.  
  19.   (print "debug 1")
  20.  
  21.   (setq jobNum (dcl-Control-GetText border_text/Form1/tb_jobNum))
  22.   (setq projectName (dcl-Control-GetText border_text/Form1/tb_projectName))
  23.   (setq planType (dcl-Control-GetText border_text/Form1/tb_planType))
  24.   (setq address (dcl-Control-GetText border_text/Form1/tb_address))
  25.   (setq cityCountyState (dcl-Control-GetText border_text/Form1/tb_cityCountyState))
  26.   (setq mapNum (dcl-Control-GetText border_text/Form1/tb_mapNum))
  27.   (setq parcel (dcl-Control-GetText border_text/Form1/tb_parcel))
  28.  
  29.   (print "debug 2")
  30.  
  31.   (dcl-Form-Close border_text/Form1)
  32.  
  33.   (print "debug 3")
  34.  
  35.   (vlax-put-property ob_planType "TEXTSTRING" planType)
  36.   (vlax-put-property ob_projName "TEXTSTRING" projectName)
  37.   (vlax-put-property ob_address "TEXTSTRING" address)
  38.   (vlax-put-property ob_cityCountyState "TEXTSTRING" cityCountyState)
  39.   (vlax-put-property ob_jobNum "TEXTSTRING" (strcat("JOB NO.: " jobNum)))
  40.  
  41.   (print "debug 4")
  42. )

marcoheuer

  • Mosquito
  • Posts: 3
Re: OnClicked doesn't execute unless I run routine twice
« Reply #1 on: June 27, 2017, 01:27:29 AM »
hello jhadams82,
change row 40 to
Code: [Select]
(vlax-put-property ob_jobNum "TEXTSTRING" (strcat "JOB NO.: " jobNum))
regards
marco

jhadams82

  • Mosquito
  • Posts: 18
Re: OnClicked doesn't execute unless I run routine twice
« Reply #2 on: June 27, 2017, 10:37:07 AM »
ah ha!  thanks, marco.  that's one bug squashed.  but it still doesn't run through on the first try.  any clue what that's about?  maybe something to do with how/when I load the OpenDCL lib?  does anybody have any debugging advice for ODCL?

VovKa

  • Water Moccasin
  • Posts: 1631
  • Ukraine
Re: OnClicked doesn't execute unless I run routine twice
« Reply #3 on: June 27, 2017, 11:14:45 AM »
does anybody have any debugging advice for ODCL?
function c:border_text/Form1/btn_submit#OnClicked must be defined BEFORE (dcl_Form_Show border_text/Form1)

jhadams82

  • Mosquito
  • Posts: 18
Re: OnClicked doesn't execute unless I run routine twice
« Reply #4 on: June 27, 2017, 11:21:06 AM »
OMG YES!! :yay!:  VovKa for the win!  thank you!  lol, I knew it would be simple.  As soon as I saw that I wanted to kick myself.  Thanks again