明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1983|回复: 6

[函数] 求助高手

[复制链接]
发表于 2009-10-28 15:57:00 | 显示全部楼层 |阅读模式
本帖最后由 作者 于 2009-10-28 16:49:57 编辑

(defun sub_pel1()
  (cond 
  ((or(= xf1 "0")(= xf1 "3"))(setq e1(atof(get_tile "pe1"))))
 ((or(= xf2 "0")(= xf2 "3"))(setq e2(atof(get_tile "pe2"))))
 ((or(= xf3 "0")(= xf3 "3"))(setq e3(atof(get_tile "pe3"))))
 ((or(= xf4 "0")(= xf4 "3"))(setq e4(atof(get_tile "pe4"))))
 
 )
 (set_tile "pel1" (rtos(+ e1 e2 e3 e4)))
)

xf1、xf2、xf3、xf4为同类型的下拉列表 请问一下这样表述为什么老显示参数类型错误,

想实现当xf1至xf4下拉列表值为 0或者3时 pel1的edit_box显示 pe1+pe2+pe3+pe4的值

假如xf1值不为0或者3,xf2至xf4为0或者3时 pel1的edit_box显示  pe2+pe3+pe4的值

这样写哪里需要修改一下啊,求高手帮忙解答一下 ,谢谢

发表于 2009-10-28 16:51:00 | 显示全部楼层

將字串轉換成實數
(atof string)

引數

string

要轉換成實數的字串。

傳回值

一個實數。

範例

指令:(atof "97.1")
97.1
指令:(atof "3")
3.0
指令:(atof "3.9")

3.9

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

設定對話方塊框的值
(set_tile key value)

引數

key

指定框的字串。

value

命名要指定新值的字串 (由 value 屬性起始設定)。<================注意

傳回值

框所設定的值。

 楼主| 发表于 2009-10-28 16:55:00 | 显示全部楼层

什么意思?我如果把函数改成

(defun sub_pel1() 
 (or(= xf1 "0")(= xf1 "3")(setq e1(atof(get_tile "pe1"))))
 (or(= xf2 "0")(= xf2 "3")(setq e2(atof(get_tile "pe2"))))
 (or(= xf3 "0")(= xf3 "3")(setq e3(atof(get_tile "pe3"))))
 (or(= xf4 "0")(= xf4 "3")(setq e4(atof(get_tile "pe4"))))
 
 )
 (set_tile "pel1" (rtos(+ e1 e2 e3 e4)))
)

就不报错了,但是功能实现不了 如果e1 e2 e3 e4 中有nil是不是没办法计算啊

 楼主| 发表于 2009-10-28 16:56:00 | 显示全部楼层
龙哥能不能说明白点,我不是很明白你的意思
发表于 2009-10-28 16:59:00 | 显示全部楼层

指令: (+ 1 nil 2)
損壞的引數類型: numberp: nil
 ** 指令中斷 **

為甚麼不自己試試???

 楼主| 发表于 2009-10-28 17:03:00 | 显示全部楼层

谢谢龙哥

 楼主| 发表于 2009-10-28 17:26:00 | 显示全部楼层

(defun sub_pel1()
  (cond 
 ((or(= xf1 "0")(= xf1 "3"))(setq e1(atof(get_tile "pe1")))(setq e1 0))
 ((or(= xf2 "0")(= xf2 "3"))(setq e2(atof(get_tile "pe2")))(setq e2 0))

 ((or(= xf3 "0")(= xf3 "3"))(setq e3(atof(get_tile "pe3")))(setq e3 0))

 ((or(= xf4 "0")(= xf4 "3"))(setq e4(atof(get_tile "pe4")))(setq e4 0)) 
 )
 (set_tile "pel1" (rtos(+ e1 e2 e3 e4)))
)

为什么我把程序改成这样还是不行啊。。。

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

本版积分规则

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

GMT+8, 2024-10-1 17:18 , Processed in 0.179586 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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