----- Original Message ----- 
From: Armin Wappenschmidt <[EMAIL PROTECTED]>
Sent: Tuesday, June 27, 2000 10:50 AM
Subject: [Zope] range with variables

> Hi all,
> I've a problem using the following dtml construct:
> <dtml-let start=Variable_from_Formular> # <-- that's the problem!!!!!!
> <dtml-let stop="100">
> <dtml-let period="5">
>    <dtml-in "_.range(start,stop,period)">
>       <dtml-comment> do something </dtml-comment>
>    </dtml-in>
> </dtml-let>
> </dtml-let>
> </dtml-let>
> How can I set the variable "start" from a user given input?

You can call
or you can do this bay a usual FORM
<INPUT TYPE="TEXT" NAME="startindex">

The problem is that in both cases the `startindex' is a string, 
you have tu convert it to int.

<dtml-call "REQUEST.set('start_int',_.string.atoi(startindex)">

ATENTION: If 'startindex' is not a valid number the `atoi' method will
rise an exception like:

Error Type: ValueError
Eror value: invalid literal for atoi():

So is better to check first, something like:

<dtml-call "REQUEST.set('startindex_int',_.string.atoi(startindex)">
 Error message - INVALID NUMBER

Other way is to force `startindex' to be a int like:
<INPUT TYPE="TEXT" NAME="startindex:int">

But you could have problems, an exception like above could occur
(if someone will input an invalid number) and you can not do something.

That's the story.


Zope maillist  -  [EMAIL PROTECTED]
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-dev )

Reply via email to