Page 1 of 1

Is there a function to convert a string into a number ?

Posted: Tue Jan 13, 2004 3:18 pm
by Inquisitive
I need to convert a string into a number. This is needed for performing a mod operation.

Posted: Tue Jan 13, 2004 3:23 pm
by roy
Hi,
Basically DS is type free, meaning that if you take a string and put it in a phrase of numeric meaning it will work if you enshure that it is numeric castable (a number in fact) in a transformer for example.
though types are checked when you read/write data from/into you sources/targets.
IHTH

not necessarily true

Posted: Tue Jan 13, 2004 3:32 pm
by 1stpoint
I wrote a VAL function a few years back.

It will convert things like "1.244E10", "$5767.88" and other non numeric fields to number.

Re: Is there a function to convert a string into a number ?

Posted: Tue Jan 13, 2004 5:12 pm
by Teej
Inquisitive wrote:I need to convert a string into a number. This is needed for performing a mod operation.
Therefore, you are asking if you need to convert from a string to an integer. Not necessary -- as others have said, DataStage is MOSTLY type-independent. Just lets the mod function rip.

Naturally, you need to ensure that your data is validated as an integer in advance.

However, if you want a decimal values, just use StringToDecimal().

-T.J.

Posted: Tue Jan 13, 2004 8:05 pm
by ray.wurlod
If you're using a BASIC Transformer stage (or are in a server job), you can use a BASIC expression. The easiest way is to perform some arithmetic. But you have to be certain that what you're beginning with can be regarded as numeric.

Code: Select all

If Num(inlink.column) Then Iconv(inlink.column,"MD0") Else 0
The Iconv function will remove thousands delimiters and currency symbol. It will also round to the indicated number of decimal places and NOT return the decimal place holder character. Find out all about the "MD" conversion in on-line help from Designer or Manager.

Is there a function to convert a string into a number ?

Posted: Wed Jan 14, 2004 8:07 am
by bigpoppa
PX is not freely-typed b/c it doesn't operate on DS's Basic engine. It uses a separate c-based engine.

I don't know the answer to the original question, but if someone has the APT_Ref cards, could they be kind enough to see if there is a str_to_num function for the APT_String class?

Thanks,
BP

Re: Is there a function to convert a string into a number ?

Posted: Wed Jan 14, 2004 10:33 pm
by Teej
bigpoppa wrote:I don't know the answer to the original question, but if someone has the APT_Ref cards, could they be kind enough to see if there is a str_to_num function for the APT_String class?
There is an "asInteger(APT_Int32, APT_Status)" within APT_String class.

However, what the person would want is a APT_FieldConversion - there's tons of conversion options in it.

This is referring to Orchestrate HTML 6.0 version.

-T.J.