Re: options.e in win32lib
- Posted by CChris <christian.cuvier at ag?iculture.go?v.fr> Dec 18, 2007
- 525 views
Mike777 wrote: > > CChris wrote: > > > > Mike777 wrote: > > > > > > Not sure about this, but I was trying to use the getOpt() function and > > > found > > > it didn't work. Peeking inside options.e I *think* I found two places > > > where > > > changes could be right: > > > > > > First -------------------- > > > > > > 153 if match(pCategory, lData) = 1 then > > > > > > should be > > > > > > 153 if match(pCategory, lower(lData)) = 1 then > > > > > > This is fairly obvious in that the most recently acquired lData (on line > > > 147) > > > hasn't yet been "lowered". > > > > > > > Actually, I have changed this part so that several groups may start by the > > same > > letters, like [ Group ] and { \tGroup_2 ]. > > So I replaced > > }}} <eucode> > > if match(pCategory, lData) = 1 then > > lInCategory = w32True > > end if > > </eucode> {{{ > > with > > }}} <eucode> > > if match(pCategory, lower(lData)) = 1 then > > for i=length(pCategory)+1 to length(lData) do > > if lData[i]=' ' or lData[i]='\t' then -- keep scanning > > else > > lInCategory = (lData[i]=']') > > exit > > end if > > end for > > end if > > </eucode> {{{ > > I like it. However, where did you "make the change"? I have downloaded the > 12/15 Win32Lib and it doesn't appear to have been changed there. > I released 70.2e before reading your post, so the change isn't in 2e. It will be in next release, hopefully official 70.3. > > > > Second ------------------ > > > > > > 162 if length(lOptData) >= 2 and lOptData[1] = '"' and > > > lOptData[length(lOptData)] > > > = '"' then > > > lData = lOptData[2..length(lOptData)-1] > > > else > > > > > > might be replaced with: > > > > > > 162 if length(lOptData) >= 2 then > > > if lOptData[1] = '"' and lOptData[length(lOptData)] = '"' then > > > lData = lOptData[2..length(lOptData)-1] > > > else > > > lData = lOptData > > > end if > > > else > > > > > > This merely ensures that lData is reset to the correct part of lOptData if > > > its > > > length is greater than two, whether or not it starts and ends with a > > > quotation > > > mark. I know that doing what I've done obliterates the code beneath it > > > that > > > attempts to change numbers to text and attempts to change text input (yes, > > > no, > > > etc.) to corresponding w32 constants (w32True and w32False). Frankly, I'm > > > not > > > sure that is such a good idea, anyway, so I don't think it is much of a > > > loss. > > > For example, if I have an option with value "Tre rain in Spain if false." > > > I > > > really don't want it to be obliterated in favor of a w32False return > > > value. > > > > > > I have my doubts about anybody actually using this function, since it > > > appears > > > to have been non-functional. > > > > > > Yes, I'm aware of the various libraries in the Archive that deal with ini > > > files, > > > but this seemed like a "simple" place to start. Famous last words, that! > > > > > > If somebody thinks I'm off-base on this issue, or how I raised it, please > > > let > > > me know (or you are likely to see more of the same in the near future). > > > > > > Mike > > > > I don't understand what the issue is. > > I didn't communicate it clearly enough. > > > What appears on the right side of the '=' sign may be either, after > > collating > > any continuation lines and stripping comments off: > > 1/ a double quoted string (so the length is at least 2), in which case the > > quotes > > are stripped and the inner part returned; > > 2/ a sequence of characters that fully converts to a number, in which case > > the > > number is returned. Currency signs are ignored. > > 3/ anything else. In that case, the code tries to identify the sequence as > > one > > of special meaning: > > 3a/ If some is recognised, its associated boolean value is returned > > I think 3a is my issue. I have a number of ini files that have long strings > to the right of the equals sign and they are not enclosed in double quotes. > If any part of that string has the characters "false" (ignore the double > quotes > for this purpose) then the return value is 0. > Not true. The relevant code is:
if find(lOptData,{"true","yes","on"}) then lData = w32True elsif find(lOptData,{"false","no","off"}) then lData = w32False end if
So, if your .ini line is someVar = yes, I do , the right hand side of '=' is not any of the litteral constants in the code above, so "yes, I do" will be returned (outer whitespace is trimmed) as is. find() and match() are different. HTH CChris > Perhaps there is a standard for ini files somewhere and those who wrote these > particular ini files are not conforming to the standards as written. No > matter, > I guess, now that I know the standard as intended, since I will be in charge > of the ini files that my application uses, I can live with it. > > > 3b/ else lData=lOptData is returned. > > > The option you quoted has double quotes around it > > That was my miscommunication. I meant to imply that it would be those > characters, > without the double quotes. Sorry. > > , so the first part will apply. > > Be sure to use double quotes if the option starts with a digit, but isn't to > > be treated as a number > > Could you post an example of behaviour you wouldn't expect or wish, but > > actually > > takes place? > > I think it will work, now. > > Thanks > > Mike