What language?

Solved

Posted on 2006-06-05

This has boggled my mind for quite some time. I have a short procedure that takes in four integers and performs some simple calculations with them. We'll call this procedure "buildProfile".

I have another procedure (generateSlice) that generates four numbers, with the objective of and passing them to buildProfile.

That procedure looks like this:

Pro generateSlice, x1, x2, y1, y2

firstPoint = fix(randomu(seed, 1) * 800)

secondPoint = fix(randomu(seed, 1) * 800)

x1 = 0 ;Constants

x2 = 799 ;Constants

y1 = firstPoint

y2 = secondPoint

endelse

end

So, if I call generateSlice, a, b, c, d, I get the numbers 0, 799, and two random integers between 0 and 799, assigned to the variables a, b, c, d respectively.

However, if I then call buildProfile, a, b, c, d, the procedure does not produce the expected result. However, if I were to call buildProfile, x1, x2, 580, 700 (replacing the last two variables with constant values of my own), it works perfectly fine. Is there any reason that assigning one variable to the value of another variable might cause problems in this context?

Thanks.

I have another procedure (generateSlice) that generates four numbers, with the objective of and passing them to buildProfile.

That procedure looks like this:

Pro generateSlice, x1, x2, y1, y2

firstPoint = fix(randomu(seed, 1) * 800)

secondPoint = fix(randomu(seed, 1) * 800)

x1 = 0 ;Constants

x2 = 799 ;Constants

y1 = firstPoint

y2 = secondPoint

endelse

end

So, if I call generateSlice, a, b, c, d, I get the numbers 0, 799, and two random integers between 0 and 799, assigned to the variables a, b, c, d respectively.

However, if I then call buildProfile, a, b, c, d, the procedure does not produce the expected result. However, if I were to call buildProfile, x1, x2, 580, 700 (replacing the last two variables with constant values of my own), it works perfectly fine. Is there any reason that assigning one variable to the value of another variable might cause problems in this context?

Thanks.

5 Comments

x1 = 0 ;Constants

x2 = 799 ;Constants

y1 = firstPoint

y2 = secondPoint

If I change 'firstPoint' and 'secondPoint' to constants, the procedure works fine, and the passed values work as expected.

Because two of the variables are scalars, and two are arrays, IDL becomes confused, and tries to perform multiply the array by a scalar.

The solution is:

firstPoint = fix(randomu(seed, 1) * 800)

secondPoint = fix(randomu(seed, 1) * 800)

x1 = 0 ;Constants

x2 = 799 ;Constants

y1 = firstPoint[0]

y2 = secondPoint[0]

This way, we only assign the scalar value that is desired.

Thanks for leaving a comment.

Title | # Comments | Views | Activity |
---|---|---|---|

Is Cross Site Request Forgery (CSRF) & XSS applicable to RPG coding? | 10 | 89 | |

zeroMAx challenge | 20 | 66 | |

Sql how to exclude from a table | 3 | 61 | |

ClickOnce Install - Shortcut Question | 3 | 44 |

Join the community of 500,000 technology professionals and ask your questions.

Connect with top rated Experts

**17** Experts available now in Live!