Power Automate - Subtract two integer variables - power-automate

I am trying to subtract two integer values as such:
But I get this error:
Unable to process template language expressions in action 'Negative_Index_of_Snabel-a' inputs at line '0' and column '0': 'The template language function 'sub' expects its first parameter to be an integer or a decimal number. The provided value is of type 'String'. Please see https://aka.ms/logicexpressions#sub for usage details.'.
I know that my variables in the sub() function is in quotes. But I cannot save it otherwise.

You're passing in literal string values, you need to specify that the values you want to evaluate are variables, like thus ...
sub(variables('VarMailInt'),variables('VarSnabelaIndex'))

Related

How to pass contant string value for a column in SUMMARIZECOLUMN

I want to pass a constant string value i.e. Not Applicable for one of the column values that will be used in SUMMARIZECOLUMNS function. But I am not find any format in how to do the same.
SUMMARIZECOLUMNS( table_name[column_name], "Custom_Column_Name", "Not Applicable")

The code always outputs "not"

The following code always outputs "not":
print "input a number please. "
TestNumber = gets
if TestNumber % 2 == 0
print "The number is even"
else
print "The number is not even"
end
What is going wrong with my code?
The gets() method returns an object of type String.
When you call %() on a String object, the return value is a new String object (usually it changes the text. You can read more about string formatting here).
Since there are no String objects that == 0, the if/else will always take the same path.
If you want to use the return value of gets() like a number, you will need to transform it into one first. The simplest approach is probably to use the to_i() method on String objects, which returns a new 'Integer' object. If you're doing something where the user input will not always be an integer (e.g. 3.14 or 1.5), you might need to use a different approach.
One last thing: in your example the result of gets() is saved into a constant called TestNumber. Constants are different to normal variables, and they will probably cause problems if you're not using them intentionally. Normal variables don't start with capital letters. (You can read more about ruby variables here). In ruby you need to write you variable names like this: test_number.
I suspect your Testnumber variable might be interpreted as a string during the operation. make sure the testnum is converted to an integer first even if you put in say 100 it could be its being interpreted as the stirng "100" and not the integer 100.
A similar issue can be found here: Ruby Modulo Division
You have to convert TestNumber from string to integer, as your input has linefeed and/or other unwanted characters that do not match an integer.
Use TestNumber = gets.to_i to convert to integer before testing.

In TI-BASIC, how do I display the Variable Name given only the variable?

I'm creating a function that displays a lot of variables with the format Variable + Variable Name.
Define LibPub out(list)=
Func
Local X
for x,1,dim(list)
list[x]->name // How can I get the variable name here?
Disp name+list[x]
EndFor
Return 1
EndFunc
Given a list value, there is no way to find its name.
Consider this example:
a:={1,2,3,4}
b:=a ; this stores {1,2,3,4} in b
out(b)
Line 1: First the value {1,2,3,4} is created. Then an variable with name a is created and its value is set to {1,2,3,4}.
Line 2: The expression a is evaluated; the result is {1,2,3,4}. A new variable with the name b is created and its value is set to `{1,2,3,4}.
Line 3: The expression b is evaluated. The variable reference looks up what value is stored in b. The result is {1,2,3,4}. This value is then passed to the function out.
The function out receives the value {1,2,3,4}. Given the value, there is no way of knowing whether the value happened to be stored in a variable. Here the value is stored in both a and b.
However we can also look at out({1,1,1,1}+{0,2,3,4}).
The system will evaluate {1,1,1,1}+{0,2,3,4} and get {1,2,3,4}. Then out is called. The value out received the result of an expression, but an equivalent value happens to be stored in a and b. This means that the values doesn't have a name.
In general: Variables have a name and a value. Values don't have names.
If you need to print a name, then look into strings.
This will be memory intensive, but you could keep a string of variable names, and separate each name by some number of characters and get a substring based on the index of the variable in the list that you want to get. For instance, say you want to access index zero, then you take a substring starting at (index of variable * length of variable name, indexofvariable *length + length+1).
The string will be like this: say you had the variables foo, bas, random, impetus
the string will be stored like so: "foo bas random impetus "

Freemarker displays int value as double value(e.g. prints 0 as 0.00)

I am trying to write a freemarker template file having information about a table.
I have written '${noRows}' in the template for table rows count.
The noRows is a int value:
int noOfRows = myTable.getNumRows();
data.put("noRows", noOfRows);
The noOfRows is always an integer value but in the output file it is displayed as double value with ".00" appended to it.
How can I display the value as integer only.
If the value is indeed an integer, all you should need to do is
${noOfRows?string}
You can also use the Java decimal number format syntax:
${noOfRow?string["0"]}
Reference: http://freemarker.org/docs/ref_builtins_number.html#ref_builtin_string_for_number
Apparently, your number_format setting is set to 0.00 or like. (FreeMarker doesn't care about Integer VS Double when formatting numbers. It just have a single numerical type, and it formats all of them according to that setting.) Check it wherever FreeMarker is configured. As last resort, you can also set this setting in the template like <#setting number_format="0.##">. Last not least, as "sev" said, you can specify the format at each place individually.

Cannot cast object '(10)' with class 'java.lang.String' to class 'java.lang.Integer'

I am using ireport 3.7.1. I have made a connection with my database.I have a procedure which when given an input in number ,it returns the word format of the number i.e if I give input 10,it will return ten. The problem is when I am executing the procedure in pl/sql developer,I am getting the proper output but when I am firing the same procedure in ireport it's giving me this exception
Cannot cast object '(10)' with class 'java.lang.String' to class 'java.lang.Integer' .
Casting straight from a String to an Integer is not possible. You'll want to use the function Integer.parseInt(stringNumber);
(10) isn't a properly formated integer. Not even for PL/SQL:
select '(10)' +0 from dual;
> ORA-01722: invalid number
I could only suggest you to trace back the point where those ( ) come from. And fix your code at that position instead. Just a wild guess, some number formats use parenthesis to represent negative numbers. Maybe this is your case?
That being said, if you still want to locally remove the parenthesis that have somehow lurked inside of your string:
String str = "(10)";
int value = Integer.parseInt(str.substring(1, str.length()-1));
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
// *blindly* get away of first and last character
// assuming those are `(` and `)`
For something a little bit more robust, and assuming parenthesis denotes negative numbers, you should try some regex:
String str = "(10)";
str = str.replaceFirst("\\(([0-9]+)\\)", "-$1");
// ^^^ ^^^ ^
// replace integer between parenthesis by its negative value
// i.e.: "(10)" become "-10" (as a *string*)
int value = Integer.parseInt(str);

Resources