乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 19|回复: 19

[编程交流] Multiple-choice questions

[复制链接]

4

主题

22

帖子

18

银币

初来乍到

Rank: 1

铜币
20
发表于 2022-7-6 06:10:26 | 显示全部楼层 |阅读模式
Hello everybody, there are a long time i don't come there. I hope you'll understand because i'm french and so.
 
I would like to make in autolisp a MCQ for my program.  To make that, here is my algorithm:
 
ask the question  : accept you this implantation? [ Yes / No ]  
 
(there i want storing the value in a variable)
 
         if the answer is No, what do you want to change? [ tracking / Shift / first light fitting / Spacing / Gap ]
 
(there i want storing the value in a variable)
             if the answer is tracking  > do that
             if the answer is Shift > do that
             if the answer is the first light fitting  > do that
             if the answer is spacing  > do that
             if the answer is Gap > do that
 
 
         if the answer is Yes, continue the program
 
Actually this MCQ will be in "while fonction" and i would like to have the opportunity to keep several values.
 
To know: each case is a function, first of all the program set all of these cases
and after this MCQ will be into this "while" function to ask customer if it is okay. I want to make that to have a possibility to come back at the desired step (steps)
 
 
Thank you everybody !
回复

使用道具 举报

5

主题

1334

帖子

1410

银币

限制会员

铜币
-20
发表于 2022-7-6 06:16:07 | 显示全部楼层
  1. (defun c:MCQ ( / tracking shift first-light-fitting spacing gap loop ch change ) (defun tracking ( / )   ... ) (defun shift ( / )   ... ) (defun first-light-fitting ( / )   ... ) (defun spacing ( / )   ... ) (defun gap ( / )   ... ) (setq loop T) (while loop   (initget "Yes No")   (setq ch (getkword "\nAccept this implantation ? [ Yes / No ]  : "))   (if (or (eq ch nil) (eq ch "No"))     (progn       (initget 1 "Tracking Shift First-light-fitting Spacing Gap")       (setq change (getkword "\nWhat do you want to change? [ [T]racking / [s]hift / [F]irst-light-fitting / [sP]acing / [G]ap ] : "))       (cond         ( (eq change "Tracking")           (tracking)         )         ( (eq change "Shift")           (shift)         )         ( (eq change "First-light-fitting")           (first-light-fitting)         )         ( (eq change "Spacing")           (spacing)         )         ( (eq change "Gap")           (gap)         )       );end cond       (setq loop T)     );end progn     (setq loop nil)   );end if );end while ... (princ));end defun MCQ(prompt "\nInvoke with : MCQ")(princ)
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 06:17:55 | 显示全部楼层
I would code the loop in the following way:
  1. (defun c:test ( / ans )   (initget "Yes No")   (if (/= "Yes" (getkword "\nAccept this implantation? [Yes/No] : "))       (while           (progn (initget "Tracking Shift First SPacing Gap")               (setq ans (getkword "\nChange [Tracking/Shift/First light fitting/SPacing/Gap] : "))           )           (cond               (   (= ans "Tracking")                   (princ "\nTracking selected.")               )               (   (= ans "Shift")                   (princ "\nShift selected.")               )               (   (= ans "First")                   (princ "\nFirst light fitting selected.")               )               (   (= ans "SPacing")                   (princ "\nSpacing selected.")               )               (   (princ "\nGap selected."))           )       )   )   (princ "\nContinue with program...")   (princ))
回复

使用道具 举报

4

主题

22

帖子

18

银币

初来乍到

Rank: 1

铜币
20
发表于 2022-7-6 06:21:28 | 显示全部楼层
Thank you very much Marko! it's very nice ! So , i have just some questions for you, i don't understand some things like why the "(setq loop T)" it's again there after the "end cond" ? And  since the line "(princ)" included, i don't understand  is the use ?
 
I would like to add two things :
 
The first : Each time that the customer make this choice for example Spacing , i would like to erase the drawing that the program have made ONLY, not  all of the  drawing plan.
The second : Is to tell if the program it's ok we can continue the program
 
And one thing important is , there are a function just after " (defun gap ( / )...)" it's the function  who draw the drawing
 
 
 
Thank you soo much
回复

使用道具 举报

4

主题

22

帖子

18

银币

初来乍到

Rank: 1

铜币
20
发表于 2022-7-6 06:26:09 | 显示全部楼层
Thank you Lee Mac !  both of your program are good for me but i would like to have a possibility to put inside the "cond" function one test with several results , it's possible or no?
 
 
Thank you soo much.
回复

使用道具 举报

2

主题

389

帖子

387

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-6 06:26:30 | 显示全部楼层
mathieucraveiro, have you already written the other functions (defuns) that will be the main part of this program?
 
What marko_ribar and Lee Mac showed you were the part you asked for, and yes, these will allow calls to other functions as marko_ribar shows.  They also show that the program can continue.
 
As for princ by itself, it's just a quiet way to end the routine, without printing something extra to the screen at the end, such as "nil".
 
As for loop being set to T or nil, this is just the control variable to keep the while loop going or cause it to finish.
 
As for erasing the objects the program has created, just save the name of the last one using entlast. Do this before your program creates anything; then you can step through from there and delete all the new objects.
 
As for the gap defun, it was not clear to me what you were trying to say.  Are you saying it is written or needs to be written or what?
回复

使用道具 举报

4

主题

22

帖子

18

银币

初来乍到

Rank: 1

铜币
20
发表于 2022-7-6 06:31:44 | 显示全部楼层
Hello neophoible and thank you for your answer i understand better now about these functions. Actually it's not a function "gap" but the function just after "gap" who permit to draw, it's not done again . ThaNK YOU
回复

使用道具 举报

2

主题

389

帖子

387

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-6 06:35:19 | 显示全部楼层
You are welcome.  Hope you get everything worked out now.
回复

使用道具 举报

4

主题

22

帖子

18

银币

初来乍到

Rank: 1

铜币
20
发表于 2022-7-6 06:37:56 | 显示全部楼层
My program it's not finished but, it's a pleasure to continue when there are some people  to help you when you are blocked   ! Have a good day !
回复

使用道具 举报

4

主题

22

帖子

18

银币

初来乍到

Rank: 1

铜币
20
发表于 2022-7-6 06:40:29 | 显示全部楼层
Hello Everybody , i need to have some help because i would like to change the color of one entity polylign . First of all with an example :
 
  1. (defun c:essai () (setq pt1 (getpoint "\n first point ")) (setq pt2 (getpoint "\n second point ")) (command "polylign" pt1 pt2 "") (setq entCouleur (entget (entlast))) (setq essai(subst '(62 . 2) '(62 . 1) entCouleur)) )
 
I thinking to use the "subst" function to remplace the old color by the new color.
 
The  replacement into the list it's done but the entity polylign stay with the first color. I don't know why?
 
And after, i would like to tell at the programm to replace the color of the polylign even if the first color isn't inform.
 
 
Thank you
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-10 18:49 , Processed in 1.022992 second(s), 72 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表