Compliments of the season!
I wonder if anyone can help me?
I have an ini file with the following info:
Code:
[U01]
Data=1,1,1,1
Attrib=1,3
[U02]
Data=2,2,2,2,
Attrib=1,
[U03]
Data=0,3,0,3
Attrib=3,
The ini can have up to 99 sections
Not all sections may be included in the ini. i.e It may only have sections U01, U05, U99.
What I need to be able to do is
1. Find out if a specific data string is in the data element of any of the sections. Note: there will be no duplications in the Data element. i.e. "0,3,0,3" will only be found in the Data element of one section.
2. If the data string is found, establish which Section the data string is in. i.e. U03.
I can do this the long and clumsy way using the following for U01 to U99:
Code:
var U01 = GetINIFileData(SYSTEM_PUBLICATION_DIR"+Student+".ini", "U01", "Data")
var U02 = GetINIFileData(SYSTEM_PUBLICATION_DIR"+Student+".ini", "U02", "Data")
var U03 = GetINIFileData(SYSTEM_PUBLICATION_DIR"+Student+".ini", "U03", "Data") //etc to U99
var testdata=U01+"f,"+U02+"f,"+U03+"f," // etc, up to U99 ("f" is being used as a terminator)
var datatrue=String.contains(testdata,UserData)// UserData is the data that needs to be compared with the elements data i.e 0,3,0,3,
if ( String.contains(testdata,UserData)){
ValidData=1
DataNo =""
if (U01 == UserData){
DataNo = "U01"
}
if (U02 == UserData){
DataNo = "U02"
}
if (U03 == UserData){
DataNo = "U03"
}// would need to do this for U01 to U99
var UserAttrib = GetINIFileData(SYSTEM_PUBLICATION_DIR"+Student+".ini", DataNo", "Attrib")
}
Else {
ValidData=0
}
How can I do this more efficiently
Regards
Neil