|
-
September 26th, 2008, 03:34 PM
#1
GetPrivateProfileString Reading Section With Multiple Keys
I want to know if it is possible to use GetPrivateProfileString to read a section where the keys are duplicate. I try it, but I can only retreive one key. This is my file format
[Section Name]
KeyOne = ItemOne
KeyOne = ItemTwo
KeyOne = ItemThree
For any reason, I can only retrieve item one. I want to know and how if I can format GetPrivateString in a form, where the first time it executes it will retrieve keyone from the first line, then go to the next line to read the next keyone.
-
September 26th, 2008, 05:51 PM
#2
Re: GetPrivateProfileString Reading Section With Multiple Keys
if it is possible to use GetPrivateProfileString to read a section where the keys are duplicate.
No.
Put 2 red sweaters in a box, and ask a bystander to get 'the red sweater' out of the box. The first question you get is 'which red sweater'. That's why you can only retrieve 1 item.
-
September 26th, 2008, 07:07 PM
#3
Re: GetPrivateProfileString Reading Section With Multiple Keys
Why are you having the same names in the first place ?
-
September 29th, 2008, 09:45 AM
#4
Re: GetPrivateProfileString Reading Section With Multiple Keys
In this case, I may need to use getline from std library to retrieve the items which are duplicate. So how can I use getline in this particular case?
-
September 29th, 2008, 09:52 AM
#5
Re: GetPrivateProfileString Reading Section With Multiple Keys
A better question is why do you have duplicates and how can you remove them.
-
September 29th, 2008, 10:38 AM
#6
Re: GetPrivateProfileString Reading Section With Multiple Keys
I try to use getline, but getline only stop reading before delimiter. I want to start reading after '=', not before. Is there a way I can modify it.
PHP Code:
streamFile.getline(myChar, 10, '=');
-
September 29th, 2008, 11:41 AM
#7
Re: GetPrivateProfileString Reading Section With Multiple Keys
A better question is why do you have duplicates and how can you remove them
-
September 29th, 2008, 12:05 PM
#8
Re: GetPrivateProfileString Reading Section With Multiple Keys
this is not an .ini file. It is an special purpose text file
-
September 29th, 2008, 12:35 PM
#9
Re: GetPrivateProfileString Reading Section With Multiple Keys
 Originally Posted by vcstarter
this is not an .ini file. It is an special purpose text file
Sure looks like an INI. Regardless, why not come up with unique names?
-
September 29th, 2008, 12:56 PM
#10
Re: GetPrivateProfileString Reading Section With Multiple Keys
I cannot modify the file. It is given as is
-
September 29th, 2008, 02:43 PM
#11
Re: GetPrivateProfileString Reading Section With Multiple Keys
Then write your own parser!
It is nor difficult: read each string, search for the '=', left part (before '=') would be the key and the rest (after the '=') - the value.
Victor Nijegorodov
-
September 29th, 2008, 04:04 PM
#12
Re: GetPrivateProfileString Reading Section With Multiple Keys
OK I will do so, this is basically what I am working on now
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|