+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 11
  1. #1
    Junior Member
    Using
    Architecture 2016
    Join Date
    Nov 2014
    Posts
    20

    Default I need an additional LISP lesson

    Registered forum members do not see this ad.

    Hi together,

    I'm looking for a "jump mark" or a "goto-function" but there is no one.
    I need a simplification of my code because I don't want to write the programs e.g.(program 1), (program 2),... twice under each (progn because there are the same.

    ...
    (if (/= 0 checkPINstate)
    (progn
    (requestPIN)
    (if (= checkPIN inputPIN)
    (program 1)
    (program 2)
    ...
    ...
    )
    )
    (progn
    (program 1)
    (program 2)
    ...
    ...
    )
    )
    ...
    kind regards
    Bluebird1973

  2. #2
    Forum Deity David Bethel's Avatar
    Discipline
    Multi-disciplinary
    David Bethel's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Commercial Food Service
    Using
    AutoCAD pre 2000
    Join Date
    Dec 2003
    Location
    Newport News, Virginia
    Posts
    2,522

    Default

    There are a lot of different ways to approach this

    Code:
      (while (/= 0 checkPINstate)
             (requestPIN)
             (checkPINstate))
      (program1)
      (program2)
    This will force a correct PIN, leaving only esc as a alternate exit ( probably not the most elegant nor best solution )

    -David
    R12 (Dos) - A2K

  3. #3
    Senior Member
    Computer Details
    ronjonp's Computer Details
    Operating System:
    Windows 10
    Using
    AutoCAD 2018
    Join Date
    Apr 2009
    Location
    Colorado
    Posts
    461

    Default

    My 2c...
    Code:
    (cond ((and (/= 0 checkpinstate) (requestpin) (= checkpin inputpin)) (program 1) (program 2))
          ((program 1) (program 2))
    )
    Last edited by ronjonp; 13th Oct 2017 at 02:24 pm.

  4. #4
    Junior Member
    Using
    Architecture 2016
    Join Date
    Nov 2014
    Posts
    20

    Default

    Hi David,
    Hi ronjonp,

    Thanks for your try, but it didn't work.

    kind regards
    Bluebird1973

  5. #5
    Senior Member
    Computer Details
    ronjonp's Computer Details
    Operating System:
    Windows 10
    Using
    AutoCAD 2018
    Join Date
    Apr 2009
    Location
    Colorado
    Posts
    461

    Default

    Quote Originally Posted by Bluebird1973 View Post
    Hi David,
    Hi ronjonp,

    Thanks for your try, but it didn't work.

    kind regards
    Bluebird1973
    With your example above, (program1) and (program2) will always run so not sure where you're going with this?

    Perhaps:
    Code:
    (cond ;; Pin already validated .. run programs
          ((= 0 checkpinstate) (program 1) (program 2))
          ;; Pin not validated, get the pin, if pin checks out then run programs
          ((and (requestpin) (= checkpin inputpin)) (program 1) (program 2))
    )

  6. #6
    Super Member
    Discipline
    Multi-disciplinary
    Using
    AutoCAD 2015
    Join Date
    Nov 2013
    Posts
    1,080

    Default

    What if (requestpin) asigns a global variable 'checkpinstate' and then the funciton itself returns nil.

    Another 2c..
    Code:
    (if (member checkpinstate '(nil 0)) (requestpin))
    (cond ( (and checkpinstate (/= 0 checkpinstate)) (program1) (program2) ))
    Quote Originally Posted by Bluebird1973 View Post
    Thanks for your try, but it didn't work.
    When requesting for hints, the copy-paste approach doesn't work always with the examples.

  7. #7
    Senior Member
    Computer Details
    ronjonp's Computer Details
    Operating System:
    Windows 10
    Using
    AutoCAD 2018
    Join Date
    Apr 2009
    Location
    Colorado
    Posts
    461

    Default

    Perhaps:
    Code:
    (cond
      ;; Pin already validated .. run programs
      ((= "0" (getenv "checkpinstate")) (program 1) (program 2))
      ;; Pin not validated, get the pin, if pin checks out set the 'checkpinstate' variable then run programs
      ((and (requestpin) (= checkpin inputpin)) (setenv "checkpinstate" "0") (program 1) (program 2))
    )
    Kind of hard to come to a solution when 1/2 of this requires reading minds LOL.

  8. #8
    Junior Member
    Using
    Architecture 2016
    Join Date
    Nov 2014
    Posts
    20

    Default

    I found now a solution.


    Code:
    (progn
       (cond
          (
             (/= 0 checkPINstate)
                (progn
                   (requestPIN)
                   (cond
                    (
                      (/= checkPIN inputPIN)
                         (progn
                          (princ "\nError: bad argument pw")
                          (exit)
                          )
                    )
                   )
                )
          )
       )
    
       (if (= Prog checkProg)
          (progn
             (cond
                ((program 1))
                ((program 2))
                ((program 3))
                ...

    kind regards
    Bluebird1973

  9. #9
    Senior Member
    Computer Details
    ronjonp's Computer Details
    Operating System:
    Windows 10
    Using
    AutoCAD 2018
    Join Date
    Apr 2009
    Location
    Colorado
    Posts
    461

    Default

    Quote Originally Posted by Bluebird1973 View Post
    I found now a solution.


    Code:
    (progn
       (cond
          (
             (/= 0 checkPINstate)
                (progn
                   (requestPIN)
                   (cond
                    (
                      (/= checkPIN inputPIN)
                         (progn
                          (princ "\nError: bad argument pw")
                          (exit)
                          )
                    )
                   )
                )
          )
       )
    
       (if (= Prog checkProg)
          (progn
             (cond
                ((program 1))
                ((program 2))
                ((program 3))
                ...

    kind regards
    Bluebird1973
    FWIW .. this will accomplish the same thing without a messy exit.
    Code:
    ;; Assumes that your (requestpin) actually returns something
    (if (or (= 0 checkpinstate) (and (requestpin) (/= checkpin inputpin) (= prog checkprog)))
      (progn (program 1) (program 2) (program 3))
      (princ "\nError: bad argument pw")
    )

  10. #10
    Junior Member
    Using
    Architecture 2016
    Join Date
    Nov 2014
    Posts
    20

    Default

    Registered forum members do not see this ad.

    Hi ronjonp,

    Yes, you are right.
    It is really the better way.

    Thank you for the lesson!!!

    kind regards
    Bluebird1973

Similar Threads

  1. Rename Layout LISP. Need to add additional. Please Help.
    By tmelancon in forum AutoLISP, Visual LISP & DCL
    Replies: 6
    Last Post: 8th Dec 2015, 02:58 am
  2. How to get this LISP to add an additional 90 degrees to its rotate
    By msirois in forum AutoLISP, Visual LISP & DCL
    Replies: 10
    Last Post: 7th Dec 2015, 08:03 am
  3. Another Lesson Request
    By CADLee in forum Student Project Questions
    Replies: 2
    Last Post: 10th Jan 2013, 07:58 pm
  4. viiewports...i need a lesson in scale
    By ThatOne in forum AutoCAD General
    Replies: 3
    Last Post: 6th Sep 2010, 01:50 am

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts