| View previous topic :: View next topic |
| Author |
Message |
icon Newbie
Joined: 17 Aug 2002 Posts: 7
|
Posted: Mon Jan 19, 2004 6:10 pm Post subject: @iniread: no way to get a list with all keynames? |
|
|
I should get a list with all key names from a specific section name in a ini file. But it seems that this is not supported by @iniread, if you don't know the key name.
Any ideas how to solve this? |
|
| Back to top |
|
 |
Skit3000 Admin Team

Joined: 11 May 2002 Posts: 2166 Location: The Netherlands
|
Posted: Mon Jan 19, 2004 6:33 pm Post subject: |
|
|
If you are using VDS 5, this should do the trick...
| Code: | #define function,inifile
rem Get all sections from an INI file
info @inifile(sections,@windir()\win.ini)
rem Get all keys + values from an INI file
info @inifile(keys,@windir()\win.ini)
rem Get all keys + values from a specified section of an INI file
info @inifile(keys,@windir()\win.ini,files)
exit
:Inifile
list create,30
list loadfile,30,%2
if @equal(%1,SECTIONS)
%z = 0
%%output =
repeat
if @equal(@substr(@trim(@item(30,%z)),1,1),"[")
%%output = %%output@cr()@substr(@trim(@item(30,%z)),2,@diff(@len(@trim(@item(30,%z))),1))
end
%z = @succ(%z)
until @equal(%z,@count(30))
end
if @equal(%1,keys)
if @equal(%3,)
%z = 0
%%output =
repeat
if @both(@unequal(@substr(@trim(@item(30,%z)),1,1),"["),@unequal(@substr(@trim(@item(30,%z)),1,1),";"))
if @unequal(@trim(@item(30,%z)),)
%%output = %%output@cr()@substr(@trim(@item(30,%z)),1,@pred(@pos("=",@trim(@item(30,%z)))))
end
end
%z = @succ(%z)
until @equal(%z,@count(30))
else
%z = 0
%%output =
repeat
if @equal(@trim(@item(30,%z)),"["%3"]")
%z = @succ(%z)
repeat
if @both(@unequal(@substr(@item(30,%z),1,1),";"),@unequal(@substr(@item(30,%z),1,1),"["))
if @unequal(@trim(@item(30,%z)),)
%%output = %%output@cr()@substr(@trim(@item(30,%z)),1,@pred(@pos("=",@trim(@item(30,%z)))))
end
end
%z = @succ(%z)
until @equal(@substr(@trim(@item(30,%z)),1,1),"[")@equal(%z,@count(30))
end
%z = @succ(%z)
until @equal(%z,@count(30))
end
end
list close,30
exit %%output |
The output is seperated by @cr()s, so you can assign it to a list if you want. _________________ [ Add autocomplete functionality to your VDS IDE windows! ]
Voor Nederlandse beginners met VDS: bekijk ook eens deze tutorial!
Last edited by Skit3000 on Mon Jan 19, 2004 7:32 pm; edited 1 time in total |
|
| Back to top |
|
 |
icon Newbie
Joined: 17 Aug 2002 Posts: 7
|
Posted: Mon Jan 19, 2004 6:59 pm Post subject: Thanks |
|
|
Wow, thanks very much for the fast answer. It's working very well.
 |
|
| Back to top |
|
 |
jules Professional Member


Joined: 14 Sep 2001 Posts: 1043 Location: Cumbria, UK
|
Posted: Mon Jan 19, 2004 7:11 pm Post subject: |
|
|
This might be of interest, too:
| Code: |
#define function,inivals
# %R = @inivals(<ini_file>,<ini_sect>)
:inivals
%R =
LOADLIB KERNEL32
if @ok()
%B = @fill(2048,,Z)
%N = @lib(KERNEL32,GetPrivateProfileSectionA,int:,str:%2,@addr("%B"),int:2048,str:%1)
if @greater(%N,0)
%I = 1
repeat
%C = @val(@substr(%B,%I))
if @zero(%C)
%R = %R@cr()
else
%R = %R@chr(%C)
end
%I = @succ(%I)
until @greater(%I,%N)
else
%R =
end
FREELIB kernel32.dll
end
exit %R
|
_________________ The Tech Pro
www.tech-pro.net |
|
| Back to top |
|
 |
Serge Professional Member


Joined: 04 Mar 2002 Posts: 1480 Location: Australia
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|