I was looking at some of the macros in VS2013 and noticed that some use what look to be something like powershell syntax calls inside of the registry (less the macros $(VCTargetsPath) and $(MSBuildExtensionsPath32)).
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\12.0\12.0
VCTargetsPath REG_SZ $([MSBuild]::ValueOrDefault('$(VCTargetsPath)','$(MSBuildExtensionsPath32)\Microsoft.Cpp\v4.0\V120\'))
I tried to execute it, but powershell doesn't seem to understand the type [MSBuild].
How can I interpret this easily, without parsing and translating what it seems to be obviously doing?
NOTE
My goal is to parse a .vcxproj file and extract information from it. This requires that I evaluate the Condition tag attributes, which in turn require that I expand and evaluate them. If I'm going down the wrong path and you know something about how to do this, then please point me in the right direction.
Related
I'm new to PowerShell scripting and am looking to create ps1 scripts that I can used as cmdlets. My background is in using strongly typed variables, but I'm struggling to find how (or if) it is possible to ensure that all user variables in a script are explicitly typed. Some languages only allow explicitly typed variables. VBA allows the directive "Option Explicit" and I was hoping to find some way to achieve the same in any PSH scripts I create.
I've done a lot of searching (google, stackoverflow etc.) but not found anything. If there is no way to force all variable definitions to be explicitly typed, I'll have to write a cmdlet to parse my scripts to find any implicitly typed variables ... but hoping for a better solution.
I don't think you can do that in PowerShell. Closest you can get is to use Set-StrictMode which will, among other things, prohibit use of uninitialized variables.
But if you want to parse the scripts, maybe don't write your own solution. Use PSScriptAnalyzer module. It has a lot of built-in rules, unfortunately none for checking explicit types. But you can define your own rules, and maybe someone already created the one you're looking for and posted it somewhere.
I'm trying to figure out how to modify an XML file with NSIS. So I'm trying to learn how to use the XML plugin. The examples on the forum page often use the format ${plugin::command} like:
${xml::LoadFile}
The documentation gives no indication that you need the dollar sign and curly braces. As I understand it, just plugin::command will do. So I've been trying to figure out what that syntax means.
The documentation says a $ is for variables and the {} are for code blocks, but I can't find anything about what it means when they're used together. My Internet searches have revealed that it's used for something called template literals in JavaScript. But what does it mean in NSIS?
EDIT: I should mention that the NSIS documentation does show examples of this syntax, especially in the Predefines section, but it still doesn't explain what the syntax means in general.
EDIT: Okay, now I see that the syntax is for the compiler to replace things using !define and !macro. But... what about this specific case? Is it valid to use colons in such a symbol? Why are some people writing ${xml::LoadFile}and some people just writing xml::LoadFile?
It's a !define. There is a header file for this plugin that defines it. The plugin probably needs to do more than one thing, so they wrapped a few lines together with a define that inserts a macro. Either that or it has some default parameters for the plugin call. Either way, it's trying to save you some typing with this syntax.
I'm working on a PowerShell profile template that mimics the lambda mod for zsh as close as possible as a proof-of-concept.
I was able to get the lambda, the user colored if root and the home-abbreviated path right. The git part can be done using posh-git, but the repo hash displayed in the mod is right aligned in the prompt line.
Zash/Bash does this through a RPROMPT variable and I haven't found similar functionality in PowerShell. Does it really not exist? Is it possible to implement it?
If I were to implement how'd it go about? It seems to me it's impossible to reliably align something right on PS without the Shell size (and therefore breaking at resize). Also, I wouldn't know how to have the cursor still on the line that RPROMPT was written.
I'd like to check hardcoded values in (a lot of) Smartforms and SAPScript forms.
I have found a way to read the source code of both of these, but it seems that i will have to go through a lot of parsing before I get anything reliable.
I've come across function module GET_LITERAL but that doesn't seem to help me much since i have to specify the offset of the value, if i got right what the function is doing in the first place.
I also found RS_LITERAL_LIST but that also doesn't do what i expect.
I also tried searching for reports and methods, but haven't found anything that seemed to help.
A backup plan would be to get some good parsing tool, so do you know of anything like that.
Anyway, any hints would be helpful and appreciated.
[EDIT]
Forgot to mention, the version of my system is 4.6C
If you have a fairly recent version of ABAP, you can use a regex.
Follow the pattern of this example, but use your source as the text and create your own regex. Have it look for any single quotes on the end of a word separated by spaces or any integers with spaces on either side. That's just a start, you might need to work on a better pattern.
String functions count, find, and match
I am screwing around with a tiny script I am making and one thing I am trying to figure out is how to make a perl variable reflect an executable, for example.
$putty = C:\putty.exe;
When ever I run it like this it tells me "C:\ is not recognizable command, what am I doing wrong? I have also tried surrounding it in quotes and no help by that.
You should be quoting literal strings, for example like
my $putty = 'C:\putty.exe';
If this is news to you, you might have been missing out on the strict pragma before. I highly recommend having a look at that and using it in all of your code.