Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
More then one variable in a return command
Message
From
09/07/2000 14:41:22
 
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00389980
Message ID:
00390004
Views:
11
>This is the calling program
>
>local amtdue,annualrate
>loandate = {04/10/2000}
>loanamt = 100
>strcode = 0
>firearmcode = "E"
>govermentcode = .T.
>loanduration = date() - loandate
>set database to pawn
>amtdue = feecalc(loanduration,loanamt,strcode,firearmcode,govermentcode,@amtdue,@annualrate)


You have to initialize amtdue and annualrate first:

amtdue = 0
annualrate = 0

But you don't need amtdue as that is the actual return value of your function.


>? amtdue
>*? annualrate
>
>
>
>here is the top part of the function
>function feecalc(loanduration,loanamt,strcode,firearmcode,govermentcode)


You need to add the amtdue and annualrate variables to your parameter list for the function definition:
function feecalc(loanduration,loanamt,strcode,firearmcode,govermentcode,amtdue,annualrate)


>local storage,prorateamt,amtdue,sixday,thrtday
>local annualrate


Remove amtdue, annualrate from the above declarations of local.


>
>use fees &&load fees table
>scatter memvar && load all fields to varibals
>use && clear table
>use intrest && load intrest table
>scatter memvar && load all fields to variables
>use && clear table
>
>sixtyday = sixtyday / 100 && normilze values
>thirtyday = thirtyday / 100 && normilze values
>
>
>Thanks Kelly


Now, like I said above, you don't need to pass amtdue to the function if that is your return value. If you do that, you need to keep the LOCAL definition of amtdue, and be sure that that is what you RETURN at the end, RETURN amtdue.

So your code would end up like this:
local amtdue,annualrate
loandate = {04/10/2000}
loanamt = 100
strcode = 0
firearmcode = "E"
govermentcode = .T.
loanduration = date() - loandate
set database to pawn
annualrate = 0
amtdue = feecalc(loanduration,loanamt,strcode,firearmcode,govermentcode,@annualrate)

? amtdue
? annualrate
here is the top part of the function
function feecalc(loanduration,loanamt,strcode,firearmcode,govermentcode,annualrate)

local storage,prorateamt,amtdue,sixday,thrtday
*local annualrate  && note that it is commented out because it's in your function declaration!
Fred
Microsoft Visual FoxPro MVP

foxcentral.net
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform