07-24-2012, 06:40 AM
Macro Macro1792
Also can be used API function GetPrivateProfileSection.
To add variables to a string, there are 2 ways:
1. Put F before the string, and insert variables enclosed in { }. Example: F"string {variable} string"
2. Use function str.format.
When using in regular expression, enclose variables in \Q \E. Then variable text is interpreted as simple text, not as regular expression.
out
str lines=
;[config1]
;abc
;
;[config2]
;cde
;fgh
;ijk
;
;[config3]
;etc...
str var_config="config2"
str x
if findrx(lines F"(?s)^\Q[{var_config}]\E(.+?)(?:^\[|\z)" 0 8 x 1)>=0
,x.trim
,out x
else out "not found"
Also can be used API function GetPrivateProfileSection.
To add variables to a string, there are 2 ways:
1. Put F before the string, and insert variables enclosed in { }. Example: F"string {variable} string"
2. Use function str.format.
When using in regular expression, enclose variables in \Q \E. Then variable text is interpreted as simple text, not as regular expression.