Hello there
Today I try cltkl, looks fine when you run following code
(in-package "CL-USER")
(defun window (&KEY (INTERPRETER CLTCL:*INTERPRETER*) OPTIONS)
"Runs the Common Lisp window."
(cltcl:event-loop (viewer)
:interpreter interpreter
:options options))
(defun viewer ()
#TCL[
package require Tk
namespace import ::cltcl::callLisp
label .label1 -text "Sum of"
entry .a -width 6 -relief sunken -textvariable a
entry .b -width 6 -relief sunken -textvariable b
label .label2 -text "Result"
label .s -textvariable s
pack .label1 .a .b .label2 .s -side left -padx 1m -pady 2m
bind .a <Return> {set s [callLisp sum $a $b]}
bind .b <Return> {set s [callLisp sum $a $b]}])
(defun sum (a b)
(+ a b))
when I type in number 1 in entry and press Enter this happens
The value
"1"
is not of type
NUMBER
[Condition of type TYPE-ERROR]
tcl treats everything like strings but how to convert it to number for function sum, any ideas.
Regards
cltcl
Re: cltcl
Hello there,
Problem with string solved and successfully.
(in-package "CL-USER")
(defun window (&KEY (INTERPRETER CLTCL:*INTERPRETER*) OPTIONS)
"Runs the Common Lisp window."
(cltcl:event-loop (viewer)
:interpreter interpreter
:options options))
(defun viewer ()
#TCL[
package require Tk
namespace import ::cltcl::callLisp
label .label1 -text "Sum of"
entry .a -width 6 -relief sunken -textvariable a
entry .b -width 6 -relief sunken -textvariable b
label .label2 -text "Result"
label .s -textvariable s
pack .label1 .a .b .label2 .s -side left -padx 1m -pady 2m
bind .a <Return> {set s [callLisp sum $a $b]}
bind .b <Return> {set s [callLisp sum $a $b]}])
(defun string-to-number (n)
(car (list (read-from-string n))))
(defun sum (a b)
(+ (string-to-number a) (string-to-number b)))
Problem with string solved and successfully.
(in-package "CL-USER")
(defun window (&KEY (INTERPRETER CLTCL:*INTERPRETER*) OPTIONS)
"Runs the Common Lisp window."
(cltcl:event-loop (viewer)
:interpreter interpreter
:options options))
(defun viewer ()
#TCL[
package require Tk
namespace import ::cltcl::callLisp
label .label1 -text "Sum of"
entry .a -width 6 -relief sunken -textvariable a
entry .b -width 6 -relief sunken -textvariable b
label .label2 -text "Result"
label .s -textvariable s
pack .label1 .a .b .label2 .s -side left -padx 1m -pady 2m
bind .a <Return> {set s [callLisp sum $a $b]}
bind .b <Return> {set s [callLisp sum $a $b]}])
(defun string-to-number (n)
(car (list (read-from-string n))))
(defun sum (a b)
(+ (string-to-number a) (string-to-number b)))