1 páginas (11 elementos)
Feature or a bug? Cannot force numeric evaluation within a function - Mensajes
This example should be self explanatory. I expected same output in both cases. Is this a feature or a bug? Caused disaster in my formula logic.
Thanks!

FunctionBug.sm (7,33 KiB) descargado 1206 vez(es).
Thanks!

FunctionBug.sm (7,33 KiB) descargado 1206 vez(es).
Feature 
You are using pass-by-reference, that assign a value to an input argument when it is the target of an assignment inside the procedure (see here f.e.)

the last assignment is missing; to assign the same value both to the result and to the input variable you have to define ID#:eval(ID#+1) even after the loop.
![2016-11-14 01_53_10-2016-11-14 01_52_11-SMath Studio - [FunctionBug.sm_].png - Visualizzatore foto d.png](/es-ES/files/Download/P6g35s/2016-11-14-01_53_10-2016-11-14-01_52_11-SMath-Studio---[FunctionBug.sm_].png---Visualizzatore-foto-d.png)
You are using pass-by-reference, that assign a value to an input argument when it is the target of an assignment inside the procedure (see here f.e.)

the last assignment is missing; to assign the same value both to the result and to the input variable you have to define ID#:eval(ID#+1) even after the loop.
![2016-11-14 01_53_10-2016-11-14 01_52_11-SMath Studio - [FunctionBug.sm_].png - Visualizzatore foto d.png](/es-ES/files/Download/P6g35s/2016-11-14-01_53_10-2016-11-14-01_52_11-SMath-Studio---[FunctionBug.sm_].png---Visualizzatore-foto-d.png)
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
WroteFeature
You are using pass-by-reference, that assign a value to an input argument when it is the target of an assignment inside the procedure (see here f.e.)
the last assignment is missing; to assign the same value both to the result and to the input variable you have to define ID#:eval(ID#+1) even after the loop.
Davide, pass by reference assignment is intentional. What i do not understand is why
The result is 56 and not 10 - I used eval() to assign a static value to ID#, or so I thought, but ID# was assigned a dynamic ID# = ID# + 1, which was not the intent.
Hey, in first block, you incremented ID by 1 in loop; in second you do it by self-incrementing i!
С уважением,
Михаил Каганский
A 2 usuarios les gustó este mensaje
WroteDavide, pass by reference assignment is intentional. What i do not understand is why
The result is 56 and not 10 - I used eval() to assign a static value to ID#, or so I thought, but ID# was assigned a dynamic ID# = ID# + 1, which was not the intent.
Ah! Now I see it.
WroteHey, in first block, you incremented ID by 1 in loop; in second you do it by self-incrementing i!
This is the cause
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
A 1 usuarios les gustó este mensaje
Alexander O. Melnik 14/11/2016 17:21:00
Thank you all; so far I understood that something should be clear to me by now, but its not. What can I do to encapsulate a seemingly simple for() loop in a function that produces same result (10)?
FunctionBug1.sm (6,67 KiB) descargado 1200 vez(es).

FunctionBug1.sm (6,67 KiB) descargado 1200 vez(es).

1 páginas (11 elementos)
- Nuevos mensajes
- Sin mensajes nuevos


