I created a function for use in a report to return address details from a table by the specified field name as follows:-
function cwgetbranch
lparameters lcbranch,lcfield
local lcalias,lcreturn
lcreturn = ""
lcalias = alias()
if sqopen("S","cware") &&Opens a table shared and selects it.
afields(lafields)
if ascan(lafields,upper(lcfield)) > 0
locate for alltrim(left(cw_code,2)) == alltrim(upper(left(lcbranch,2)))
if found()
lcreturn = &lcfield
endif
else
lcreturn = "#INVALID FIELD NAME#"
endif
sqclose("cware") &&Closes the table again.
if !empty(lcalias)
select &lcalias
endif
endif
return lcreturn
I compiled this and it worked fine. When I deployed it on a customer site it didn't work (returned "" for every enquiry). I checked through all the things that could cause the problem and they were all fine. I tested this on another PC in my office and it was the same as on the customer site.
I added an else clause on the found as follows:-
if found()
lcreturn = &lcfield
else
lcreturn = ""
endif
compiled again and it all worked fine.
I then removed the else clause again, recompiled and it still all worked fine.
Any ideas what could have happened?
function cwgetbranch
lparameters lcbranch,lcfield
local lcalias,lcreturn
lcreturn = ""
lcalias = alias()
if sqopen("S","cware") &&Opens a table shared and selects it.
afields(lafields)
if ascan(lafields,upper(lcfield)) > 0
locate for alltrim(left(cw_code,2)) == alltrim(upper(left(lcbranch,2)))
if found()
lcreturn = &lcfield
endif
else
lcreturn = "#INVALID FIELD NAME#"
endif
sqclose("cware") &&Closes the table again.
if !empty(lcalias)
select &lcalias
endif
endif
return lcreturn
I compiled this and it worked fine. When I deployed it on a customer site it didn't work (returned "" for every enquiry). I checked through all the things that could cause the problem and they were all fine. I tested this on another PC in my office and it was the same as on the customer site.
I added an else clause on the found as follows:-
if found()
lcreturn = &lcfield
else
lcreturn = ""
endif
compiled again and it all worked fine.
I then removed the else clause again, recompiled and it still all worked fine.
Any ideas what could have happened?