Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
beginner: regex ini-like file and variable within regex
#7
Macro Macro1793
Code:
Copy      Help
out
;---------------
;create ini file for testing
str lines=
;[config1]
;abc
;
;[config2]
;cde=1
;fgh=2
;ijk=3
;
;[config3]
;etc...
str iniFile.expandpath("$temp$\qm48825.ini")
lines.setfile(iniFile)
;---------------

str var_config="config2"
str x

int nSize=100*1024; x.all(nSize)
x.fix(GetPrivateProfileSection(var_config x nSize iniFile))
if x.len
,;GetPrivateProfileSection returns multistring; show each string
,lpstr s=x
,rep
,,if(!s[0]) break
,,out s
,,s+len(s)+1
else out "not found"

;this is not perfect code. 1. Need to ensure that nSize is big enough; 2. Need to use Unicode function version to support Unicode in ini file path.


Messages In This Thread

Forum Jump:


Users browsing this thread: 5 Guest(s)