class SpotParser{ String [] memory; SpotParser(){ memory = new String[1]; } void addLine(String command){ if(memory[0] == null){ memory[0] = command; } else { memory = append(memory, command); } } void clearMemory(){ memory = new String[1]; } void save(String fileName){ if(memory[0] != null){ saveStrings(fileName, memory); println("saved " + fileName); } else { println("nothing to save"); } } void load(String fileName){ memory = loadStrings(fileName); println("spots loaded"); } void export(){ clearMemory(); for(int i = 0; i < net.spot.length; i++){ addLine("spot("+net.spot[i].x+","+net.spot[i].y+","+net.spot[i].id+")"+"wide ="+net.spot[i].wide); } println("spots added to parser"); } void port(){ if(memory[0] != null){ net.spot = new Spot[memory.length]; for(int i = 0; i < memory.length; i++){ boolean goodLine = false; float [] params = float(split(memory[i].substring(memory[i].indexOf('(')+1, memory[i].lastIndexOf(')')), ",")); if(memory[i].startsWith("spot")){ if(params.length == 3){ net.spot[i] = new Spot(params[0], params[1], int(params[2])); goodLine = true; } else { println("spot parameters incorrect"); } } if(!goodLine){ println("line number:"+i+" bad"); } } println("spots read from parser"); } } }