乐筑天下

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

[编程交流] 关于ATOF的问题

[复制链接]

23

主题

102

帖子

79

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
115
发表于 2022-7-6 08:30:57 | 显示全部楼层 |阅读模式
  1. (action_tile
  2.    "accept"                                                ;if O.K. pressed
  3.    (strcat                                                ;string 'em together
  4.      "(progn
  5.      [color="red"] (setq SIZ (atof (get_tile "selections")))"[/color]        ;get list selection
  6.      " (done_dialog)(setq userclick T))"                ;close dialog, set flag
  7.    );strcat
  8. );action tile
  9. (start_dialog)                                        ;start dialog
  10. (unload_dialog dcl_id)                                ;unload
  11.   (if userclick                                        ;check O.K. was selected
  12.    (progn
  13.      [color="red"](setq SIZ (fix SIZ))        [/color]                        ;convert to integer;
  14.     [color="red"] (setq SIZ (nth SIZ NAMES))[/color]                        ;get the size
  15.    );progn
  16. );if userclick
  17. (princ)

 
你好,老虎
 
我被困在这里,这个教程是从下面的链接。平铺“选择”中的If值
是“M8”,为什么atof函数会处理它。http://www.afralisp.net/dialog-control-language/tutorials/dialog-boxes-and-autolisp-part-2.php
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 09:10:44 | 显示全部楼层
由于“selections”磁贴是列表磁贴,(适用于list\u box/popup\u list),get\u磁贴返回一个字符串,其中包含所选项目的从零开始的索引。作者使用atof函数将该字符串转换为实数,然后使用fix将其转换为整数。如果我在写它,我会去掉中间人,使用atoi直接转换成整数。
 
回复

使用道具 举报

23

主题

102

帖子

79

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
115
发表于 2022-7-6 09:28:34 | 显示全部楼层
谢谢你的回复。
,在教程中,列表中的一个元素是“M10”,(如果我在这个(setq-SIZ(fix-SIZ))中的两行之后插入“M10”,则atof(其中)返回“M10”)。
 
atof-此函数将字符串更改为实数。
 
  1.         Syntax : (atof string)
  2.            string - any valid string.
  3.                 (atof "345") returns 345.0
  4.                 (atof "345.9") returns 345.9
  5.                 (atof 345) returns "Error: Bad Argument Type"   [345 is a number, not a string]
  6.                 (atof 345.9) returns "Error: Bad Argument Type"   [345.9 is a number, not a string]
  7.                 (atof "-345") returns -345.0
  8.                 (atof "-345.9") returns -345.9
  9.                 (atof "345JEFF49") returns 345.0
  10.                 (atof "JEFF49") returns 0.0

我也看了这里。。。
如果它转换成实数,那么输出为什么是字符串。我相信李的回答完全涵盖了这个问题。。。但是它还没有点击
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 09:36:22 | 显示全部楼层
重读我的帖子-对于列表互动程序,get\u tile返回所选项目的索引。
 
因此,如果选择了第一个项目,get\u tile返回“0”,如果选择了第二个项目,则返回“1”等。
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-7 09:05 , Processed in 0.399053 second(s), 60 queries .

© 2020-2025 乐筑天下

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