明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1018|回复: 3

请教下对表的赋值问题。

[复制链接]
发表于 2009-7-7 13:41:00 | 显示全部楼层 |阅读模式

          例如首先建立个表(a b c d e f...)然后从读取的记事本里面把读取到得值(按行读取)按顺序逐一给表里的a b c d    。 。。

 也就是相当于把记事本里面的数值按行的顺序建成一个表。

求教下这样的程序该怎么写?

发表于 2009-7-7 15:05:00 | 显示全部楼层
本帖最后由 作者 于 2009-7-7 17:30:25 编辑

;;依次赋值给 a b c d e f g 不妥,假如行数超过26怎么办?
;;下面的方法是依次赋值给 *LINE_1* *LINE_2* *LINE_3* ... *LINE_N*
(defun ttt (/ file i)
(setq file "c:\\TXTFILE.txt")
(setq file (open file "r"))
(setq i 1)
(while (setq line (read-line file))
  (set (read (strcat "*LINE_" (itoa i) "*")) line)
  (setq i (1+ i))
)
(close file)
i
)
发表于 2009-7-7 16:54:00 | 显示全部楼层

(set (read (strcat "*LINE_" (itoa i) "*")) line)
再请教下版主,上面这句为什么用set 不能用setq。

(defun c:rea()
(setq file(getfiled "选择文件" "" "" 2))
  (setq ff(open datefile "r"))
  (setq i 1)
(while (setq line (read-line ff)))
  (set (read (strcat "x" (itoa i)))  line)
  (setq i (+ 1 i))
  (close file)
  )

附上我的程序帮我看下哪里有问题。

发表于 2009-7-7 17:29:00 | 显示全部楼层

(setq a 1)

=

(set 'a 1)

----------------------------------------------------

(setq a 1 b 2 c 3)

=

(mapcar 'set '(a b c) '(1 2 3))

比较一下就能看出区别

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

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-10-2 15:18 , Processed in 0.156191 second(s), 26 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表