Welcome to the SRP Forum! Please refer to the SRP Forum FAQ post if you have any questions regarding how the forum works.
Math with Multi-Value Data
I've got a real basic question here...
Is there some undocumented expression that will multiply an array of data to a single number?
For example, if I had an array such as ...
Array = 2.3:@FM:3:@FM:4.5
... and if I wanted to make all data in the Array converted to work as a masked decimal with 2 digits, I would want to multiply each value in the array by 100. In order to do that I would have to make another array with the same amount of values all equal to 100 such as....
Hundreds = 100:@FM:100:@FM:100
and then mulitply the two arrays...
Result = Array *** Hundreds
If I were to simply try to multiply the Array by 100 with the same expression, "***", I would get only the first value in the array multiplied by 100 and the rest of the values would be multiplied by 0.
It seems to me that there would be some way to simply convert a whole array or multiply the whole array by a single number, but I haven't been able to find any documentation to support my theory.
Thanks in advance for any light you might shed on the topic.
Is there some undocumented expression that will multiply an array of data to a single number?
For example, if I had an array such as ...
Array = 2.3:@FM:3:@FM:4.5
... and if I wanted to make all data in the Array converted to work as a masked decimal with 2 digits, I would want to multiply each value in the array by 100. In order to do that I would have to make another array with the same amount of values all equal to 100 such as....
Hundreds = 100:@FM:100:@FM:100
and then mulitply the two arrays...
Result = Array *** Hundreds
If I were to simply try to multiply the Array by 100 with the same expression, "***", I would get only the first value in the array multiplied by 100 and the rest of the values would be multiplied by 0.
It seems to me that there would be some way to simply convert a whole array or multiply the whole array by a single number, but I haven't been able to find any documentation to support my theory.
Thanks in advance for any light you might shed on the topic.
Comments
Multivalue arithmetic in OI has never been as good as it was in AREV. Are you particularly interested in getting multivalue multiplication to work or do you need to convert each element in the array by 100? If the latter, you can accomplish the same thing using the Iconv function:
Result = Iconv(Array, 'MD2')
Here is an example of needing to use arithmetic between a single number and all the elements of an array that I have come across. If I want a report showing suggested prices of items based on costs and margins, the formula is as follows...
SuggestedPrices = Costs / (1 - Margins)
or perhaps more accurately stated
SuggestedPrices = Costs /// (1 --- Margins)
To have the desired results, I have to do some code to create an Array of elements all equal to 1 with the same number of elements as the Costs and Margins Arrays. Is there an easier way to go about it?
I am trying to make sure I understand what you are doing properly. Are all of the variables (SuggestedPrices, Costs, and Margins) multivalued? I assume so based on the name. Thus, your struggle is with the number 1, which is inherently single-valued.
As you know, multiivalue arithmetic converts single-valued numbers into multivalued numbers but assumes a value of 0 rather than the actual number. I seem to recall that AREV used to have a special function to deal with this. I think it was called Repeat(), thus your code would look like this:
SuggestedPrices = Costs /// (Repeat(1) --- Margins)
However, that does not appear to be supported in AREV32 or OI. So, the best alternative I can recommend is to use the Str() function:
SuggestedPrices = Costs /// (Str(1 : @VM, 3) --- Margins)
Of course, this approach actually creates a fourth result (which you can ignore) and it also assumes you know there will only be 3 values. If that is an indeterminate number at runtime, then do a FieldCount on Margins and replace 3 with that number.