Author Topic: A question about an DCL example.  (Read 331 times)

0 Members and 1 Guest are viewing this topic.

andy_lee

  • Newt
  • Posts: 146
A question about an DCL example.
« on: March 17, 2017, 08:13:25 am »
Hi
Dear friend. I see a DCL example at "web2.airmail.net" .


Code: [Select]

//---------------------------------------------------------------------------------------------------------
// MyYesNo
// Note: The width for the Text1 key was determined by the syntax example and
// will need to be changed as per your requirements. Also note that the buttons
// for Yes and No, the added fixed_width = true;.
//---------------------------------------------------------------------------------------------------------
MyYesNo : dialog {
  key = "Title";
  label = "";//Title$ from lsp file
  spacer;
  : text {
    key = "Text1";
    label = "";//Question$ from lsp file
    width = 35.0;
    alignment = centered;
  }
  spacer;
  : row {
    fixed_width = true;
    alignment = centered;
    : button {
      key = "Yes";
      label = "&Yes";
      is_default = true;
      width = 7.92;
      fixed_width = true;
    }
    : button {
      key = "No";
      label = "&No";
      is_cancel = true;
      width = 7.92;
      fixed_width = true;
    }
  }
}//MyYesNo

Code: [Select]
;----------------------------------------------------------------------------------------------------------
; MyYesNo - Question dialog with one question line
; Arguments: 2
;   Title$ = Dialog Title
;   Question$ = Question line
; Syntax: (MyYesNo " My Yes No" "Do you like creating programs in AutoLISP?")
;----------------------------------------------------------------------------------------------------------
(defun MyYesNo (Title$ Question$ / Answer$ Dcl_Id% Return#)
  (princ "\nMyYesNo")(princ)
  ; Load Dialog
  (setq Dcl_Id% (load_dialog "MyDialogs.dcl"))
  (new_dialog "MyYesNo" Dcl_Id%)
  ; Set Dialog Initial Settings
  (set_tile "Title" Title$)
  (set_tile "Text1" Question$)
  ; Dialog Actions
  (action_tile "Yes" "(done_dialog 1)")
  (action_tile "No" "(done_dialog 0)")
  (setq Return# (start_dialog))
  ; Unload Dialog
  (unload_dialog Dcl_Id%)
  (if (= Return# 1)
    (setq Answer$ "Yes")
    (setq Answer$ "No")
  );if
  (princ "\n")(princ Answer$)(princ);Optional
  Answer$
);defun MyYesNo

usage:
Code: [Select]
(MyYesNo " My Yes No" "Do you like creating programs in AutoLISP?")
"My Yes No" is Title.
"Do you like creating programs in AutoLISP?" is message need to display.   I want use a variable[ eg: (getvar "dwgprefix") ]  in this message .  How do it ?
« Last Edit: March 17, 2017, 08:40:44 am by andy_lee »
andy.
Best regards.

Peter2

  • Bull Frog
  • Posts: 413
Re: A question about an DCL example.
« Reply #1 on: March 17, 2017, 09:36:59 am »
To concatenate strings usually strcat is used:

Code - Auto/Visual Lisp: [Select]
  1. (MyYesNo " My Yes No" (strcat "Do you want to open "  (getvar "dwgprefix") " now?")
(Untested ...)
Peter

AutoCAD 2011 - 2017 German (so some technical terms will be badly retranslated to English)

andy_lee

  • Newt
  • Posts: 146
Re: A question about an DCL example.
« Reply #2 on: March 17, 2017, 10:43:30 am »
To concatenate strings usually strcat is used:

Code - Auto/Visual Lisp: [Select]
  1. (MyYesNo " My Yes No" (strcat "Do you want to open "  (getvar "dwgprefix") " now?")
(Untested ...)

Thanks Peter . Nice !
The result is
Code: [Select]
Do you want to open  C:\\Users\\Administrator\\Documents\\ now?"
But I want like this

Code: [Select]
Do you want to open  "C:\\Users\\Administrator\\Documents\\" now?"

possible?
andy.
Best regards.

Lee Mac

  • Seagull
  • Posts: 11681
  • AutoCAD 2015 Windows 7 London, England
Re: A question about an DCL example.
« Reply #3 on: March 17, 2017, 01:33:36 pm »
Escape the double-quotes using a backslash, e.g.:

Code - Auto/Visual Lisp: [Select]
  1. (MyYesNo " My Yes No" (strcat "Do you want to open \""  (getvar "dwgprefix") "\" now?")

andy_lee

  • Newt
  • Posts: 146
Re: A question about an DCL example.
« Reply #4 on: March 19, 2017, 09:47:51 am »
Escape the double-quotes using a backslash, e.g.:

Code - Auto/Visual Lisp: [Select]
  1. (MyYesNo " My Yes No" (strcat "Do you want to open \""  (getvar "dwgprefix") "\" now?")

Thanks  Lee,  you are so smart.
andy.
Best regards.

efernal

  • Newt
  • Posts: 167
Re: A question about an DCL example.
« Reply #5 on: March 21, 2017, 04:49:10 pm »
Code - Auto/Visual Lisp: [Select]
  1. ;;try
  2. (acet-ui-message "message" "title" 36)
  3. ;;6 for yes, 7 for no
  4. ;;no dcl needed...
  5.  
  6.  
e.fernal