- To trim a string use:
1 | ${WordReplace} $target " " "" "{}" $output |
- To get day/time info use:
1 | ${GetTime} "" "L" $Day $Month $Year $DayOfWeek $Hour $Minute $Second |
- To check a string for invalid characters you can use ${StrFilter}
1 | ${WordReplace} $target " " "" "{}" $output |
1 | ${GetTime} "" "L" $Day $Month $Year $DayOfWeek $Hour $Minute $Second |
Most C++ developers are familiar using with for_each() when iterating over an STL collection. But a few months ago as I read a blog post about the ‘auto’ keyword over at Marc Gregoire’s Blog I was dumbstruck when saw the following example:
[sourcecode language=”cpp”]
for each (auto m in myMap)
{
tcout << _T("Map element ") << m.first << _T(": ");
for each(auto e in m.second)
{
tcout << _T("'") << e << _T("', ");
}
tcout << endl;
}
[/sourcecode]
What the heck was this ‘for each’ without an underscore business? Apparently I’d been painfully unaware of this new syntax since 2004!!! It’s Microsoft/Visual Studio specific. But since my primary project is Windows-based through and through, you can bet I’ll be making use of this beauty to keep my code cleaner.
-CM12
PS. Do note, though, that this syntax automatically dereferences iterators, so it’s not useful if you need to do iterator manipulation.
Today I learned:
Today I learned:
[sourcecode language=”Python”]
SectionGetFlags ${SEC_AI} $0
${If} $0 == ${SF_SELECTED}
[/sourcecode]
I was using the above code and getting inconsistent behavior. Turns out ${SF_SELECTED} is defined in sections.nsh bitmask style. The statement above ONLY works for a section that is selected and has no other attributes set. A read-only section that is selected, for example, will be set to “17” — 1 (selected) + 16 (readonly). Turns out that LogicLib has a way to make life easier:
[sourcecode language=”python”]
${If} ${SectionIsSelected} ${SEC_AI}
[/sourcecode]