How do I add a variable to a piece of text? - construct-2

I am creating a side scroller game, and I want a counter on the UI that counts how many times the player has died. But, I do not know what to add to what I have already. I tried typing the variable name behind the &, but it did not accept that. What do I do to put a variable in a set of text?
I am using the free version.

The & is the string concatenation operator in Construct 2.
For global variables:
"Deaths: " & VARIABLE_NAME
For instance variables:
"Deaths: " & instanceName.variableName
Note the " around the string.
NB: There is no need to explicitly convert the number to a string, it will be done implicitly.

Construct-2 runs on Javascript, so would the "+" operator not do what you are attempting?

Related

Place plaintext right beside variables (without whitespace) in VS Code User Snippets

I would like to create a User Snipper in VS Code that is a combination of variables and plaint text. This can typically be achieved by combining variables and plain text with a whitespace between then. But I would like to ad a variable next to a text without a whitespace.
For Example, I would like to create the current timestamp like this:
2022-02-19T21:02:24-0530
Below is what I tried
$CURRENT_YEAR-$CURRENT_MONTH-$CURRENT_DATET$CURRENT_HOUR:$CURRENT_MINUTE:$CURRENT_SECOND-0530
Notice the T in between $CURRENT_DATE & $CURRENT_HOUR
OUTPUT:
2022-02-CURRENT_DATET21:06:12-0530
You can add $ symbol before the plain-text you want to add.
In this case, you need at add $T instead of T
$CURRENT_YEAR-$CURRENT_MONTH-$CURRENT_DATE$T$CURRENT_HOUR:$CURRENT_MINUTE:$CURRENT_SECOND-0530
Note that $T will get considered as a placeholder, and it will be the last item selected while tabbing through the inserted snippet.

Eval() function for Microsoft PowerApps

Is someone aware of an equivalent function in PowerApps that will, just like the Excel Eval() function, take an input string value, execute commands specified within it, and produce a result? For example, if I have I have two variables, varOne already set to the value 1 and a variable x set to 8, and then I fed this Eval() function the following string:
"x + " & varOne & " = " & x + varOne
...it would produce:
"x + 1 = 9"
Does something like this (or a reasonable workaround) exist for PowerApps?
No, this functionality does not exist in PowerApps at this moment. Feel free to create a new feature request in the PowerApps Ideas board for this.
There are two ways to achieve this as of the moment.
Create a PCF Control and use JavaScript Eval().
You can use an Api like Math.js or even Bing Search on your Power Automate Flow to solve the equation for you.
$”x + {VarOne} “
This will generate x + 1 as output. You just need to add the Value(x) + Value(varOne) behind it.
It sort of does what you are looking for but not completely.
Via logic apps, you can create a JavaScript function and do eval there out of the box. That at least keeps it low code.

PhpStorm editing multiple selection

I'm wondering about way to edit multiple selections but with different texts
For example:
arr=['hi','i','am','your','array','can','change','me','quickly','please']
arr=['test1','text','foo','test','fast','yes','test2','test3','text2','text3']
I have array of ten elements and I want to change them all with different texts.
Ordinary way to select one then change it. If you use multiple selections all of them are replaced with the same new text.
The question there: any way to change them faster?
I think there may be a way to change it like Emmet in HTML when you enter Emmet code PhpStorm convert it and take you inside red box in each element to write inside it one by one.
i have found the solution to make it easily to edit the array
just using the find ctrl+f and then use f3 to get next value to edit
in the search we can enter the regular expression that will find any matched values
(?<=')\w+(?=')|(?<=,)\w+(?=,)|(?<=\[)\w+(?=,)|(?<=,)\w+(?=])
(?<=')\w+(?=') : any text inside single quotes symbol ' can be changed double "
(?<=,)\w+(?=,): any word between commas for numbers and variables in the array
(?<=\[)\w+(?=,): the first element of the array if it as number or variable
(?<=,)\w+(?=]) : the last element in the array if it as number or variable
| : or operator

Regular Expression Generation for AngularJS ng-pattern

I'm using a regex to validate a form input. So basically a user can input "SELECT some_name of select_match".
So far I have the regex: \bSELECT\b \bof select_match\b
The last part is the middle part, which I think should be [a-zA-Z] but I'm not sure how to place it in the middle. I've read multiple pages but can't get it to work.
Also preferably I'd like the regex to ignore spaces between "SELECT" and of "select_match". Meaning that SELECT blabla of select_match and SELECT blabla of select_match would both be validated as correct.
Can anyone tell me how to do this? Thank you.
If I understood you correctly, this should work:
/^SELECT\s+(\w+)\s+of select_match$/
Notes:
This allows any number of spaces between "SELECT" and the match_name; and between the match_name and the "of" (but, at least 1. To change to at least 0, change the \s+ to a \s*)
After that, the rest of the string must be exactly like that (same spaces and words exactly).
The match_name will be in match group 1.
If this doesn't work, show a bit of your code (where you use it) and we can try to find the problem.
Note: If you are using it in ng-pattern lose the "/"s (being the pattern: ^SELECT\s+(\w+)\s+of select_match$).
Note2: If you are using it in a string, remember you might need to escape every "\" (making it a "\", and the result: ^SELECT\\s+(\\w+)\\s+of select_match$

Use Array of Values of Object in a Foreach Loop

I cannot seem to find anything about using the values of one property of an object in a foreach loop (without having the entire object placed into the loop).
I first create a function called UFGet-Servers that uses Get-ADComputer and returns the names of the servers in a specific OU in my environment and places them in an array. That's great, except that when I use the array in a foreach loop, each object that it grabs has #[Name=serverName] in it, which I cannot use in any useful manner. The following pseudo-code is an abbreviated example:
foreach($Computer in $ComputerNames){do code... code is adding the server name into a UNC path such as "\\$Computer\C$\"}
The problem with the above is that you can't add the whole object to a path -- it ends up looking like "\#[Name=serverNameHere]\C$\" which totally bombs out. How do I get rid of the "#[property=" part, and simply use the value as the $Computer in the loop?
What really weirds me out is that I can't find a straightforward article on this anywhere... would have thought everyone and their mom would have wanted to do something like this.
So, your issue isn't with ForEach loops, it is with string formatting. There are two ways that I know of to take care of what you need. First is going to be string formatting, which allows you to use {0}m {1} and so on to inject values into a string, providing that you follow the string with -f and a list of said values. Such as:
ForEach($Computer in $ComputerNames){
"The Server Path is \\{0}\Share$" -f $Computer.Name
}
The second way is a sub-expression (I'm sure somebody will correct me if I used the wrong term there). This one involves enclosing the variable and desired property (or a function, or whatever) inside $(). This will evaluate whatever is inside the parenthesis before evaluating the string. See my example:
ForEach($Computer in $ComputerNames){
"The Server Path is \\$($Computer.name)\Share$"
}

Resources