‎2009 Jan 19 11:10 AM
Hi Experts,
Why we need to declare Flag variable in Coding. Plz clearify me. What is it used?
Thanks in Advance.
Regards,
Swapnika
‎2009 Jan 19 11:13 AM
Flags are usually used to trace any particular thing during logic execution..
Something like marking whether particular thing has happened or not and then take decision based on it.
So we usually set a flag to 'X' and then later may check it as IF flag = 'X'. option 1. Else. option 2.
An important thing to remember is to clear the flag as soon as decision has been taken so that old value of flag does not persist for next Loop run..
Revert if u need anything in particular.
Edited by: Ankesh on Jan 19, 2009 4:43 PM
‎2009 Jan 19 11:17 AM
‎2009 Jan 19 11:20 AM
Hi,
They are single Character variable used to hold two different Values X or SPACE.
They can be used to set X so as to specify a particular state of the object.
‎2009 Jan 19 11:22 AM
hi,
Flags are used in BRANCHING CONDITIONALITY
based on the flag value u can choose different flows in program execution.
for example it can be assigned to the value a function returns on calling
flag=call_some_function();
if(flag==0) ---> do action 1
if(flag==1) ---> do action 2
and so on
Regards
Jayapriya
‎2009 Jan 19 11:31 AM
Hi ,
Flags are generally used to alter the program execution according to a defined approach.
Say after a specific operation you set the flag as FLAG_SET = 'X' .
At a later point you nned to validate and perform soem operation only if the previous operation is successful , then you check for the FLAG_SET = 'X' . then continue with the operation else if you wish to do some other activity then write the logic for the same.
Regards,
Radhika.