cltcl

Discussion of other useful tools

cltcl

Postby saufesma » Wed Dec 19, 2018 9:16 pm

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
saufesma
 
Posts: 5
Joined: Tue Dec 18, 2018 1:38 am

Re: cltcl

Postby saufesma » Thu Dec 20, 2018 6:58 pm

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)))
saufesma
 
Posts: 5
Joined: Tue Dec 18, 2018 1:38 am


Return to Other Tools

Who is online

Users browsing this forum: No registered users and 1 guest

cron