forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


@iniread: no way to get a list with all keynames?

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
icon
Newbie


Joined: 17 Aug 2002
Posts: 7

PostPosted: Mon Jan 19, 2004 6:10 pm    Post subject: @iniread: no way to get a list with all keynames? Reply with quote

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
View user's profile Send private message
Skit3000
Admin Team


Joined: 11 May 2002
Posts: 2166
Location: The Netherlands

PostPosted: Mon Jan 19, 2004 6:33 pm    Post subject: Reply with quote

If you are using VDS 5, this should do the trick... Smile

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
View user's profile Send private message
icon
Newbie


Joined: 17 Aug 2002
Posts: 7

PostPosted: Mon Jan 19, 2004 6:59 pm    Post subject: Thanks Reply with quote

Wow, thanks very much for the fast answer. It's working very well.

Very Happy
Back to top
View user's profile Send private message
jules
Professional Member
Professional Member


Joined: 14 Sep 2001
Posts: 1043
Location: Cumbria, UK

PostPosted: Mon Jan 19, 2004 7:11 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Serge
Professional Member
Professional Member


Joined: 04 Mar 2002
Posts: 1480
Location: Australia

PostPosted: Tue Jan 20, 2004 1:50 am    Post subject: Reply with quote

icon, would xini.dll be any good for you? it's available from vdsworld http://www.vdsworld.com/index.php?page=search&index=4&keywords=ini&authorid=&extend=1 4th one down

serge

_________________
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Page 1 of 1

 
Jump to:  
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

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group