Author Topic: How to work user input for this program  (Read 7124 times)

0 Members and 1 Guest are viewing this topic.

Adesu

  • Guest
How to work user input for this program
« on: March 17, 2005, 12:54:20 AM »
The scenario for this program,is if in your area drawing there are string,as like 10 20 30 40 .....etc,now you please click 10 20 etc,then the program would ask,what you want to do ( "Select Add Subtracts Divides Multiply"),then ask again where you would put for text in area drawing,the result final would display as gave them input,but in "opt" this program can't work,anyones can help how to solve this script,thanks. :(

Code: [Select]
; cco is stand for create count object
;        Design by Ade Suharna <mteybid@yuasabattery.co.id>
;        15 March 2005
;        Program no.213/03/2005
;        Edit by
(defun c:cco (/ ss ssl cnt ssn opt ttl)
  (prompt "\nCLICK OBJECT TO BE EVALUATION")
  (setq ss (ssget))
  (setq ssl (sslength ss))
  (setq cnt 0)
  (repeat ssl
    (setq ssn (ssname ss cnt))
    (setq sse (entget ssn))
    (setq as1 (atoi (cdr (assoc 1 sse))))  
    (set (read (strcat "ss" (itoa cnt))) as1)
    )
(prompt "Select Add Subtracts Divides Multiply")
(initget " A S D M ")
(setq opt (getkword "\nCHOOSE ONES <A/S/D/M>: "))
(cond ((eq opt "A")(setq opt +))
      ((eq opt "S")(setq opt -))
      ((eq opt "D")(setq opt /))
      ((eq opt "M")(setq opt *))
      )
(if ss
  (cond
    ((eq ssl 1)(alert "\nInvalid selected,not enough to evaluation"))
    ((eq ssl 2)(setq ttl (opt ss0 ss1)))
    ((eq ssl 3)(setq ttl (opt ss0 ss1 ss2)))
    ((eq ssl 4)(setq ttl (opt ss0 ss1 ss2 ss3)))
    ((eq ssl 5)(setq ttl (opt ss0 ss1 ss2 ss3 ss4)))
    ((eq ssl 6)(setq ttl (opt ss0 ss1 ss2 ss3 ss4 ss5)))
    ((eq ssl 7)(setq ttl (opt ss0 ss1 ss2 ss3 ss4 ss5 ss6)))
    ((eq ssl 8)(setq ttl (opt ss0 ss1 ss2 ss3 ss4 ss5 ss6 ss7)))
    ((eq ssl 9)(setq ttl (opt ss0 ss1 ss2 ss3 ss4 ss5 ss6 ss7 ss8)))
    ((eq ssl 10)(setq ttl (opt ss0 ss1 ss2 ss3 ss4 ss5 ss6 ss7 ss8 ss9)))
    ((> ssl 10)(alert "\nSorry your selected,too over"))
    )
  )
  (setq loc (getpoint "\nCLICK LOCATION FOR RESULT OBJECT: "))
  (setq hei 1)
  (command "_text" loc hei "" ttl "")
  (princ ttl)
  )

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
How to work user input for this program
« Reply #1 on: March 17, 2005, 01:04:23 AM »
Adesu,

Do you know how to use the debugger in the Visual Lisp IDE ?
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>
How to work user input for this program
« Reply #2 on: March 17, 2005, 01:11:26 AM »
It would help anyone testing or using this if this line

(prompt "\nCLICK OBJECT TO BE EVALUATION")

read

(prompt "\nSelect TEXT to be evaluated.")



... I assume it's text because of this : (assoc 1 sse)  

Is it meant to select text ??

added : and is the value meant to be a string representation of an integer
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>
How to work user input for this program
« Reply #3 on: March 17, 2005, 01:44:02 AM »
I have made some serious assumptions here :


look for these markers
;; added kwb
;; revised kwb

Particularly these :
The cnt variable for the ssNo  was not being incremented in the repeat loop
;; revised kwb : quoted the additive and multiplicative symbols

;; revised kwb : changed (setq ttl (opt ....)
;; to ((eval opt) ss0 ss1 ... ... ... )))

Code: [Select]

;;revised as noted : kwb@theSwamp

(defun c:cco (/ ss ssl cnt ssn opt ttl)
  ;; revised kwb
  ;;(prompt "\nCLICK OBJECT TO BE EVALUATION")
  (prompt "\nSelect TEXT to be evaluated.")
  ;; /revised kwb

  (setq ss  (ssget)
        ssl (sslength ss)
        cnt 0
  )
  (repeat ssl
    (setq ssn (ssname ss cnt)
          sse (entget ssn)
          as1 (atoi (cdr (assoc 1 sse)))
    )
    (set (read (strcat "ss" (itoa cnt))) as1)
   
    ;; added kwb
    (setq cnt (1+ cnt))
    ;;/added
  )
  (prompt "Select Add Subtracts Divides Multiply")
  (initget " A S D M ")
  (setq opt (getkword "\nCHOOSE ONES <A/S/D/M>: "))
 
  ;; revised kwb : quoted the additive and multiplicative symbols
  (cond ((eq opt "A") (setq opt '+))
        ((eq opt "S") (setq opt '-))
        ((eq opt "D") (setq opt '/))
        ((eq opt "M") (setq opt '*))
  )  
  ;; /revised kwb :

 
  (if ss
    ;; revised kwb : changed (setq ttl (opt ....)
    ;; to ((eval opt) ss0 ss1 ... ... ... )))
    (cond
      ((eq ssl 1) (alert "\nInvalid selected,not enough to evaluation"))
      ((eq ssl 2) (setq ttl ((eval opt) ss0 ss1)))
      ((eq ssl 3) (setq ttl ((eval opt) ss0 ss1 ss2)))
      ((eq ssl 4) (setq ttl ((eval opt) ss0 ss1 ss2 ss3)))
      ((eq ssl 5) (setq ttl ((eval opt) ss0 ss1 ss2 ss3 ss4)))
      ((eq ssl 6) (setq ttl ((eval opt) ss0 ss1 ss2 ss3 ss4 ss5)))
      ((eq ssl 7) (setq ttl ((eval opt) ss0 ss1 ss2 ss3 ss4 ss5 ss6)))
      ((eq ssl 8) (setq ttl ((eval opt) ss0 ss1 ss2 ss3 ss4 ss5 ss6 ss7)))
      ((eq ssl 9) (setq ttl ((eval opt) ss0 ss1 ss2 ss3 ss4 ss5 ss6 ss7 ss8)))
      ((eq ssl 10)(setq ttl ((eval opt) ss0 ss1 ss2 ss3 ss4 ss5 ss6 ss7 ss8 ss9)))
      ((> ssl 10) (alert "\nSorry your selected,too over"))
    )
  )
  ;; /revised kwb :
 
  ;; revised kwb
;;;  (setq loc (getpoint "\nCLICK LOCATION FOR RESULT OBJECT: ")
;;;        hei 1
;;;  )
  (setq loc (getpoint "\nSelect Location for New Text : ")
        hei 1
  )  
  ;; /revised kwb

  ;; revised kwb
;;;  (command "_text" loc hei "" ttl "" "")
  (command "_text" loc hei "" ttl 0)
  ;; /revised kwb
 
  (princ ttl)
  (princ)
)
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>
How to work user input for this program
« Reply #4 on: March 17, 2005, 02:00:11 AM »
.. and just a courtesy note .. can you please add code tags to your posts, they make the code more readable .. well for me anyway.
If you dont know how, please ask.
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.

Adesu

  • Guest
How to work user input for this program
« Reply #5 on: March 17, 2005, 03:51:44 AM »
Quote from: Kerry Brown
.. and just a courtesy note .. can you please add code tags to your posts, thet make the code readable .. well for me anyway.
If you dont know how, please ask.


Hi Kerry Brown,after your revised,that code become work,perfect !!,thanks a lot for your suggest.
I am not understanding what do you mean "can you please add code tags to your posts, thet make the code readable",can you more detail for this your argument,sorry for rather stupid my question

Mark

  • Custom Title
  • Seagull
  • Posts: 28753
How to work user input for this program
« Reply #6 on: March 17, 2005, 04:06:06 AM »
Quote from: Adesu
I am not understanding what do you mean "can you please add code tags to your posts, thet make the code readable",can you more detail for this your argument,sorry for rather stupid my question

Have a look here Adesu. http://www.theswamp.org/phpBB2/faq.php?mode=bbcode#5
TheSwamp.org  (serving the CAD community since 2003)

Adesu

  • Guest
How to work user input for this program
« Reply #7 on: March 17, 2005, 04:22:39 AM »
Quote from: Mark Thomas
Quote from: Adesu
I am not understanding what do you mean "can you please add code tags to your posts, thet make the code readable",can you more detail for this your argument,sorry for rather stupid my question

Have a look here Adesu. http://www.theswamp.org/phpBB2/faq.php?mode=bbcode#5


Hi Mark ,thanks for your suggest,sorry for post before,because I new in this forum,especialy for posting.
by the way,are you not yet sleeping for this time ?

Mark

  • Custom Title
  • Seagull
  • Posts: 28753
How to work user input for this program
« Reply #8 on: March 17, 2005, 04:56:29 AM »
Quote from: Adesu
Hi Mark ,thanks for your suggest,sorry for post before,because I new in this forum,especialy for posting.
by the way,are you not yet sleeping for this time ?

Nope, not sleeping.  :cry:   It is going to be a long day!!
TheSwamp.org  (serving the CAD community since 2003)

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
How to work user input for this program
« Reply #9 on: March 17, 2005, 07:01:49 AM »
I feel your pain brother, sorry to hear it.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
How to work user input for this program
« Reply #10 on: March 17, 2005, 08:12:09 AM »
Quote from: Adesu
>>> ,after your revised,that code become work,perfect !!,thanks a lot for your suggest. <<<<


You're welcome.

Good to see you got the code tags working too. :)

Stay well,
Kerry
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.

daron

  • Guest
How to work user input for this program
« Reply #11 on: March 17, 2005, 08:14:22 AM »
Oops! I edited his post and added the code tags, so it could be read.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
How to work user input for this program
« Reply #12 on: March 17, 2005, 08:37:37 AM »
Perhaps view this instruction Adesu.

Cheers.

:)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
How to work user input for this program
« Reply #13 on: March 17, 2005, 08:37:49 AM »
most excellent Daron.

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.

Adesu

  • Guest
How to work user input for this program
« Reply #14 on: March 17, 2005, 07:58:43 PM »
Quote from: MP
Perhaps view this instruction Adesu.

Cheers.

:)


Hi Daron and MP,thanks very much for your tutorial and suggest,it mean if we send thread ,as like this
Code: [Select]

(defun.....bla..bla...
.......
(princ)
)

sorry if my question too stupid,what function your add [code] at begin and finish text?

Adesu

  • Guest
How to work user input for this program
« Reply #15 on: March 17, 2005, 08:04:45 PM »
Quote from: Kerry Brown
Adesu,

Do you know how to use the debugger in the Visual Lisp IDE ?


Hi Kerry,yes I am not familiar with  the debugger ,and never use it,would you give me how to use it,thanks for your spend time.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
How to work user input for this program
« Reply #16 on: March 17, 2005, 08:18:55 PM »
From the Visual Lisp IDE

Select Help from The Menu

Select Visual Lisp Help Topics

When the help file opens select AutoLisp Tutorial.

Read the first 3 Chapters.


That will save us both a lot of aggravation.
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.

Adesu

  • Guest
How to work user input for this program
« Reply #17 on: March 17, 2005, 10:42:38 PM »
Quote from: Kerry Brown
From the Visual Lisp IDE
Select Help from The Menu
Select Visual Lisp Help Topics
When the help file opens select AutoLisp Tutorial.
Read the first 3 Chapters.
That will save us both a lot of aggravation.




On Visual Lisp editor I put a "(setq ss (ssget "x" '((0 . "LINE"))))",and then
I am trying to how you show me ,and I attempt to tested it,now I sort and hightlite "(setq ss (ssget "x" '((0 . "LINE"))))",and then
1.click debug on file menu
2.click add watch...
3.displayed Add watch dialog box with contain "(setq ss   (ssget "x" '((0 . "LINE"))))"
4.click Ok
5.displayed watch dialog box with contain;
  *Last-Value*=
  (setq ss (sget "x" (quote ((0...=<selec....
6.sort or highlite "(setq ss (sget "x" (quote ((0...=<selec....",and then double click
7.displayed Inspeck :PICKSET dialog box with contain
   at first line <Selection set :28>
   at second line
  • <LINE>(Entity name : 147fd88)

8. sort again or highlite and double click again
9.displayed Acad Line dialog box with contain
  at first line <Entity name : 147fd88>
  at second line {handle} "49" {layer} "0" ...etc

I usually copy clicp "(setq ss (ssget "x" '((0 . "LINE"))))" to Visual Lisp Console and then hit "enter" as like this

_$ (setq ss (ssget "x" '((0 . "LINE"))))
<Selection set: 5c>
_$

How comment you ,is it as you suggest ?