Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Flags

Former Member
0 Likes
1,218

Hi Experts,

Why we need to declare Flag variable in Coding. Plz clearify me. What is it used?

Thanks in Advance.

Regards,

Swapnika

5 REPLIES 5
Read only

Former Member
0 Likes
939

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

Read only

0 Likes
939

Thanks Ankesh

Read only

Former Member
0 Likes
939

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.

Read only

Former Member
0 Likes
939

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

Read only

Former Member
0 Likes
939

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.