//String Processor //v0.2.1 int Preprocess_Buffer[214747]; int PreProcessString(int address){ //Create string tables, and load them with strings. The format is: // $######:String // DOLLAR NUMBER COLON TEXT int string1[]= "$00001:This is the first entry in our string table. $00002:This is the second.$00003:This is the third. "; int string2[]= "$00004:This is number four. $00005:THis is number five. "; int string3[]="$00006:This is our sixth string.$00007:Seven and counting. "; int string4[]="$00008:Eighth. "; int string5[]="$00009:Nine and still going. "; int string6[]="$00010:Address ten, anyone?$00011:Now address eleven. "; int string7[]="$00012:Twelve, aned climbing. "; int string8[]="$00013:Lucky thirteen. "; int string9[]="$00014:The burgular. "; int string10[]="$00015:Last set, last address, number fifteen. "; //Store all the string table pointers in an array. int strings[]={string1,string2,string3,string4,string5,string6,string7,string8,string9,string10}; //! Get the address: int adr_lookup; //A place to store the last located address in a string. int adr_buffer[6]; //A place to store the string address as char. int read_adr_buffer[6]; int q = 0; int e = 0; int r = 0; int t = 0; int u; int i; int adr_index[4]; //3 is the length of the string tied to the address. int matched_adr; int end_of_string; //Convert the addres to char and store it in the buffer. itoa(adr_buffer,address); int checking_adr; //Load each big string table from the array with their pointers for ( ; q <= SizeOfArray(strings); q++ ) { //! <= is intentional here. if ( q == SizeOfArray(strings) return -1; //break; //A safety break from the loop if we scan every string for the address //and we don't find it. while ( !matched_adr && !end_of_string ) { //Scan the string, and find the $ char for ( ; w <= SizeOfArray(strings[q]); w++ ) { if ( w == SizeOfArray(strings) { end_of_string = 1; //We finished parsing this string. Time to try the next one. break; //Returns to 'q' loop, and sets the next string pointer in the list, to scan it. } if ( matched_adr ) break; //Eits the for loop, back to tht while loop, and the string is copied to the processing buffer. //If the loop is still running... if ( strings[q][w] == IsChar(CHAR_DOLLAR) ) { //We found an address, let's store it. adr_index[0] = q; adr_index[1] = w; //0 is the string pointer, 1 is the index with the $ token for ( e = adr_index[1]; e < SizeOfArray(adr_index[1]); e++ ) { //Find a colon if ( adr_index[1][e] == IsChar(CHAR_COLON) ) { //We found a colon, so store it... adr_index[2] = e; //2 is the index of the colon, so we know where to end the loop. //Copy the address into the buffer, and compare the two buffers. t = 0; //Clear this, as we'll need it. for ( r = adr_index[1]; r < adr_index[2]; r++ ) { read_adr_buffer[t] = adr_index[0][r]; t++; //Store into the buffer. checking_adr = 1; } if ( checking_adr ) break; } } //Compare the read buffer to the lookup buffer. //Store the value we read into read_adr_buffer by //converting it into a number: adr_lookup = atoi(read_adr_buffer); //See if it matches: if ( adr_lookup == address ) { matched_adr = 1; break; } else { matched_adr = 0; continue; } //for ( u = 0; q < 6; u++ ) { //if ( read_adr_buffer[u] == adr_buffer[u] ) matched_adr = 1; // else { // matched_adr = 0; //not a match // //Go back to w, and start on the position next in the list. // break; // } //} } } if ( matched_adr ) { break; //Exit the while loop. } } if ( matched_adr ) { i = 0; arr_index[2]++; //Start one char after the colon. //Store the string: //Use the values that we recorded for the pointer, the first index, and the last index, and copy the string to our main buffer for processing. for ( ; adr_index[2] < SizeOfArray(arr_index[0]; adr_index[2]++ ) { if ( arr_index[0][arr_index[2]] != CHAR_DOLLAR ) { Preprocess_Buffer[i] = arr_index[0][arr_index[2]]; i++; } if ( arr_index[0][arr_index[2]] == CHAR_DOLLAR ) break; } break; //Exit the q loop... } } //If the q loop breaks, the function ends. return 1; //The function tells us that it was successful in finding a string, and that it stored it in the buffer. //We can call if ( PreProcessString(ADDRESS) ) and store it while we check that it was stored. }