Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- script typedef ffc namespace;
- ffc script log
- {
- void run()
- {
- print("Testing %s\n","log.print()");
- print("Test Number: %d\n",1);
- print("Testing %s, %s\n","log.print()","with iteration.");
- print("Test %s %d\n","Number:",2);
- }
- void print(int s, int v) //what if we use an array literal for the inputs?. No, then we still don't have overloaded strings
- {
- int main_buf[2048];
- int buffer_pos; int string_pos; int q;
- for ( ; s[string_pos] != '%'; ++string_pos )
- {
- main_buf[buffer_pos] = s[string_pos]; //copy until we reach %
- ++buffer_pos; //we increment both iterators
- }
- //Now, we found an insertion token, so insert it
- //if ( s[string_pos] != '%' ) //copy the buffer text over to the buffer, until we find our token
- //{
- // main_buf[buffer_pos] = s[string_pos];
- // ++buffer_pos;
- //}
- //else //found a special token
- //{
- switch(s[string_pos+1]) //read ahead, one vhar beyond '%'
- {
- case 'S':
- case 's':
- {
- //++buffer_pos; //skip over the token
- //main_buf[buffer_pos+q+1] = ' '; //add a trailing space
- for ( q = 0; v[q]; ++q ) //until we reach NULL, imnsert the substring
- {
- main_buf[buffer_pos] = v[q]; //copy the string passed as a param
- //over to the buffer
- ++buffer_pos;
- }
- //main_buf[buffer_pos+q+1] = ' '; //add a trailing space
- //++buffer_pos; //set up the buffer for the next char
- break;
- }
- case 'F':
- case 'f':
- {
- //++buffer_pos; //skip over the token
- //main_buf[buffer_pos+q+1] = ' '; //add a trailing space
- int i_val[12];
- ftoa(i_val,v);
- for ( q = 0; i_val[q]; ++q )
- {
- main_buf[buffer_pos] = i_val[q];
- ++buffer_pos;
- }
- //main_buf[buffer_pos+q+1] = ' '; //add a trailing space
- //++buffer_pos; //set up the buffer for the next char
- break;
- }
- case 'D':
- case 'd':
- {
- //++buffer_pos;
- //main_buf[buffer_pos+q+1] = ' '; //add a trailing space
- int f_val[12];
- itoa(f_val,v);
- for ( q = 0; f_val[q] ; ++q )
- {
- main_buf[buffer_pos] = f_val[q];
- ++buffer_pos;
- }
- //main_buf[buffer_pos+q+1] = ' '; //add a trailing space
- //++buffer_pos; //set up the buffer for the next char
- break;
- }
- default: ++buffer_pos; break;
- }
- //we copied the insertion, so, resume the rest o the string:
- for ( ; s[string_pos]; ++string_pos ) //Until we reach NULL
- {
- //copy the rest of the string:
- main_buf[buffer_pos] = s[string_pos];
- ++buffer_pos;
- }
- //main_buf[buffer_pos+1] = '\n'; Put this in the string!
- TraceS(main_buf); //TraceNL();
- }
- void print(int s, int v1, int v2) //what if we use an array literal for the inputs?. No, then we still don't have overloaded strings
- {
- int main_buf[2048];
- int buffer_pos; int string_pos; int q;
- for ( ; s[string_pos] != '%'; ++string_pos )
- {
- main_buf[buffer_pos] = s[string_pos];
- ++buffer_pos;
- }
- int values[]={v1,v2};
- int val_index;
- do
- {
- switch(s[string_pos+1])
- {
- case 'S':
- case 's':
- {
- for ( q = 0; values[val_index[q]]; ++q ) //until we reach NULL
- {
- main_buf[buffer_pos+q] = values[val_index[q]]; //copy the string passed as a param
- //over to the buffer
- ++buffer_pos;
- }
- break;
- }
- case 'F':
- case 'f':
- {
- int i_val[12];
- ftoa(i_val,values[val_index]);
- for ( q = 0; i_val[q]; ++q ) //until we reach NULL
- {
- main_buf[buffer_pos] = i_val[q];
- ++buffer_pos;
- }
- break;
- }
- case 'D':
- case 'd':
- {
- int f_val[12];
- itoa(f_val,values[val_index]);
- for ( q = 0; f_val[q] ; ++q )
- {
- main_buf[buffer_pos] = f_val[q];
- ++buffer_pos;
- }
- break;
- }
- default: ++buffer_pos; break;
- }
- //we copied the insertion, so, resume the rest o the string:
- for ( ; s[string_pos] != '%'; ++string_pos ) //Until we reach NULL
- {
- //copy the rest of the string:
- main_buf[buffer_pos] = s[string_pos];
- ++buffer_pos;
- }
- ++val_index; //increase for overloads
- }while((s[string_pos])); //until we reach null in the main buffer
- TraceS(main_buf); //TraceNL();
- }
- void print(int s, int v1, int v2, int v3) //what if we use an array literal for the inputs?. No, then we still don't have overloaded strings
- {
- int main_buf[2048];
- int buffer_pos; int string_pos; int q;
- for ( ; s[string_pos] != '%'; ++string_pos )
- {
- main_buf[buffer_pos] = s[string_pos];
- ++buffer_pos;
- }
- int values[]={v1,v2,v3};
- int val_index;
- do
- {
- switch(s[string_pos+1])
- {
- case 'S':
- case 's':
- {
- for ( q = 0; values[val_index[q]]; ++q ) //until we reach NULL
- {
- main_buf[buffer_pos+q] = values[val_index[q]]; //copy the string passed as a param
- //over to the buffer
- ++buffer_pos;
- }
- break;
- }
- case 'F':
- case 'f':
- {
- int i_val[12];
- ftoa(i_val,values[val_index]);
- for ( q = 0; i_val[q]; ++q ) //until we reach NULL
- {
- main_buf[buffer_pos] = i_val[q];
- ++buffer_pos;
- }
- break;
- }
- case 'D':
- case 'd':
- {
- int f_val[12];
- itoa(f_val,values[val_index]);
- for ( q = 0; f_val[q] ; ++q )
- {
- main_buf[buffer_pos] = f_val[q];
- ++buffer_pos;
- }
- break;
- }
- default: ++buffer_pos; break;
- }
- //we copied the insertion, so, resume the rest o the string:
- for ( ; s[string_pos] != '%'; ++string_pos ) //Until we reach NULL
- {
- //copy the rest of the string:
- main_buf[buffer_pos] = s[string_pos];
- ++buffer_pos;
- }
- ++val_index; //increase for overloads
- }while((s[string_pos]));
- TraceS(main_buf); //TraceNL();
- }
- void print(int s, int v1, int v2, int v3, int v4) //what if we use an array literal for the inputs?. No, then we still don't have overloaded strings
- {
- int main_buf[2048];
- int buffer_pos; int string_pos; int q;
- for ( ; s[string_pos] != '%'; ++string_pos )
- {
- main_buf[buffer_pos] = s[string_pos];
- ++buffer_pos;
- }
- int values[]={v1,v2,v3,v4};
- int val_index;
- do
- {
- switch(s[string_pos+1])
- {
- case 'S':
- case 's':
- {
- for ( q = 0; values[val_index[q]]; ++q ) //until we reach NULL
- {
- main_buf[buffer_pos+q] = values[val_index[q]]; //copy the string passed as a param
- //over to the buffer
- ++buffer_pos;
- }
- break;
- }
- case 'F':
- case 'f':
- {
- int i_val[12];
- ftoa(i_val,values[val_index]);
- for ( q = 0; i_val[q]; ++q ) //until we reach NULL
- {
- main_buf[buffer_pos] = i_val[q];
- ++buffer_pos;
- }
- break;
- }
- case 'D':
- case 'd':
- {
- int f_val[12];
- itoa(f_val,values[val_index]);
- for ( q = 0; f_val[q] ; ++q )
- {
- main_buf[buffer_pos] = f_val[q];
- ++buffer_pos;
- }
- break;
- }
- default: ++buffer_pos; break;
- }
- //we copied the insertion, so, resume the rest o the string:
- for ( ; s[string_pos] != '%'; ++string_pos ) //Until we reach NULL
- {
- //copy the rest of the string:
- main_buf[buffer_pos] = s[string_pos];
- ++buffer_pos;
- }
- ++val_index; //increase for overloads
- }while((s[string_pos]));
- TraceS(main_buf); //TraceNL();
- }
- void print(int s, int v1, int v2, int v3, int v4, int v5) //what if we use an array literal for the inputs?. No, then we still don't have overloaded strings
- {
- int main_buf[2048];
- int buffer_pos; int string_pos; int q;
- for ( ; s[string_pos] != '%'; ++string_pos )
- {
- main_buf[buffer_pos] = s[string_pos];
- ++buffer_pos;
- }
- int values[]={v1,v2,v3,v4,v5};
- int val_index;
- do
- {
- switch(s[string_pos+1])
- {
- case 'S':
- case 's':
- {
- for ( q = 0; values[val_index[q]]; ++q ) //until we reach NULL
- {
- main_buf[buffer_pos+q] = values[val_index[q]]; //copy the string passed as a param
- //over to the buffer
- ++buffer_pos;
- }
- break;
- }
- case 'F':
- case 'f':
- {
- int i_val[12];
- ftoa(i_val,values[val_index]);
- for ( q = 0; i_val[q]; ++q ) //until we reach NULL
- {
- main_buf[buffer_pos] = i_val[q];
- ++buffer_pos;
- }
- break;
- }
- case 'D':
- case 'd':
- {
- int f_val[12];
- itoa(f_val,values[val_index]);
- for ( q = 0; f_val[q] ; ++q )
- {
- main_buf[buffer_pos] = f_val[q];
- ++buffer_pos;
- }
- break;
- }
- default: ++buffer_pos; break;
- }
- //we copied the insertion, so, resume the rest o the string:
- for ( ; s[string_pos] != '%'; ++string_pos ) //Until we reach NULL
- {
- //copy the rest of the string:
- main_buf[buffer_pos] = s[string_pos];
- ++buffer_pos;
- }
- ++val_index; //increase for overloads
- }while((s[string_pos]));
- TraceS(main_buf); //TraceNL();
- }
- void print(int s, int v1, int v2, int v3, int v4, int v5, int v6) //what if we use an array literal for the inputs?. No, then we still don't have overloaded strings
- {
- int main_buf[2048];
- int buffer_pos; int string_pos; int q;
- for ( ; s[string_pos] != '%'; ++string_pos )
- {
- main_buf[buffer_pos] = s[string_pos];
- ++buffer_pos;
- }
- int values[]={v1,v2,v3,v4,v5,v6};
- int val_index;
- do
- {
- switch(s[string_pos+1])
- {
- case 'S':
- case 's':
- {
- for ( q = 0; values[val_index[q]]; ++q ) //until we reach NULL
- {
- main_buf[buffer_pos+q] = values[val_index[q]]; //copy the string passed as a param
- //over to the buffer
- ++buffer_pos;
- }
- break;
- }
- case 'F':
- case 'f':
- {
- int i_val[12];
- ftoa(i_val,values[val_index]);
- for ( q = 0; i_val[q]; ++q ) //until we reach NULL
- {
- main_buf[buffer_pos] = i_val[q];
- ++buffer_pos;
- }
- break;
- }
- case 'D':
- case 'd':
- {
- int f_val[12];
- itoa(f_val,values[val_index]);
- for ( q = 0; f_val[q] ; ++q )
- {
- main_buf[buffer_pos] = f_val[q];
- ++buffer_pos;
- }
- break;
- }
- default: ++buffer_pos; break;
- }
- //we copied the insertion, so, resume the rest o the string:
- for ( ; s[string_pos] != '%'; ++string_pos ) //Until we reach NULL
- {
- //copy the rest of the string:
- main_buf[buffer_pos] = s[string_pos];
- ++buffer_pos;
- }
- ++val_index; //increase for overloads
- }while((s[string_pos]));
- TraceS(main_buf); //TraceNL();
- }
- void print(int s, int v1, int v2, int v3, int v4, int v5, int v6, int v7)
- {
- int main_buf[2048];
- int buffer_pos; int string_pos; int q;
- for ( ; s[string_pos] != '%'; ++string_pos )
- {
- main_buf[buffer_pos] = s[string_pos];
- ++buffer_pos;
- }
- int values[]={v1,v2,v3,v4,v5,v6,v7};
- int val_index;
- do
- {
- switch(s[string_pos+1])
- {
- case 'S':
- case 's':
- {
- for ( q = 0; values[val_index[q]]; ++q ) //until we reach NULL
- {
- main_buf[buffer_pos+q] = values[val_index[q]]; //copy the string passed as a param
- //over to the buffer
- ++buffer_pos;
- }
- break;
- }
- case 'F':
- case 'f':
- {
- int i_val[12];
- ftoa(i_val,values[val_index]);
- for ( q = 0; i_val[q]; ++q ) //until we reach NULL
- {
- main_buf[buffer_pos] = i_val[q];
- ++buffer_pos;
- }
- break;
- }
- case 'D':
- case 'd':
- {
- int f_val[12];
- itoa(f_val,values[val_index]);
- for ( q = 0; f_val[q] ; ++q )
- {
- main_buf[buffer_pos] = f_val[q];
- ++buffer_pos;
- }
- break;
- }
- default: ++buffer_pos; break;
- }
- //we copied the insertion, so, resume the rest o the string:
- for ( ; s[string_pos] != '%'; ++string_pos ) //Until we reach NULL
- {
- //copy the rest of the string:
- main_buf[buffer_pos] = s[string_pos];
- ++buffer_pos;
- }
- ++val_index; //increase for overloads
- }while((s[string_pos]));
- TraceS(main_buf); //TraceNL();
- }
- void print(int s, int v1, int v2, int v3, int v4, int v5, int v6, int v7, int v8)
- {
- int main_buf[2048];
- int buffer_pos; int string_pos; int q;
- for ( ; s[string_pos] != '%'; ++string_pos )
- {
- main_buf[buffer_pos] = s[string_pos];
- ++buffer_pos;
- }
- int values[]={v1,v2,v3,v4,v5,v6,v7,v8};
- int val_index;
- do
- {
- switch(s[string_pos+1])
- {
- case 'S':
- case 's':
- {
- for ( q = 0; values[val_index[q]]; ++q ) //until we reach NULL
- {
- main_buf[buffer_pos+q] = values[val_index[q]]; //copy the string passed as a param
- //over to the buffer
- ++buffer_pos;
- }
- break;
- }
- case 'F':
- case 'f':
- {
- int i_val[12];
- ftoa(i_val,values[val_index]);
- for ( q = 0; i_val[q]; ++q ) //until we reach NULL
- {
- main_buf[buffer_pos] = i_val[q];
- ++buffer_pos;
- }
- break;
- }
- case 'D':
- case 'd':
- {
- int f_val[12];
- itoa(f_val,values[val_index]);
- for ( q = 0; f_val[q] ; ++q )
- {
- main_buf[buffer_pos] = f_val[q];
- ++buffer_pos;
- }
- break;
- }
- default: ++buffer_pos; break;
- }
- //we copied the insertion, so, resume the rest o the string:
- for ( ; s[string_pos] != '%'; ++string_pos ) //Until we reach NULL
- {
- //copy the rest of the string:
- main_buf[buffer_pos] = s[string_pos];
- ++buffer_pos;
- }
- ++val_index; //increase for overloads
- }while((s[string_pos]));
- //main_buf[buffer_pos+1] = '\n'; //Put the NL char in the input string!
- TraceS(main_buf); //TraceNL();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement