Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Naresh1
Contributor III
Contributor III

Please Can anyone answer this

Screenshot_20190916_184151_com.android.gallery3d.jpg

  Set & let

4 Replies
treysmithdev
Partner Ambassador
Partner Ambassador

It should be 7.

 

If you are ever unsure, it is worth testing out on your own. If you run this using the debugger it will show you how the different parts of this are executed and how the variable changes.

Blog: WhereClause   Twitter: @treysmithdev
StarinieriG
Partner - Specialist
Partner - Specialist

Hi,

vValue is a string because 1+2 is between " ' " (and you are using SET instead of LET)

So you couldn't do a sum.

So at the end:

vValue = '1+2'

vSum = '+4'

treysmithdev
Partner Ambassador
Partner Ambassador

@StarinieriG  vValue gets replaced with the string in the vSum LET expression. 

So:

 

Let vSum = $(vValue) + 4;

 

Turns into:

 

Let vSum = 1+2 + 4;

 

Debugger window to visualize:

clipboard_image_1.png

If you take the script:

 

Sub A

	SET vValue = '1+2';

EndSUB

Sub B

	Let vSum = $(vValue)+4;
    
EndSub;

Sub C

	let vValue=;
    
    let vSum=;
    
EndSub

Set vValue=56;

CALL A; Call B;


Trace ------------------ vValue = $(vValue) | vSum = $(vSum);

 

 

It will return:

clipboard_image_0.png

Blog: WhereClause   Twitter: @treysmithdev
Brett_Bleess
Former Employee
Former Employee

This may be crazy, but here are the Help links for Set and Let, maybe seeing the official doc will help solidify the delta, I know I struggled with them at first as well...

https://help.qlik.com/en-US/qlikview/April2019/Subsystems/Client/Content/QV_QlikView/Scripting/Scrip...

https://help.qlik.com/en-US/qlikview/April2019/Subsystems/Client/Content/QV_QlikView/Scripting/Scrip...

Cheers,
Brett

To help users find verified answers, please do not forget to use the "Accept as Solution" button on any post(s) that helped you resolve your problem or question.
I now work a compressed schedule, Tuesday, Wednesday and Thursday, so those will be the days I will reply to any follow-up posts.