Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello all,
I have just finished a macro and it works. For some purposes I want to write this macro in the script. I tried it, but it did not work.
Here is the code of the function:
function test(a,b,c,g,delta_g,e,f)
delta=(b-a)/c
t=a+delta
do while t=<b
v_i=v_i+(d(t-delta)+d(t)-w(t-delta)-w(t))*(delta/2)/(g+delta_g)
v_ii=v_ii+(d(t+delta)+d(t)-w(t+delta)-w(t))*(delta/2)/(g+delta_g)
p_i=v_i*d(t)
p_ii=v_ii*d(t+delta)
if p_i>0 and p_ii>0 then
final=final+(p_i+p_ii)*(delta/2)/f
else
final=final+(p_i+p_ii)*(delta/2)*fend if
t=t+delta
loop
test=final-e
end function
Where w() and d() are predefined functions.
What should the equivalent look like in the script?
Any help please?
Thanks in advance.
i suspect the reason you want to move this to your load script is you have a table of fields equivalent to a,b,c,g,f, etc and you want to call the function for each row. you can do a loop through your table and call your function (it is SUB routine in load script) this way your code is cleaner and you reuse a proven function:
Sub..end sub ‒ QlikView
Please add some sample and expected output. That helps in faster response.
No, a,b,c etc are not fields of table. They have a unique values.
There is an 1:1 equivalent?
this is the same question:
Re: Field generation within while loop - Qlik Community - 1789989