Micro Focus QTP (UFT) Forums
If.. then..else statement - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: If.. then..else statement (/Thread-If-then-else-statement)



If.. then..else statement - sunny rao - 11-07-2008

Hi all,
Some basic question

I am writing sample code

Code:
intfirst=False
intsecond=False

If Ucase(datatable("first", dtGlobalsheet)) = "True" Then
intfirst=true
Runaction "firstone", oneiteration
elseif Ucase(datatable("second", dtGlobalsheet)) = "True" Then
intsecond=True
Runaction "secondone", oneiteration
else
Runaction "Thirdone", oneiteration
end if

Guys the question is even if I set the value in global datasheet as true for "first"
the script still executes action "Thirdone" and just skips the previous two actions. It does not show any syntax error either.

can anybody explain this?


RE: If.. then..else statement - Ankur - 11-07-2008

If Ucase(...) = "True" . If you can explain this you will get your answer.


RE: If.. then..else statement - sunny rao - 11-07-2008

hi Ankur,

Thanks for the reply. But probably I did not understand it, can you write it in little more detail.
I can do this same logic by setting up an environment variable and checking it true or false. But what is wrong with the above code.


RE: If.. then..else statement - Ankur - 11-07-2008

ok... in more detail.

What is Ucase used for?


RE: If.. then..else statement - sunny rao - 11-08-2008

Hi Ankur,
Well I got it, I guess it was trivial but satisfied after knowing it...., Ucase(..) was converting the datatable value to "TRUE" all uppercase and that I cannot equate it to "True"

And can you suggest whether If...then else statement is better of giving the condition so that particular action can be run or is there a better work around?