How to use a stored string in function call

Hi All
I have written code for storing data in a string based on pattern.
whenever i tried to use in a function call its not getting there.
Actually the same logic was applied for another string..then i can use the
string at any function.

the code goes like this

/mp metadata/{
start=index($0,"metadata");
if ($2=="metadata")
flow_string=substr($0,start);
print(flow_string);
}
I can print the data in this search block

If i tried to use in any function the data in the flow_string is not retrieving
like
function retrieve_data(){
print(flow_string);
}
It is not working..
but the same thing is working for some other pattern.

Please can anyone have an idea whats may be the reason that iam not able to use that string..any globally declaration is need to be done..
for one string the logic is working and why its not working for other string?
while parsing data any problem?

please help me out...

Whatever the reason, an improvement (not merely a workaround!) would be to make sure you always use local variables in functions. This is a basic principle of modular coding; it helps keep code complexity down and reduces the risk that you end up with spaghetti code.

So, in other words, refactor retrieve_data() so that it receives the flow_string as an argument.

(We infer from the syntax that this is awk you are talking about.)