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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Complete Newbie - Please check a VFP expression for currency

Status
Not open for further replies.

Bollard04

Technical User
Dec 27, 2008
21
GB
Hello Guys,

I have absolutely no experience with VFP but am trying to edit some of our reports (ie invoices, quotations etc).

The expression i am looking at pulls a price from a table (as a number) and then converts (divides by 100) to a currency. I wanted to clean up the code (as to me it seems quite ridicolous) and change the formatting to add comma separation

The old expression was (i think - i cant copy and paste!):

p_oCallingObject.dispunit(.f.,p_oCallingObject.p_currncy,p_oCallingObject.w_fcrate, it_price,"",.t.,.f.,10,.f.,"",.t.)

This is what i cobbled together:

TRANSFORM(it_price/100, '$$$,$$$,$$$.$$')

I would love to know:
a) What exactly the old code is doing?
b) If there is anything wrong / could be improved in my attempt?

I would REALLY appreciate some help

Thank you
 
Mike - I agree. That's why I suggested using something else other than the Method's value as the Print When's NOT EMPTY check value.

If they were inserting a blank line for Report Form spacing issues (I'm not sure how since they can't control the code itself), it would mean that some other field might be BLANK in that record and they could use that value for the NOT EMPTY text.

Bollard4 - Good Luck,
JRB-Bldr
 
Thank you for all your help and support guys. Ive really been blown away.

@jrbbldr - I have been using the !EMPTY check by itself and it is working as i had hoped. So thank you very much.

My final final final question (i promise!):
I have been adding this extra code to other currency fields, but have hit a problem with the TOTAL - VFP complains the expression is too long. How can i get around this?

Here is the code:
iif(SQG_lastrec_L('sname.sn_account+ihead.ih_doc'),p_oCallingObject.dispvalu(.f., p_oCallingObject.w_fcrate, p_oCallingObject.p_tgoods- p_oCallingObject.p_over+ p_oCallingObject.p_tvat,"",.t.,.f.,12),"")

Which i then make too long by:
ALLTRIM(TRANSFORM(VAL(STRTRAN(iif(SQG_lastrec_L('sname.sn_account+ihead.ih_doc'),p_oCallingObject.dispvalu(.f., p_oCallingObject.w_fcrate, p_oCallingObject.p_tgoods- p_oCallingObject.p_over+ p_oCallingObject.p_tvat,"",.t.,.f.,12),""), ',','')), '999,999,999.99'))

Any ideas?

Thank you again
 
Well, for a start, you can cut out the VAL(, along with the matching closing parenthesis.

The expression is already a string. VAL() just makes it into a numeric, and TRANSFORM() then converts it back to a string.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Another way of cutting out a few characters would be to add @T to the format string; in other words, instead of this:

'999,999,999.99'

do this:

'@T 999,999,999.99'

Then remove the ALLTRIM( and matching closing parenthesis.

The @T has the same effect as ALLTRIM().

Together, these too suggestions might just cut the string down to an aceptable size. If they don't, there are other things you can do. But start with the above.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
So we've helped you in your stated goal to simplify an expression to the point where you've exceeded a 254-char limit with a far more complex expression?

Cool.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top