乐筑天下

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

[编程交流] 包括“使用STRCAT时”

[复制链接]
rlx

21

主题

1505

帖子

1551

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
81
发表于 2022-7-5 15:53:39 | 显示全部楼层
如果您想在脚本中传递文件名或命令并使用“您将使用”命令,这完全取决于您尝试做什么
 
 
  1. (write-line "(while (= 1 (logand (getvar "cmdactive") 1))(command "Yes"))" fp)

但我的工作日已经结束了,所以在这里关门。。。我把你交给了RonjonP&rkmcswain能干的手下
回复

使用道具 举报

24

主题

1265

帖子

1028

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
362
发表于 2022-7-5 15:56:56 | 显示全部楼层
 
是的,它将在命令提示符下返回该代码,但将该代码插入其他代码中。
 
例如:
 
  1. (alert (strcat "sometext " (chr 34)  "EXTRATEXT" (chr 34)))

 
返回以下内容:
 

                               
登录/注册后可看大图
回复

使用道具 举报

18

主题

111

帖子

93

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
90
发表于 2022-7-5 16:00:43 | 显示全部楼层
嗯嗯
 
 
当我不使用变量时,我怎么会出错呢。
 
 
不要给我答案,我会想如果这个
巴德,你看到我犯了一个错误,所以我会想几分钟,看看我是否能看到你已经看到的
 
 
谢谢你的帮助
回复

使用道具 举报

18

主题

111

帖子

93

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
90
发表于 2022-7-5 16:04:28 | 显示全部楼层
@rkmcswain公司
 
 
我不是在警报中使用它,而是将其设置为变量
在AutoCAD中使用警报时,我会得到与您相同的结果,但在写入变量时,我会得到额外的/这会扰乱我的代码
回复

使用道具 举报

58

主题

3353

帖子

33

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1761
发表于 2022-7-5 16:08:11 | 显示全部楼层
你在用什么编辑器?在Vlide中很容易识别出你正在使用一个变量,即使你不是故意的。
162118mv5vmolf38mmo4rp.png
回复

使用道具 举报

66

主题

1552

帖子

1514

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
325
发表于 2022-7-5 16:09:52 | 显示全部楼层
从最简单的解释开始,得出最终结论:
 
当您有一个字符串变量时,其内容必须用双引号包装:“
示例:“这是我的字符串”
strcat函数需要多个字符串参数,以便将它们合并在一起:
  1. (strcat
  2. "First string"
  3. "Second string"
  4. "Third string"
  5. )
  6. [color="darkgreen"]; The above, condensed in one row it looks like this (which would help you to mess-up your double quotes understanding) :[/color]
  7. (strcat "First string" "Second string" "Third string")

 
现在知道了这一点,很明显,如果您试图手动添加一个“,解释器会希望您也放上结束符“来完成字符串包装,通过点击回车键,您可以看到“_>
例子:
  1. _$ "my string is
  2. "_> finished now" [color="darkgreen"]; the interpreter hints with "_> that it expects a closing "[/color]
  3. "my string is\nfinished now"

 
  1. _$ (strcat "My string
  2. ("_> " [color="darkgreen"]; the interpreter hints with "_> that it expects a closing " and a closing ')'[/color]
  3. (_> ", my next string" [color="darkgreen"]; the interpreter hints with (_> a closing ')'[/color]
  4. (_> )[color="darkgreen"]; I'll close the ), for the (strcat) function[/color]
  5. "My string\n, my next string"

 
现在,通过了解所有这些内容,关于逻辑是什么-那么如何在字符串中包含实际的“字符”?
就像Rlx告诉你的那样,你必须使用“来获得”
 
  1. (alert "Now I'll put this "string" in my double quotes")

代码中的字符串可能会让您感到困惑,但解释器会检查双引号前的“\”,然后知道他必须逐字传递它。
 
现在棘手的部分是,当您将其与strcat函数一起使用时,您必须注意如何使用“(双引号):
  1. _$ (setq MyVariable "DGRL")
  2. "DGRL"
  3. _$ (strcat "My nickname is " MyVariable " and I'm on cadtutor") [color="darkgreen"]; notice the dobule-quote separators for (strcat)[/color]
  4. "My nickname is DGRL and I'm on cadtutor"
  5. _$ (strcat "My nickname is [b][color="red"]"[/color][/b]" MyVariable "[b][color="red"]"[/color][/b] and I'm on cadtutor") [color="darkgreen"]; adding the literal quotes, notice that the dobule-quote separators for (strcat) remain the same[/color]
  6. "My nickname is [b][color="red"]"[/color][/b]DGRL[b][color="red"]"[/color][/b] and I'm on cadtutor" [color="darkgreen"]; but it still looks confusing ![/color]
  7. _$ (alert "My nickname is [b][color="red"]"[/color][/b]DGRL[b][color="red"]"[/color][/b] and I'm on cadtutor") [color="darkgreen"]; but the interpreter does his job, so when alerting it we'll be ok[/color]

 
顺便说一句,你注意到字符串“my string is finished now”中的“\n”了吗?那是什么?这是一个换行符,我刚刚按下enter键,解释器就这样翻译了它,所以它知道:
“看,n前面有,这意味着这是一个换行符,而不是‘n’字母”。
回复

使用道具 举报

24

主题

1265

帖子

1028

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
362
发表于 2022-7-5 16:12:49 | 显示全部楼层
 
你真的试过了吗,还是只是在读命令行?
我们把它分解一下
 
  1. (setq var "SAMSUNG") ;<- a string
  2. (setq str (strcat
  3.    "My TV is a " ;<- a string
  4.    (chr 34)      ;<- a string
  5.     var          ;<- a string
  6.    (chr 34)      ;<- a string
  7.               )
  8. )
  9. (progn (princ str)(princ)) ; returns
  10. ;; My TV is a "SAMSUNG"
回复

使用道具 举报

5

主题

956

帖子

963

银币

初来乍到

Rank: 1

铜币
35
发表于 2022-7-5 16:16:08 | 显示全部楼层
伙计们
 
 
这条线需要是STRCAT
 
 
规则。exe添加“HKEY\U CURRENT\U USER\Software\Autodesk\Autocad\R19.1\ACAD-D001:409\Profiles\>\ Variables”/v“SECURELOAD”/t REG\U SZ/d“1”/f
 
 
有些是“有的不是”
一个没有“被视为变量(DUH),但我正在努力使用strcat在一行中实现这一点
当把线放入变量时,它需要保持这样
 
 
所以我想要的是
 
 
(setq VAR(strcat reg.exe添加“HKEY\U CURRENT\U USER\Software\Autodesk\Autocad\R19.1\ACAD-D001:409\Profiles\>\ Variables”/v“SECURELOAD”/t reg\U SZ/d“1”/f))
 
 
键入VAR时,您将得到-->reg。exe添加“HKEY\U CURRENT\U USER\Software\Autodesk\Autocad\R19.1\ACAD-D001:409\Profiles\>\ Variables”/v“SECURELOAD”/t REG\U SZ/d“1”/f
回复

使用道具 举报

18

主题

111

帖子

93

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
90
发表于 2022-7-5 16:18:49 | 显示全部楼层

[code](setq VAR“reg.exe add”HKEY\U CURRENT\U USER\\Software\\Autodesk\\Autocad\\R19.1[url=“文件://\\ACAD-D001:409\\Profiles\”
回复

使用道具 举报

rlx

21

主题

1505

帖子

1551

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
81
发表于 2022-7-5 16:23:31 | 显示全部楼层
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-14 03:20 , Processed in 0.431215 second(s), 83 queries .

© 2020-2025 乐筑天下

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