/* I do not know if the second call to finder.getValue() is on
* purpose, i.e. if it will return a value different from the first
* call. If it does not, replace it with `val` */
while(finder.findUntil("DT", "\n\r")){
int val = finder.getValue();
if(val >= 1 && val <= 4) {
ip[val - 1] = finder.getValue();
}
if(val >= 5 && val <= 8) {
subnet[val - 5] = finder.getValue();
}
if(val >= 9 && val <= 12) {
gateway[val - 9] = finder.getValue();
}
}
Edit: probably should use else if to save some cycles.
while(finder.findUntil("DT", "\n\r")){
int val = finder.getValue();
ip[(val-1)%4] = finder.getValue();
}
EDIT: This assumes that the first read of val can only return values 1-12. If that is not a good assumption, then adding an if(val >= 1 && val <= 12) would be needed.