MB Software Solutions wrote:
>>> inserts values into the numeric field, and the character fields  
>>> DEFAULT
>>> value settings transform the numbers into their character equivalents.
>>> I had been using something like this:
>>>
>>>     CREATE CURSOR curReport(nValue n(10,2), cValue c(10) DEFAULT
>>> ALLTRIM(STR(nValue,10,liDecimals)))
>>>
>>> ...where liDecimals is a value set at run time depending on the amount
>>> of decimal places I need for that record insert.  In my testing I know
>>> that TRANSFORM would be great like this:
>>>
>>>     TRANSFORM(nValue,'999,999.99')
>>>
>>> ...but sometimes I don't want the character representation to have the
>>> same number of decimal positions.  My plan B is to create some rigged
>>> UDF whereby I pass the value and the number of decimals places I want
>>> and it parses/builds it for me, but that seems kludgey.  Is there a  
>>> way
>>> to get the transform to behave variably like I had in my initial  
>>> DEFAULT
>>> value with ALLTRIM(STR(..)) without a UDF  ??
>>>       

This was what I came up with

(method:  FormatNumber)
LPARAMETERS tnValue, tiDecimals
LOCAL lcValue as String, lcExpr as String

lcExpr = '999,999'
if tiDecimals > 0 then
    lcExpr = lcExpr + '.' + REPLICATE('9',tiDecimals)
endif

lcValue = ALLTRIM(TRANSFORM(tnValue,lcExpr))
return lcValue



-- 
Michael J. Babcock, MCP
MB Software Solutions, LLC
http://mbsoftwaresolutions.com
http://fabmate.com
"Work smarter, not harder, with MBSS custom software solutions!"



_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/[EMAIL PROTECTED]
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to