Prev | Current Page 158 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

indexOf(???=???);
curValLoc = configStr.indexOf(??? & ???);
keyStr = configStr.substr(0, curKeyLoc);
valStr = configStr.substr(curKeyLoc+1, curValLoc - curKeyLoc-1);
htProps.set(keyStr, valStr);
prevKeyLoc = curKeyLoc;
curKeyLoc = configStr.indexOf(???=???, prevKeyLoc+1);
keyStr = configStr.substr(curValLoc+1, curKeyLoc - curValLoc-1);
valStr = configStr.substr(curKeyLoc+1, configStr.length - curKeyLoc-1);
htProps.set(keyStr, valStr);
trace(htProps.get(???item1???));
// Outputs: val1
trace(htProps.get(???item2???));
// Outputs: val2
}
}
The main function provides a number of temporary variables for storing the location of the most recent
search. As you traverse the string contained in the configStr variable, you note the beginning and end
of property and value pairs. You know that a property name will start the string and that property
names exist after an assignment operator ( = ) and before an ampersand ( & ). You also know that the
property values exist at the end of the string and between any ampersand and assignment operator.


Pages:
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170