Problem getting a simple dialog to display

#1
Trying to create a dialog box that displays line by line a lisp file inside of a list box.
Everything works up until the last line of code to display the dialog via (start-dialog)...
When you load the file, it runs it and simply returns a zero, but no dialog box and no
prompt statement following the (start_dialog) statement...Any ideas?

Here's the code:

Code: Select all

(defun create-dialog ()
  (setq dialogWidthPercent 80) ; Width percentage of the dialog
  (setq dialogHeightPercent 80) ; Height percentage of the dialog

  ; Get the screen size as a list
  (setq screenSize (getvar "screensize"))

  ; Extract screen width and height from the list
  (setq screenWidth (car screenSize)) ; Get screen width
  (setq screenHeight (cadr screenSize)) ; Get screen height

  ; Calculate dialog width and height based on percentages
  (setq dialogWidth (/ (* screenWidth dialogWidthPercent) 100.0)) ; Convert to real number
  (setq dialogHeight (/ (* screenHeight dialogHeightPercent) 100.0)) ; Convert to real number

  ; Generate the DCL string for the dialog
  (setq tempDCL
    (strcat
      "lisp_debugger : dialog {\n" ; Rename the dialog to "lisp_debugger"
      "label = \"Load Lisp File\";\n"
      "size = \"" (rtos dialogWidth 2 0) "," (rtos dialogHeight 2 0) "\";\n" ; Use decimal output with 0 precision
      "spacer_style = 1;\n"
      "spacer_width = 0;\n"
      "column_resizable = false;\n"

      ": column {\n"
      ": button {\n"
      "key = \"btnLoad\";\n"
      "label = \"Load...\";\n"
      "fixed_width = 60;\n"
      "}\n"
      ": button {\n"
      "key = \"btnExit\";\n"
      "label = \"Exit\";\n"
      "fixed_width = 60;\n"
      "}\n"
      ": button {\n"
      "key = \"btnClear\";\n"
      "label = \"Clear\";\n"
      "fixed_width = 60;\n"
      "}\n"
      ": button {\n"
      "key = \"btnAbout\";\n"
      "label = \"About\";\n"
      "fixed_width = 60;\n"
      "}\n"
      ": edit_box {\n"
      "key = \"editBox\";\n"
      "width = 100;\n"
      "height = 20;\n"
      "fixed_width = 0;\n"
      "is_password = false;\n"
      "}\n"
      ": list_box {\n"
      "key = \"listBox\";\n"
      "width = \"" (rtos (- dialogWidth 20.0) 2 0) "\";\n" ; Use decimal output with 0 precision
      "height = \"" (rtos (- dialogHeight 150.0) 2 0) "\";\n" ; Use decimal output with 0 precision
      "fixed_width = 0;\n"
      "multiple_select = false;\n"
      "}\n"
      "}\n"
      "}\n"
    )
  )

  ; Write the DCL string to the file
  (setq dclFilePath (strcat (getvar "TEMPPREFIX") "lisp_debugger.dcl")) ; Rename the DCL file
  (setq dclFile (open dclFilePath "w"))
  (if dclFile
    (progn
      (write-line tempDCL dclFile)
      (close dclFile)
    )
  )

  (prompt (strcat "\nDCL file created: " dclFilePath)) ; DEBUG: Print path of created DCL file

  ; Load the DCL file
  (setq dialogId (load_dialog dclFilePath))

  (prompt (strcat "\nDialog ID: " (itoa dialogId))) ; DEBUG: Print dialog ID

  ; Set tile for controls
  (if dialogId
    (progn
      (set_tile "btnLoad" "btnLoadCallback")
      (set_tile "btnExit" "btnExitCallback")
      (set_tile "btnClear" "btnClearCallback")
      (set_tile "btnAbout" "btnAboutCallback")
      (set_tile "editBox" "editBoxValue")
      (set_tile "listBox" "listBoxValue")
    )
  )

  (prompt "\nActions set for ALL tiles...")
  ; Display the dialog
  (if dialogId
    (start_dialog)
    (prompt "\nDialog should have appeared!")
  )
)

; Callback functions
(defun btnLoadCallback (control handle)
  (setq filename (getfiled "Select Lisp File" "" "Lisp Files (*.lsp)|*.lsp"))
  (if filename
    (progn
      (setq fileContent (read-file filename))
      (setq listBoxContent (vlax-make-safearray vlax-vbstring (cons 0 (1- (length fileContent)))))
      (foreach line fileContent
        (setq index (1- (length listBoxContent)))
        (vlax-safearray-put-element listBoxContent index line)
      )
      (vla-put-ColumnWidth listBox 0 10)
      (vla-put-ColumnWidth listBox 1 (- dialogWidth 30.0))
      (vla-put-list listBox listBoxContent)
    )
  )
)

(defun btnExitCallback (control handle)
  (done_dialog 1)
)

(defun btnClearCallback (control handle)
  (vla-delete-all-items listBox)
)

(defun btnAboutCallback (control handle)
  (alert "This is the about message.")
)

; Create the dialog
(create-dialog)
cron