Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
AmCh
Creator
Creator

From macro to script

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.

4 Replies
edwin
Master II
Master II

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 

Saravanan_Desingh

Please add some sample and expected output. That helps in faster response.

AmCh
Creator
Creator
Author

No, a,b,c etc are not fields of table. They have a unique values.

There is an 1:1 equivalent?

 

 

edwin
Master II
Master II