REPEAT Function - Help

REPEAT Function - Help

Anonymous
Not applicable
1,050 Views
5 Replies
Message 1 of 6

REPEAT Function - Help

Anonymous
Not applicable
 

I have a REPEAT function for a loop, but I got the error: 

bad argument type: fixnump: "2", when I "Inspect" through Visual Lisp" it tell me is a STR. 

 

 

Here is my sequence ...

When I click on the OK button, the following is executed:

(action_tile "accept" (strcat "(progn (setq Xcopies (atof (get_tile \"K_Copies\")))"
     "(scr_do_run)" "(done_dialog) (setq userclick T)" ")"); strcat
) ; action

 

 

then under the sector "if userclick"....

; fix - This function converts a real to an integer.
(setq Xcopies (fix Xcopies))                                ; Xcopies is a real
(setq Copies# (nth Xcopies CopyList))

 

 

Then, in the REPEAT function, I'm using the value of Copies#.

my question is: How I can make sure the "Copies#" is a Real without quotes.

I did try different ways without a good result..

 

thank you in advance for your help...

 

DC

0 Likes
Accepted solutions (2)
1,051 Views
5 Replies
Replies (5)
Message 2 of 6

ВeekeeCZ
Consultant
Consultant
The repeat finction requires an integer, not real. You can use the READ or ATOI functions
0 Likes
Message 3 of 6

Ranjit_Singh
Advisor
Advisor

Once Copylist is generated make sure it only consists of integer values. Repeat will fail unless you provide it an integer type.

(setq copylist (mapcar '(lambda (x) (fix (read x))) copylist))

The above assumes you only have strings in Copylist. You should know what you have in there, adjust the code accordingly. Or you can simply pass each copies as a integer to repeat (repeat (fix (read copies)) ....some code here... )

 

0 Likes
Message 4 of 6

Kent1Cooper
Consultant
Consultant
Accepted solution

@Anonymous wrote:
... I'm using the value of Copies#.

my question is: How I can make sure the "Copies#" is a Real without quotes.

....


If it's a fixnump error, you don't want a Real number, but an Integer.  Just use (atoi Copies#) -- no need for (fix) or (read), as long as the string actually represents a whole number, not a decimal or fractional one.

Kent Cooper, AIA
0 Likes
Message 5 of 6

Anonymous
Not applicable

Thank you, everyone....

 

let me try those recommendations... I will let you know... 

0 Likes
Message 6 of 6

Anonymous
Not applicable
Accepted solution

thanks guys... the use of  (atoi Copies#) solve the problem...

 

very much appreciated...

 

DC

0 Likes