借助数据库产生随机数
(defun $round$ (n-min n-max ws / rnds sjs sql strs sjs);n-min 最小值
;n-max 最大值
;ws 小数位数
(setq n-min (vl-catch-all-apply 'vl-princ-to-string (list n-min)))
(setq n-max (vl-catch-all-apply 'vl-princ-to-string (list n-max)))
(setq ws (vl-catch-all-apply 'vl-princ-to-string (list ws)))
(if (vl-catch-all-error-p n-min)
(setq n-min nil)
)
(if (vl-catch-all-error-p n-max)
(setq n-max nil)
)
(if (vl-catch-all-error-p ws)
(setq ws "1")
)
(if (and n-min n-max (> n-max n-min))
(progn
(setq rnds (mapcar (function
(lambda (a)
(strcat
(strcat "ROUND("
n-min
" + RAND() * ("
n-max
" - "
n-min
"), "ws") AS rand"
(itoa a)
)
)
)
)
(list 1 2 3 4 5)
)
)
(setq strs (mapcar (function (lambda (a) (strcat a ",")))
(reverse (cdr (reverse rnds)))
)
)
(setq strs (append strs (list (last rnds))))
(setq sql
(apply 'strcat strs)
)
(setq sql (strcat "select " sql))
(setq sjs
(car
($http-server$
(list
(cons "IP" (getenv "数据库地址"))
(cons "端口" ($locport$))
(cons "接口" ($fu-wu-qi-jie-kou$ "查询表"))
;(cons "数据库路径" "C:\\ZXCAD.DB")
(cons
"报文头"
(list (cons "Client-Auth" (getenv "ComputerName")))
)
(cons "Sql" SQL)
(cons "http方法" "POST")
(cons "返回格式" "db")
)
)
)
)
(setq sjs(mapcar 'cdr sjs))
)
)
sjs
)
很好,可以配个案例。; 错误: no function definition: $LOCPORT$ 拉出意大利炮打蚊子 我爱lisp 发表于 2024-4-1 16:36
很好,可以配个案例。; 错误: no function definition: $LOCPORT$
加载dbo.vlx即可 学到了很有用
页:
[1]