Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Matrix rate
Message
 
To
27/06/1999 19:07:46
Dovi Gilberd
Dovtware Consulting Inc
Miami, Florida, United States
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Miscellaneous
Thread ID:
00233562
Message ID:
00234579
Views:
26
Dovi,
Don't worry about bothering me - if I'm too busy to log onto UT messages just don't get answered.

OK, I missed something, but you may have also. As it is now, the code loops through all the fields and returns the information from the last field ONLY. If that isn't the correct one, then your lSuccess will be .F.

You want to exit the for/next loop when you find the correct value. In this case, you'd add an EXIT after the lSuccess = .T.

HTH
Barbara

>hi barbara...how are you...i'm sorry to bother you again..
>2 questions..why do i need the lsuccess..?
>i took it of and i get as a result a false answer for all the calls
>im using it like this..
>
> function rate()
> lparameter dialednr, code, calcrate, rate, n
> LOCAL y
>
> select rates
> set order to tag code
> seek left(view1.dialednr,6)
> for n=1 to fcount()
> if field(n)=upper(code)
> rate = eval(field(n))
> calcrate = rate*result
>
> endif
> endfor
>y=rate
>return rate
>endfunc
>
>what am i doing wrong
>
>
>>Dovi,
>>I STRONGLY feel that you should normalize your table as was discussed by Mark McCasland and me earlier in this thread. However, your function seems to get the information you want. You do have a couple of problems. I've rewritten it below - PLEASE be sure you check to see that the correct field names are used. Without your table structure and test data I have surely missed something. Note that you can only return ONE values from a function, but you CAN pass parameters by reference so the information is passed back.
>>lSuccess =  rate(dialdnr, code, @CalcRate, @rate, @n,
>>
>>function rate()
>>lparameter dialednr, code, calcrate, rate, n
>>LOCAL lSuccess
>>lSuccess = .F.
>>
>>select rates
>>set order to tag code
>>seek left(view1.dialednr,6)
>>for n=1 to fcount()
>>   if field(n)=upper(code)
>>      rate = eval(field(n))
>>      calcrate = rate*result
>>      lSuccess = .T.
>>   endif
>>endfor
>>
>>return lSuccess
>>Note that the values you need are returned by reference because you called them with the @ since in front of the parameters.
>>
>>You WILL have to adjust this to use your specific fields, but I hope this will get you started.
>>
>>Barbara
>>
Barbara Paltiel, Paltiel Inc.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform