I have a global MACRO defined in .cmm script and I want to get it's value by using the string name.
I tried to reference it with double "&" symbol, but after this line I get an "operand expected" error:
&error_name = STRING.LoWeR("&error_name")+"_low"
&modulus=&&error_name
VAR.IF (FS_ErrorIdStatus[&modulus] != 0)
(
&error_name = "ERR_MON_"+STRing.UPpeR("&error_name")+"_VOLTAGE"
GOSUB TC_DEBUG_MESSAGE " -- FAILED: " + &error_name + " was reported"
RETURN FALSE()
)
Although in the debug window it's value is shown.
(https://i.stack.imgur.com/6wspz.png)
You need two & on the left side of the assignment. Doing so will cause the macro expansion on the right side to happen twice before the assignment. Example:
&some_macro=0x42
;construct macro name
¯oname="some"+"_macro"
;get value from macro
&&val=&¯oname
PRINT &val
After the first macro replacement run, ¯oname is replaced with some_macro, in the second run, &some_macro is replaced with its value 0x42 which is then assigned to value &val.
Related
I am trying to create a macro on Fiji (ImageJ). I cannot find how to introduce a user input. I want to sum a stack with z project. Each sum is the result of 10 stacks. But the start is not the same. It varies between 1 and 11. So it would be fine when the user choose a startpoint. when the file is saved, the filename should contain the start and endpoint. So I know some weeks later which stacks I used. Thanks for some hints!
imageTitle=getTitle();
path = "D:/test/";
first = Dialog.getChoice();
// first = 8;
last = first+9;
selectWindow(imageTitle);
run("Z Project...", "start=first stop=last projection=[Sum Slices]");
run("Red");
saveAs("Tiff", path+"SUM_"+imageTitle+"("+first+last+")";
I get the error message:
"No dialog created with Dialog.create() in line 3:
first = Dialog.getChoice> () ;
When I didnt choose the start I get the error message:
" ')' expected in line 9:
saveAs ( "Tiff" , path + "SUM_" + imageTitle + "(" + first + last + ")" <;>
I am trying following code:
open Str
let ss = (Str.first_chars "testing" 3);;
print_endline ("The first 3 chars of 'testing' are: "^ss);;
if (ss == "tes")
then print_endline "These are equal to 'tes'"
else print_endline "These are NOT equal to 'tes'"
However, I am getting these are NOT equal:
$ ocaml str.cma testing2.ml
The first 3 chars of 'testing' are: tes
These are NOT equal to 'tes'
Why first 3 characters pulled by Str.first_chars from "testing" not equal to "tes"?
Also, I had to use ;; to make this code work (combinations of in and ; which I tried did not work). What is the best way to put these 3 statements together?
The (==) function is the physical equality operator. If you want to test whether two objects have the same contents, then you should use the structural equality operator which has one equal sign (=).
What is the best way to put these 3 statements together?
There are no statements in OCaml. Only expressions, all returning values. It is like a mathematical formula, where you have numbers, operators, and functions and you combine them together into bigger formulae, e.g., sin (2 * pi). The closest thing to the statement is an expression which has side effects and returns a value of type unit. But this is still expression.
Here is an example, how you can build your expression, which will first bind the returned substring to the ss variable, and then compute in order two expressions: an unconditional print, and a conditional print. Altogether, this will be one expression evaluating to the unit value.
open Str
let () =
let ss = Str.first_chars "testing" 3 in
print_endline ("The first 3 chars of 'testing' are: " ^ ss);
if ss = "tes"
then print_endline "These are equal to 'tes'"
else print_endline "These are NOT equal to 'tes'"
and here is how it works
$ ocaml str.cma test.ml
The first 3 chars of 'testing' are: tes
These are equal to 'tes'
I have two methods which I'm using to get and compare two colors. The first is to get the color
/*
This function returns the color at the given coordinates in hexadecimal format
*/
GetColor(x, y) {
MouseMove x, y
PixelGetColor, colorToReturn, x, y
Return %colorToReturn%
}
And here is my check color method
/*
This function checks the passed color with the color at 600, 475.
*/
CheckColor(colorToCheck) {
colorToCompare := GetColor(600, 475)
MsgBox %colorToCheck% - %colorToCompare%
IfEqual %colorToCheck%, %colorToCompare%, Return, 1
Return 0
}
I call it with this hotkey but I always get 0 back even though the two colors are the same color.
^t:: ; CTRL + T test color compare
colorToTest := GetColor(600, 475)
result := CheckColor(colorToTest)
MsgBox %result%
RETURN
Why does my check color always return false?
https://autohotkey.com/docs/commands/IfEqual.htm
IfEqual, var, value
var - The variable name.
value - A literal string, number, or variable reference (e.g.
%var2%).
So if you are set on using IfEqual command instead of if (expression) it should look like that:
IfEqual, colorToCheck, %colorToCompare%,Return 1
if (expression) altrenative:
if (colorToCheck=colorToCompare)
Return 1
"IfEqual %colorToCheck%, %colorToCompare%, Return, 1"
should be
IfEqual colorToCheck, %colorToCompare%, Return, 1
Variable names in an expression are not enclosed in percent signs (except for pseudo-arrays and other double references).
If a variable is enclosed in percent signs within an expression (e.g. %Var%), whatever that variable contains is assumed to be the name or partial name of another variable (if there is no such variable, %Var% resolves to a blank string).
I want to generate value for a variable in this format X (XX).
eg: 7 (70)
I've the values in the variables N and PctN_01. SO tried
value = cats(N," (",PctN_01,")");
But its not adding the space. I get the result 7(70). So what do I do?
You can use two 'cat' functions, cats and catx - catx concatenates with a delimiter...
value = catx(" ", N, cats("(", PctN_01, ")")) ;
If you're running a version of SAS prior to version 9 (catx not available) then you can do it along the lines of:
value = N || "(" || PctN_01 || ")";
So I have the following code
base = "INSERT INTO " + table + " ("
lineCount = 0
tableFieldNames = dataArray['titleRow']
**for titleRow as tableFieldNames:**
if some_list[-1] == titleRow:
base = base + titleRow
else:
base = base + titleRow + ","
base = base + ") VALUES "
where the bolded part gives an error "Invalid Syntax" and pypex's eclipse plugin gives a bit more verbose "Excepted:in" for the bolded text. What is throwing me is what that refers too. I've included a : at the end of the for loop declaration, and the array that it refers too is valid. Plus I have a for loop after this block of code that gives no such strange error.
Has anyone ran into such a thing, and found a way to resolve it (and even to make the parse errors more verbose?)
It should be for titleRow in tableFieldNames: (in, not as).