checking for a flag in a subscript?

I want to incorportae a subscript in a job script which is used for loading purposes.
What i require is that before a job runs it should check for a flag ,if flag is not present then create it and the loading should start.
Once loading finishes it should delete the flag.
So if any other load comes while loading is happening it should wait until that flag is deleted by the previous load?

What do you mean by a "subscript"?

You can use a function or another script; either can be called just as any other command.

What's a "flag"? Do you mean a file? If so, what is it called?

You can check for the presence of a file with "test -f FILENAME".

thank you..

subscript basically means a function only...
by flag i mean a file ..that is like "load_running"....