Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do you wrap if statements around function calls that return a valu 1

Status
Not open for further replies.

webdevelopernj

Programmer
Jul 1, 2002
9
US
#I attempting to a function conditionally based on a button #that was pressed, my first problem is that I need know how #to call a function conditionally.

#Example (this line exists in the #popular "restore_paramters" function):
*********************************************************
local($myVar) = &somefunction($query->param('field'));

if(open(FILE,$myfile)) {
}
*********************************************************
#this works fine, however, when i add

if (something == something ) {
local($myfile) = &clean_name($query->param('field'));
}

if(open(FILE,$myfile)) {
}

#the File cannot be opened
Note: there is no problem with the if statement I tested it with prints and moving the function outside the statement.
 
local is creating the variable local to the block where it is declared. in this case it may not be visible to the next if statement. try just declaring it without local or declaring it outside the if and assigning it inside. --Derek

"Fear not the storm for this is where we grow strong."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top