[plt-scheme] Re: Text-contents to a function variable

From: Stephen Bloch (sbloch at adelphi.edu)
Date: Wed Jan 13 19:16:45 EST 2010

On Jan 13, 2010, at 3:21 PM, Avi wrote:

> Stephen, you are right about the defining H as a scheme variable to
> have the value of 1.
> I'm going to answer as clearly as I can so that there is no confusion.
> If anything that is not one of the scheme variables that was defined
> before hand a message will pop up explaining the exact way (for
> simplicity's sake) to use the text-field.

What is "before hand"?  Before you wrote the function that checks the  
text field, extracts its contents, looks up the numeric value of that  
variable, and passes the result to some function?  Or before that  
function is called?  Does it include any Scheme variables that might  
be defined (as parameters or locals) IN that function?

Whatever you decide this means, you'll clearly need a way to find out  
whether there is a variable with a specified name, so that if there  
isn't, you can produce an error message.  That can be done, but it's  
probably easier if your program maintains its own mapping of names to  
values than if you try to use Scheme variables for this purpose.

> (Do you think a giant conditional is the way to go?)

Almost certainly not :-)

> I do not believe that the variables will clash because the value that
> we get from the scheme variables will be used for a program that
> checks certain combinations. Any instance where the entered value is
> not the same, would bring up the error message explaining to check
> what you wrote.

But what if some local variable happens to have a value which would  
be a legal input to that program?

> Would you like to see what I have for my overall code
> so far so you can better understand my problem?

Actually, no :-)

Stephen Bloch
sbloch at adelphi.edu





Posted on the users mailing list.