ETk problem

Tony Rogvall tony@REDACTED
Fri Jan 21 17:06:18 CET 2000


uzturnau@REDACTED wrote:

> I noticed that the function tk:cmd(Entry, [get]) sometimes returns a
> string, and sometimes a number, depending on whether the entry field
> contains only [-0-9.] or other characters as well. I don't think this
> behaviour is very useful, but I could live with it if only I knew an
> Erlang function to test for being a number or for being a string. Is
> there such a function? Or, better still, is there a way to force
> tk:cmd(Entry, [get]) to always return a string? I want to be able to
> clear an entry, and the following function gives an error if the user
> has entered "123" (though it works fine if he has entered "xyz"):
>
> clear(Entry) ->
>   Text = tk:cmd(Entry, [get]),
>   tk:cmd(Entry, [delete, 0, string:len(Text)]).
>
> Thanks for any help,
>
> Pawel Turnau

The 'rcmd' is used when the uninterpreted value is needed. In this case
this means:
        Text = tk:rcmd(Entry, [get])

This is of course a hack, but as soon as tcl/tk has internal data types
on EVERYTHING (except for string) then it's time to do something about
it.

BTW

To delete all characters in the entry use:
        tk:cmd(Entry, [delete, 0, 'end'])
(one liner :-)


/Tony





More information about the erlang-questions mailing list