乐筑天下

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

[编程交流] default values - help, somethi

[复制链接]

5

主题

23

帖子

18

银币

初来乍到

Rank: 1

铜币
25
发表于 2022-7-6 11:13:20 | 显示全部楼层 |阅读模式
Hi,
i just found out about auto lisp a month ago and got interested on it. so i'm really a novice when it comes to making lisp routine. recently, there was this "tip" on making a default value when making a routine and this serves as my pattern. but something is. wrong. it's keeping the string value only once, just to show what is the current value but when you press enter, it's no longer there when you repeat the command unlike in the case of integer, value remains there always.
below is the routine sample.tnx
code:
  1. (defun c:prog1 (/ a b)   (if (= gv nil)       (setq gv "NAME")   );end if   (princ "\Member  ")   (setq a (strcase(getstring)))   (if (= gv1 nil)       (setq gv1 0)   );end if         (princ "\Quantity  ")   (setq b (getint))     (if (= b nil)       (setq b gv1)   );end if   (setq gv a)   (princ "\nThe Member is ")   (princ a)   (setq gv1 b)   (princ "\nThe Quantity is ")   (princ b)    (princ));defun
回复

使用道具 举报

0

主题

127

帖子

130

银币

限制会员

铜币
-2
发表于 2022-7-6 11:45:55 | 显示全部楼层
Perhaps try something like ;
This need further enhancement to be production code, but will get you started in understanding the process.
 
  1. (defun c:prog1 (/ tmp) ;; set global variables (or gv (setq gv "NAME")) (or gv1 (setq gv1 0)) ;; (if (/= "" (setq tmp (strcase (getstring (strcat "\nMember  ")))))   (setq gv tmp) ) ;; (if (setq tmp (getint (strcat "\nQuantity  ")))   (setq gv1 tmp) ) ;; (princ "\nThe Member is ") (princ gv) (princ "\nThe Quantity is ") (princ (itoa gv1)) (princ))
回复

使用道具 举报

5

主题

23

帖子

18

银币

初来乍到

Rank: 1

铜币
25
发表于 2022-7-6 12:19:11 | 显示全部楼层
Kerry,
 
that's a very quick response, thanks a lot.
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-6 11:20 , Processed in 0.749611 second(s), 69 queries .

© 2020-2025 乐筑天下

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