[英]How to obtain user input (as a number) to be applied to an equation
I am trying to program a scenario where a user will input two pieces of information, a 6-minute walk distance in meters at baseline (6MWDbaseline) and then a 6-minute walk distance in meters at 24-weeks (6MWD24weeks).我正在尝试编写一个场景,用户将输入两条信息,基线时 6 分钟的步行距离(6MWDbaseline),然后是 24 周时的 6 分钟步行距离(6MWD24weeks)。 I want the user to supply those pieces of information rather than me asserting them within the program.
我希望用户提供这些信息,而不是我在程序中声明它们。 Once those numbers are entered they need to be applied to the equation: (6MWD24weeks - 6MWDbaseline) = x and then to this equation: x / 6MWDbaseline = y Where, if y >/= 0.2 then the program will denote success.
输入这些数字后,需要将它们应用于等式:(6MWD24weeks - 6MWDbaseline) = x,然后应用于此等式:x / 6MWDbaseline = y 其中,如果 y >/= 0.2,则程序将表示成功。 If y is between 0.05-0.19 then the program will denote clinical improvement.
如果 y 在 0.05-0.19 之间,则该程序将表示临床改善。 If y is <0.049 then the program will denote failure.
如果 y <0.049,则程序将表示失败。
I get an error early on in my script testing, before I can even try to program my 'clinical improvement' or 'failure' lines, that my user inputs of 6MWDbaseline and 6MWD24weeks are expected to be integers or floats.我在脚本测试的早期就遇到了一个错误,在我什至可以尝试对我的“临床改进”或“失败”行进行编程之前,我的 6MWDbaseline 和 6MWD24weeks 的用户输入应该是整数或浮点数。 Any guidance on what I might be doing wrong?
关于我可能做错了什么的任何指导?
CLIPS> (clear)
CLIPS> (defrule MAIN::6WMDbaseline-check
=>
(printout t "What is the distance on the baseline 6-minute walk distance in meters?" crlf)
(assert (6MWDbaseline (read))))
CLIPS> (defrule MAIN::6MWD24week-check
=>
(printout t "What is the distance on the 24-week 6-minute walk distance in meters?" crlf)
(assert (6MWD24week (read))))
CLIPS> (defrule MAIN::success-decision
(6MWDbaseline ?6MWDbaseline)
(6MWD24week ?6MWD24week)
=>
(if (- 6MWD24week 6MWDbaseline = x) and (/ x 6MWDbaseline >0.2))
then
(printout t "Primary outcome met, greater than 20% improvement in 6-minute walk distance" crlf))
[ARGACCES2] Function '-' expected argument #1 to be of type integer or float.
ERROR:
(defrule MAIN::success-decision
(6MWDbaseline ? 6MWDbaseline)
(6MWD24week ? 6MWD24week)
=>
(if (- 6MWD24week 6MWDbaseline = x)
CLIPS>
Thanks in advance for any assistance!在此先感谢您的帮助! Marnie
玛妮
Use the bind function to assign values to variables in the actions of a rule.使用绑定function 为规则操作中的变量赋值。 In addition, variable names must begin with a letter.
此外,变量名必须以字母开头。
CLIPS (6.4 2/9/21)
CLIPS>
(defrule 6WMDbaseline-check
=>
(printout t "What is the distance on the baseline 6-minute walk distance in meters?" crlf)
(assert (6MWDbaseline (read))))
CLIPS>
(defrule 6MWD24week-check
=>
(printout t "What is the distance on the 24-week 6-minute walk distance in meters?" crlf)
(assert (6MWD24week (read))))
CLIPS>
(defrule success-decision
(6MWDbaseline ?baseline)
(6MWD24week ?week24)
=>
(bind ?x (- ?week24 ?baseline))
(bind ?y (/ ?x ?baseline))
(switch TRUE
(case (> ?y 0.2)
then
(printout t "Primary outcome met, greater than 20% improvement in 6-minute walk distance" crlf))
(case (and (>= ?y 0.05) (<= ?y 0.2))
then
(printout t "Primary outcome improved, between 5% and 20% improvement in 6-minute walk distance" crlf))
(case (< ?y 0.05)
then
(printout t "Primary outcome failed, less than 5% improvement in 6-minute walk distance" crlf))))
CLIPS> (reset)
CLIPS> (run)
What is the distance on the baseline 6-minute walk distance in meters?
100
What is the distance on the 24-week 6-minute walk distance in meters?
121
Primary outcome met, greater than 20% improvement in 6-minute walk distance
CLIPS> (reset)
CLIPS> (run)
What is the distance on the baseline 6-minute walk distance in meters?
100
What is the distance on the 24-week 6-minute walk distance in meters?
115
Primary outcome improved, between 5% and 20% improvement in 6-minute walk distance
CLIPS> (reset)
CLIPS> (run)
What is the distance on the baseline 6-minute walk distance in meters?
100
What is the distance on the 24-week 6-minute walk distance in meters?
104
Primary outcome failed, less than 5% improvement in 6-minute walk distance
CLIPS>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.