Author Topic: ( CHALLENGE ) Remembering Variables.  (Read 8971 times)

0 Members and 1 Guest are viewing this topic.

DEVITG

  • Bull Frog
  • Posts: 479
Re: ( CHALLENGE ) Remembering Variables.
« Reply #15 on: April 22, 2006, 12:22:17 PM »
Hi LE , furthermore than telling Kelly to Kerry , it shall be some one I'm doing wrong
following are all the defun loaded by the lisp

Quote
KB:GETSTRING
KB:GETREAL
KB:GETINT
KB:GETPOINT
KB:GETASS
KB:POINTTOSTRING
KB:PRINCDOTTEDLIST
KB:SETGLOBALPAIRSLIST
KB:RESTOREVARIABLE
KB:RESTOREVARIABLES
KB:ASSERTSAVEDVARIABLES
C:TEST06
 
Location @ Córdoba Argentina Using ACAD 2019  at Window 10

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: ( CHALLENGE ) Remembering Variables.
« Reply #16 on: April 22, 2006, 07:27:20 PM »
DEVITG,

The KDUB prefix is my registered developers prefix and I didn't mean to use it here.

Let me have a coffee and I'll have a look at the code posted.

Unfortunately I did that in a bit of a hurry, and it looks like I didn't pay sufficient attention to ensuring the sample was self contained.  BRB.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: ( CHALLENGE ) Remembering Variables.
« Reply #17 on: April 22, 2006, 07:33:31 PM »
....
I did a test on c:test06

but it ask for this  defun

KDUB:IACADAPPLICATION

located here

Code: [Select]
;;------------- Confirm global document variables
      ;;
      (OR kg:IAcadApplication
          (SETQ kg:IAcadApplication (VLAX-GET-ACAD-OBJECT))
      )
      (OR kg:IAcadDocument
          (SETQ kg:IAcadDocument
                  (VLA-GET-ACTIVEDOCUMENT (kdub:iacadapplication)
                  )
          )
      )
      ;;



Am I doing, some thing wrong??? :oops:


It wasn't you, it was me .. :-)

Give this a try, using a global variable < kg:IAcadApplication > rather than a method call ...

Code: [Select]
;;------------- Confirm global document variables
      ;;
      (OR kg:IAcadApplication
          (SETQ kg:IAcadApplication (VLAX-GET-ACAD-OBJECT))
      )
      (OR kg:IAcadDocument
          (SETQ kg:IAcadDocument  (VLA-GET-ACTIVEDOCUMENT kg:IAcadApplication) )
      )
      ;;


kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: ( CHALLENGE ) Remembering Variables.
« Reply #18 on: April 22, 2006, 10:48:48 PM »
This could be the next step in the process of developing the Dialog interface that we want,

Or aim is to select text and return to the dialog, retaining the desired current values.

The process requires that the Dialog be hidden to allow access to the objects displayed.
There are several methodologies to achieve this goal .. here is one.

I haven't added much documentation as such, so if anyone has comments or questions, fire away.

First, the dialog :
Code: [Select]
// PeekaBoo.DCL
// codehimbelonga kwb@theSwamp
// 20060423
// Sample code to hide dialog

peekaboo : dialog {
label = "Hide Dialog Sample";
:boxed_column {
: edit_box { key = "peekaboo:text"; label = "Who dat ?";}
: button { key = "peekaboo:select"; label = "Select a Point";}
: text { value = "Selected Point :"; is_bold = true;}
: text { key = "peekaboo:point"; value = " ... ";}
}
ok_cancel;
}

Then the code :
Code: [Select]
;; // PeekaBoo.LSP
;; // codehimbelonga kwb@theSwamp
;; // 20060423
;; // Sample code to hide dialog

(DEFUN c:peekaboo (/                dcl_id
                   dcl_status       LocalVarNames
                   selectedPoint
                   ;; DCL field key values based on tag names
                   peekaboo:text    peekaboo:point
                   ;; Local Functions
                   x:SelectPoint    x:saveFields
                  )
                  ;| requires functions
   (kb:getpoint . .)
   (kb:PointToString . . .)
   |;
   ;;
   ;;--------------------------
   ;; IS the dialog available, if so, load it and save the pointer
   ;;--------------------------
                                                 
   (IF (MINUSP (SETQ dcl_id (LOAD_DIALOG "peekaboo.DCL")))
      (PROGN (ALERT "Unable to load dialog file 'peekaboo.DCL' ") (EXIT))
   )
   ;;--------------------------------------------------------------
   ;;  local function to select point
   ;;--------------------------------------------------------------
   ;;
   (DEFUN x:SelectPoint ()
      (SETQ selectedPoint (kb:getpoint nil
                                       selectedPoint
                                       (+ 1 8)
                                       nil
                                       selectedPoint
                          )
      )
      (IF selectedPoint
         (SETQ peekaboo:point (VL-PRIN1-TO-STRING previousPoint))
      )
   )
   ;;--------------------------------------------------------------
   ;;  local function to save the dcl field values
   ;;--------------------------------------------------------------
   ;;
   (DEFUN x:saveFields (/)
      (MAPCAR '(LAMBDA (field) (SET (READ field) (GET_TILE field)))
              LocalVarNames
      )
   )
   ;;--------------------------------------------------------------
   ;;  local function to restore the dcl field values
   ;;--------------------------------------------------------------
   ;;
   (DEFUN x:restoreFields ()
      (MAPCAR '(LAMBDA (field)
                  (IF (SETQ tmp (EVAL (READ field)))
                     (SET_TILE field tmp)
                  )
               )
              LocalVarNames
      )
   )
   ;;--------------------------------------------------------------
   ;; 
   ;;--------------------------
   ;; set environment
   ;; set status higher than any expected DONE_DIALOG value
   ;;--------------------------
   ;;
   (SETQ LocalVarNames '("peekaboo:text" "peekaboo:point")
         dcl_status    10
   )
   ;;--------------------------
   ;;  begin a loop until DONE_DIALOG accept or cancel
   ;;--------------------------
   ;;
   (WHILE (> dcl_status 1)
      ;;--------------------------
      ;;  make sure the form is defined
      ;;--------------------------
      ;;   
      (IF (NOT (NEW_DIALOG "peekaboo" dcl_id))
         (EXIT)
      )
      ;; so proceed ..
      ;;--------------------------
      ;;  initialise the action_tiles
      ;;--------------------------
      ;;
      (x:restoreFields)
      (ACTION_TILE "peekaboo:select" "(x:saveFields)(DONE_DIALOG 9)")
      ;;--------------------------
      ;;  activate the dialog
      ;;--------------------------
      ;;   
      (SETQ dcl_status (START_DIALOG))
      ;;--------------------------
      ;;  if we are here, the dialog has been removed from the screen
      ;;  following either :
      ;; (DONE_DIALOG 0) Cancel
      ;; (DONE_DIALOG 1) OK
      ;; (DONE_DIALOG 9) "select"
      ;;--------------------------
      ;;
      (COND ((= dcl_status 0) (ALERT "ZERO "))
            ((= dcl_status 1) (ALERT "ONE "))
            ((= dcl_status 9) (x:SelectPoint))
      )
   )
   (UNLOAD_DIALOG dcl_id)
   (PRINC)
)

and a Piccy


kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: ( CHALLENGE ) Remembering Variables.
« Reply #19 on: April 22, 2006, 11:00:19 PM »
If you run this routine, and move the dialog location before selecting the point, you will notice that the dialog is restoted in the center of the screen after the selection.

The next part of this development could be determining a method to ensure the dialog is restored to its previous location.

.. and incorporating a global Variable so that the values from any previous function call can be restored .. which is the original intent of this thread.

I wont be around much this week, but I'm sure any questions or solutions will be treated with due consideration by theSwamp regulars.

/// be well, kwb
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

GDF

  • Water Moccasin
  • Posts: 2081
Re: ( CHALLENGE ) Remembering Variables.
« Reply #20 on: April 23, 2006, 03:55:11 PM »
If you run this routine, and move the dialog location before selecting the point, you will notice that the dialog is restoted in the center of the screen after the selection.

The next part of this development could be determining a method to ensure the dialog is restored to its previous location.

.. and incorporating a global Variable so that the values from any previous function call can be restored .. which is the original intent of this thread.

I wont be around much this week, but I'm sure any questions or solutions will be treated with due consideration by theSwamp regulars.

/// be well, kwb


Here is one way to remember the dialob box position, write the position to the registry.
I do this for all of my dialog boxes, works great.

Code: [Select]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;; ARCH Display Position Function ;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun ARCH:SETPOSXMODE (key /)
  (vl-registry-write
    "HKEY_CURRENT_USER\\Software\\Arch Program\\Controls\\Dialog\\PositionX"
    ""
    key
  )
  (setq ARCH#POSX
(vl-registry-read
   "HKEY_CURRENT_USER\\Software\\Arch Program\\Controls\\Dialog\\PositionX"
)
  )
  (princ)
)
(defun ARCH:SETPOSYMODE (key /)
  (vl-registry-write
    "HKEY_CURRENT_USER\\Software\\Arch Program\\Controls\\Dialog\\PositionY"
    ""
    key
  )
  (setq ARCH#POSY
(vl-registry-read
   "HKEY_CURRENT_USER\\Software\\Arch Program\\Controls\\Dialog\\PositionY"
)
  )
  (princ)
)
(defun ARCH:DIALOG_NEWLOCATION ()
  (setq ARCH#DIAP (done_dialog))
  (ARCH:SETPOSXMODE (rtos (car ARCH#DIAP) 2 0))
  (ARCH:SETPOSYMODE (rtos (cadr ARCH#DIAP) 2 0))
  (setq ARCH#DIAP (list (atoi ARCH#POSX) (atoi ARCH#POSY)))
  (princ)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ARCH Dialog Setup ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun ARCH:DIALOG_POSITION (dialnam)
  (if (not (new_dialog
     dialnam
     DCL_ID
     ""
     (if ARCH#DIAP
       ARCH#DIAP
       '(-1 -1)
     )
   )
      )
    ((exit)
      (ARCH:DCL_ERROR)
    )
  )
  (princ)
)
;;;(if (not (new_dialog "square" DCL_ID "" '(100 700))) (exit))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; DCL Alert ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun ARCH:DCL_ERROR ()
  ;;(ARCH:ALERT-E "MsgBox \"Lisp Routine's DCL File not found.\nCheck and Verify Support Paths.\"")
  (alert
    "Lisp Routine's DCL File not found.\nCheck and Verify Support Paths."
  )
  (princ)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; cancel Function ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun ARCH:CANCEL2 ()
  (ARCH:DIALOG_NEWLOCATION)
  (setq op nil)
  (done_dialog)
  (princ "\n*** ///////// Program  CANCELLED ///////// ***")
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Accept Function ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun ARCH:DO_ACT-DONE (key_pr)
  (ARCH:DIALOG_NEWLOCATION)
  (setq op key_pr)
  (done_dialog)
  (princ)
)
(defun ARCH:ACCEPT2 ()
  (ARCH:DIALOG_NEWLOCATION)
  (done_dialog)
  (princ)
)

Gary
« Last Edit: April 23, 2006, 04:03:29 PM by Gary Fowler »
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: ( CHALLENGE ) Remembering Variables.
« Reply #21 on: April 26, 2006, 01:08:57 AM »
Thanks Gary, that looks like a complete universal solution.

I thought someone may have tried for a more local solution, saving the last location as a variable, either local or global .. current for the document life
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

GDF

  • Water Moccasin
  • Posts: 2081
Re: ( CHALLENGE ) Remembering Variables.
« Reply #22 on: April 26, 2006, 10:45:23 AM »
Thanks Gary, that looks like a complete universal solution.

I thought someone may have tried for a more local solution, saving the last location as a variable, either local or global .. current for the document life

Your welcome. Let me know if it can be improved on.

Gary
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: ( CHALLENGE ) Remembering Variables.
« Reply #23 on: April 26, 2006, 06:28:00 PM »
hehehehe .. I'd be the last one to ask Gary :lol:
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: ( CHALLENGE ) Remembering Variables.
« Reply #24 on: May 03, 2006, 10:33:19 PM »
From the level of participation, this topic may be either too difficult of too easy .. and I don't know which.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: ( CHALLENGE ) Remembering Variables.
« Reply #25 on: May 03, 2006, 10:55:44 PM »
Kerry -- it's neither. Right now I'm simply too swamped to participate at the level this thread deserves. Nonetheless, it's a valuable topic -- do not let the current number of responses be the barometer. Look at how many times it has been read. It's a keeper, and I reserve right to contribute to it when I've the time, energy, imagination and general presence of mind -- all in deficit for some time now.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Jeff_M

  • King Gator
  • Posts: 4094
  • C3D user & customizer
Re: ( CHALLENGE ) Remembering Variables.
« Reply #26 on: May 03, 2006, 10:59:43 PM »
From the level of participation, this topic may be either too difficult of too easy .. and I don't know which.
Well, I was turned off and quit reading in the first post by this:
Challenge :

Create library routines to read and write from DCL fields, saving to the global Variable.
Create library routines to read and write the variable to disk.
Each application would use a unique prefix for the Global Variable.

since I don't use DCL's at all......... :-P Now, had I even the slightest bit of interest in learning DCL or ODCL I probably would've checked it out a bit more. But with my schedule of late, both work & personal, I just couldn't muster up the energy to learn yet another new thing....

Whatever you all came up with I'm sure works quite well.....I'll go and read the rest of the thread later when Kim goes to work.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: ( CHALLENGE ) Remembering Variables.
« Reply #27 on: May 03, 2006, 11:26:32 PM »
MP, Jeff ;
Thanks for the comments,
I hadn't expected much posting from the guys who have this down pat as you surely do ... I had hoped  < perhaps erroneously > to have people join in who may benefit from a discussion like this.

Jeff, I'd rather use a viable alternative to DCL's, but I needed to polish up some older code with minimal cost and modification. DCL isn't too bad really once you get the hang of it.  If ODCL is delayed much longer I will have to translate Interfaces to either DCL or start using C#.NET dialogs sooner than I'd expected or planned.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.