Advertisement
ZoriaRPG

TraceError.zs v0.2

Nov 13th, 2018
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 12.91 KB | None | 0 0
  1. void TraceError(int s, int v) //what if we use an array literal for the inputs?. No, then we still don't have overloaded strings
  2. {
  3.     int main_buf[2048];
  4.     int buffer_pos; int string_pos; int q;
  5.     for ( ; s[string_pos] != '%'; ++string_pos )
  6.     {
  7.         main_buf[buffer_pos] = s[string_pos]; //copy until we reach %
  8.         ++buffer_pos; //we increment both iterators
  9.     }
  10.     //Now, we found an insertion token, so insert it
  11.    
  12.         //if ( s[string_pos] != '%' ) //copy the buffer text over to the buffer, until we find our token
  13.         //{
  14.         //  main_buf[buffer_pos] = s[string_pos];
  15.         //  ++buffer_pos;
  16.         //}
  17.         //else //found a special token
  18.         //{
  19.     switch(s[string_pos+1]) //read ahead, one vhar beyond '%'
  20.     {
  21.         case 'S';
  22.         case 's':
  23.         {
  24.             //++buffer_pos; //skip over the token
  25.             //main_buf[buffer_pos+q+1] = ' '; //add a trailing space
  26.             for ( q = 0; v[q]; ++q ) //until we reach NULL, imnsert the substring
  27.             {
  28.                 main_buf[buffer_pos] = v[q];    //copy the string passed as a param
  29.                                 //over to the buffer
  30.                 ++buffer_pos;
  31.             }
  32.            
  33.             //main_buf[buffer_pos+q+1] = ' '; //add a trailing space
  34.             //++buffer_pos; //set up the buffer for the next char
  35.             break;
  36.                
  37.         }
  38.         case 'F':
  39.         case 'f':
  40.         {
  41.             //++buffer_pos; //skip over the token
  42.             //main_buf[buffer_pos+q+1] = ' '; //add a trailing space
  43.             int i_val[12];
  44.             ftoa(i_val,v);
  45.             for ( q = 0; i_val[q]; ++q )
  46.             {
  47.                 main_buf[buffer_pos] = i_val[q];
  48.                 ++buffer_pos;
  49.             }
  50.             //main_buf[buffer_pos+q+1] = ' '; //add a trailing space
  51.             //++buffer_pos; //set up the buffer for the next char
  52.             break;
  53.  
  54.         }
  55.         case 'D':
  56.         case 'd':
  57.         {
  58.             //++buffer_pos;
  59.             //main_buf[buffer_pos+q+1] = ' '; //add a trailing space
  60.             int f_val[12];
  61.             itoa(f_val,v);
  62.             for ( q = 0; f_val[q] ; ++q )
  63.             {
  64.                 main_buf[buffer_pos] = f_val[q];
  65.                 ++buffer_pos;
  66.             }
  67.             //main_buf[buffer_pos+q+1] = ' '; //add a trailing space
  68.             //++buffer_pos; //set up the buffer for the next char
  69.             break;
  70.  
  71.         }
  72.         default: ++buffer_pos; break;
  73.     }
  74.     //we copied the insertion, so, resume the rest o the string:
  75.     for ( ; s[string_pos]; ++string_pos ) //Until we reach NULL
  76.     {
  77.         //copy the rest of the string:
  78.         main_buf[buffer_pos] = s[string_pos];
  79.         ++buffer_pos;
  80.     }
  81.     //main_buf[buffer_pos+1] = '\n'; Put this in the string!
  82.         TraceS(main_buf); //TraceNL();
  83.     }
  84.    
  85. void TraceError(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
  86. {
  87.     int main_buf[2048];
  88.     int buffer_pos; int string_pos; int q;
  89.     for ( ; s[string_pos] != '%'; ++string_pos )
  90.     {
  91.         main_buf[buffer_pos] = s[string_pos];
  92.         ++buffer_pos;
  93.     }
  94.    
  95.     int values[]={v1,v2};
  96.     int val_indx;
  97.     do
  98.     {
  99.         switch(s[string_pos+1])
  100.         {
  101.             case 'S':
  102.             case 's':
  103.             {
  104.                 for ( q = 0; v[q]; ++q ) //until we reach NULL
  105.                 {
  106.                     main_buf[buffer_pos+q] = values[val_index[q]];  //copy the string passed as a param
  107.                                     //over to the buffer
  108.                     ++buffer_pos;
  109.                 }
  110.                 break;
  111.                    
  112.             }
  113.             case 'F':
  114.             case 'f':
  115.             {
  116.                 int i_val[12];
  117.                 ftoa(i_val,values[val_index]);
  118.                 for ( q = 0; i_val[q]; ++q ) //until we reach NULL
  119.                 {
  120.                     main_buf[buffer_pos] = i_val[q];
  121.                     ++buffer_pos;
  122.                 }
  123.                 break;
  124.  
  125.             }
  126.             case 'D':
  127.             case 'd':
  128.             {
  129.                 int f_val[12];
  130.                 itoa(f_val,values[val_index]);
  131.                 for ( q = 0; f_val[q] ; ++q )
  132.                 {
  133.                     main_buf[buffer_pos] = f_val[q];
  134.                     ++buffer_pos;
  135.                 }
  136.                 break;
  137.  
  138.             }
  139.             default: ++buffer_pos; break;
  140.         }
  141.         //we copied the insertion, so, resume the rest o the string:
  142.         for ( ; s[string_pos] != '%'; ++string_pos ) //Until we reach NULL
  143.         {
  144.             //copy the rest of the string:
  145.             main_buf[buffer_pos] = s[string_pos];
  146.             ++buffer_pos;
  147.         }
  148.        
  149.         ++val_index; //increase for overloads
  150.        
  151.     }while((s[string_pos])); //until we reach null in the main buffer
  152.    
  153.         TraceS(main_buf); //TraceNL();
  154. }
  155.    
  156. void TraceError(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
  157. {
  158.     int main_buf[2048];
  159.     int buffer_pos; int string_pos; int q;
  160.     for ( ; s[string_pos] != '%'; ++string_pos )
  161.     {
  162.         main_buf[buffer_pos] = s[string_pos];
  163.         ++buffer_pos;
  164.     }
  165.    
  166.     int values[]={v1,v2,v3};
  167.     int val_indx;
  168.     do
  169.     {
  170.         switch(s[string_pos+1])
  171.         {
  172.             case 'S':
  173.             case 's':
  174.             {
  175.                 for ( q = 0; v[q]; ++q ) //until we reach NULL
  176.                 {
  177.                     main_buf[buffer_pos+q] = values[val_index[q]];  //copy the string passed as a param
  178.                                     //over to the buffer
  179.                     ++buffer_pos;
  180.                 }
  181.                 break;
  182.                    
  183.             }
  184.             case 'F':
  185.             case 'f':
  186.             {
  187.                 int i_val[12];
  188.                 ftoa(i_val,values[val_index]);
  189.                 for ( q = 0; i_val[q]; ++q ) //until we reach NULL
  190.                 {
  191.                     main_buf[buffer_pos] = i_val[q];
  192.                     ++buffer_pos;
  193.                 }
  194.                 break;
  195.  
  196.             }
  197.             case 'D':
  198.             case 'd':
  199.             {
  200.                 int f_val[12];
  201.                 itoa(f_val,values[val_index]);
  202.                 for ( q = 0; f_val[q] ; ++q )
  203.                 {
  204.                     main_buf[buffer_pos] = f_val[q];
  205.                     ++buffer_pos;
  206.                 }
  207.                 break;
  208.  
  209.             }
  210.             default: ++buffer_pos; break;
  211.         }
  212.         //we copied the insertion, so, resume the rest o the string:
  213.         for ( ; s[string_pos] != '%'; ++string_pos ) //Until we reach NULL
  214.         {
  215.             //copy the rest of the string:
  216.             main_buf[buffer_pos] = s[string_pos];
  217.             ++buffer_pos;
  218.         }
  219.        
  220.         ++val_index; //increase for overloads
  221.        
  222.     }while((s[string_pos]));
  223.    
  224.         TraceS(main_buf); //TraceNL();
  225. }
  226.    
  227. void TraceError(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
  228. {
  229.     int main_buf[2048];
  230.     int buffer_pos; int string_pos; int q;
  231.     for ( ; s[string_pos] != '%'; ++string_pos )
  232.     {
  233.         main_buf[buffer_pos] = s[string_pos];
  234.         ++buffer_pos;
  235.     }
  236.  
  237.     int values[]={v1,v2,v3,v4};
  238.     int val_indx;
  239.     do
  240.     {
  241.         switch(s[string_pos+1])
  242.         {
  243.             case 'S':
  244.             case 's':
  245.             {
  246.                 for ( q = 0; v[q]; ++q ) //until we reach NULL
  247.                 {
  248.                     main_buf[buffer_pos+q] = values[val_index[q]];  //copy the string passed as a param
  249.                                     //over to the buffer
  250.                     ++buffer_pos;
  251.                 }
  252.                 break;
  253.                    
  254.             }
  255.             case 'F':
  256.             case 'f':
  257.             {
  258.                 int i_val[12];
  259.                 ftoa(i_val,values[val_index]);
  260.                 for ( q = 0; i_val[q]; ++q ) //until we reach NULL
  261.                 {
  262.                     main_buf[buffer_pos] = i_val[q];
  263.                     ++buffer_pos;
  264.                 }
  265.                 break;
  266.  
  267.             }
  268.             case 'D':
  269.             case 'd':
  270.             {
  271.                 int f_val[12];
  272.                 itoa(f_val,values[val_index]);
  273.                 for ( q = 0; f_val[q] ; ++q )
  274.                 {
  275.                     main_buf[buffer_pos] = f_val[q];
  276.                     ++buffer_pos;
  277.                 }
  278.                 break;
  279.  
  280.             }
  281.             default: ++buffer_pos; break;
  282.         }
  283.         //we copied the insertion, so, resume the rest o the string:
  284.         for ( ; s[string_pos] != '%'; ++string_pos ) //Until we reach NULL
  285.         {
  286.             //copy the rest of the string:
  287.             main_buf[buffer_pos] = s[string_pos];
  288.             ++buffer_pos;
  289.         }
  290.        
  291.         ++val_index; //increase for overloads
  292.        
  293.     }while((s[string_pos]));
  294.    
  295.         TraceS(main_buf); //TraceNL();
  296. }
  297.  
  298. void TraceError(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
  299. {
  300.     int main_buf[2048];
  301.     int buffer_pos; int string_pos; int q;
  302.     for ( ; s[string_pos] != '%'; ++string_pos )
  303.     {
  304.         main_buf[buffer_pos] = s[string_pos];
  305.         ++buffer_pos;
  306.     }
  307.    
  308.     int values[]={v1,v2,v3,v4,v5};
  309.     int val_indx;
  310.     do
  311.     {
  312.         switch(s[string_pos+1])
  313.         {
  314.             case 'S':
  315.             case 's':
  316.             {
  317.                 for ( q = 0; v[q]; ++q ) //until we reach NULL
  318.                 {
  319.                     main_buf[buffer_pos+q] = values[val_index[q]];  //copy the string passed as a param
  320.                                     //over to the buffer
  321.                     ++buffer_pos;
  322.                 }
  323.                 break;
  324.                    
  325.             }
  326.             case 'F':
  327.             case 'f':
  328.             {
  329.                 int i_val[12];
  330.                 ftoa(i_val,values[val_index]);
  331.                 for ( q = 0; i_val[q]; ++q ) //until we reach NULL
  332.                 {
  333.                     main_buf[buffer_pos] = i_val[q];
  334.                     ++buffer_pos;
  335.                 }
  336.                 break;
  337.  
  338.             }
  339.             case 'D':
  340.             case 'd':
  341.             {
  342.                 int f_val[12];
  343.                 itoa(f_val,values[val_index]);
  344.                 for ( q = 0; f_val[q] ; ++q )
  345.                 {
  346.                     main_buf[buffer_pos] = f_val[q];
  347.                     ++buffer_pos;
  348.                 }
  349.                 break;
  350.  
  351.             }
  352.             default: ++buffer_pos; break;
  353.         }
  354.         //we copied the insertion, so, resume the rest o the string:
  355.         for ( ; s[string_pos] != '%'; ++string_pos ) //Until we reach NULL
  356.         {
  357.             //copy the rest of the string:
  358.             main_buf[buffer_pos] = s[string_pos];
  359.             ++buffer_pos;
  360.         }
  361.        
  362.         ++val_index; //increase for overloads
  363.        
  364.     }while((s[string_pos]));
  365.    
  366.         TraceS(main_buf); //TraceNL();
  367. }
  368.  
  369.  
  370. void TraceError(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
  371. {
  372.     int main_buf[2048];
  373.     int buffer_pos; int string_pos; int q;
  374.     for ( ; s[string_pos] != '%'; ++string_pos )
  375.     {
  376.         main_buf[buffer_pos] = s[string_pos];
  377.         ++buffer_pos;
  378.     }
  379.     int values[]={v1,v2,v3,v4,v5,v6};
  380.     int val_indx;
  381.     do
  382.     {
  383.         switch(s[string_pos+1])
  384.         {
  385.             case 'S':
  386.             case 's':
  387.             {
  388.                 for ( q = 0; v[q]; ++q ) //until we reach NULL
  389.                 {
  390.                     main_buf[buffer_pos+q] = values[val_index[q]];  //copy the string passed as a param
  391.                                     //over to the buffer
  392.                     ++buffer_pos;
  393.                 }
  394.                 break;
  395.                    
  396.             }
  397.             case 'F':
  398.             case 'f':
  399.             {
  400.                 int i_val[12];
  401.                 ftoa(i_val,values[val_index]);
  402.                 for ( q = 0; i_val[q]; ++q ) //until we reach NULL
  403.                 {
  404.                     main_buf[buffer_pos] = i_val[q];
  405.                     ++buffer_pos;
  406.                 }
  407.                 break;
  408.  
  409.             }
  410.             case 'D':
  411.             case 'd':
  412.             {
  413.                 int f_val[12];
  414.                 itoa(f_val,values[val_index]);
  415.                 for ( q = 0; f_val[q] ; ++q )
  416.                 {
  417.                     main_buf[buffer_pos] = f_val[q];
  418.                     ++buffer_pos;
  419.                 }
  420.                 break;
  421.  
  422.             }
  423.             default: ++buffer_pos; break;
  424.         }
  425.         //we copied the insertion, so, resume the rest o the string:
  426.         for ( ; s[string_pos] != '%'; ++string_pos ) //Until we reach NULL
  427.         {
  428.             //copy the rest of the string:
  429.             main_buf[buffer_pos] = s[string_pos];
  430.             ++buffer_pos;
  431.         }
  432.        
  433.         ++val_index; //increase for overloads
  434.        
  435.     }while((s[string_pos]));
  436.    
  437.         TraceS(main_buf); //TraceNL();
  438. }
  439.  
  440.  
  441. void TraceError(int s, int v1, int v2, int v3, int v4, int v5, int v6, int v7)
  442. {
  443.     int main_buf[2048];
  444.     int buffer_pos; int string_pos; int q;
  445.     for ( ; s[string_pos] != '%'; ++string_pos )
  446.     {
  447.         main_buf[buffer_pos] = s[string_pos];
  448.         ++buffer_pos;
  449.     }
  450.    
  451.     int values[]={v1,v2,v3,v4,v5,v6,v7};
  452.     int val_indx;
  453.     do
  454.     {
  455.         switch(s[string_pos+1])
  456.         {
  457.             case 'S':
  458.             case 's':
  459.             {
  460.                 for ( q = 0; v[q]; ++q ) //until we reach NULL
  461.                 {
  462.                     main_buf[buffer_pos+q] = values[val_index[q]];  //copy the string passed as a param
  463.                                     //over to the buffer
  464.                     ++buffer_pos;
  465.                 }
  466.                 break;
  467.                    
  468.             }
  469.             case 'F':
  470.             case 'f':
  471.             {
  472.                 int i_val[12];
  473.                 ftoa(i_val,values[val_index]);
  474.                 for ( q = 0; i_val[q]; ++q ) //until we reach NULL
  475.                 {
  476.                     main_buf[buffer_pos] = i_val[q];
  477.                     ++buffer_pos;
  478.                 }
  479.                 break;
  480.  
  481.             }
  482.             case 'D':
  483.             case 'd':
  484.             {
  485.                 int f_val[12];
  486.                 itoa(f_val,values[val_index]);
  487.                 for ( q = 0; f_val[q] ; ++q )
  488.                 {
  489.                     main_buf[buffer_pos] = f_val[q];
  490.                     ++buffer_pos;
  491.                 }
  492.                 break;
  493.  
  494.             }
  495.             default: ++buffer_pos; break;
  496.         }
  497.         //we copied the insertion, so, resume the rest o the string:
  498.         for ( ; s[string_pos] != '%'; ++string_pos ) //Until we reach NULL
  499.         {
  500.             //copy the rest of the string:
  501.             main_buf[buffer_pos] = s[string_pos];
  502.             ++buffer_pos;
  503.         }
  504.        
  505.         ++val_index; //increase for overloads
  506.        
  507.     }while((s[string_pos]));
  508.    
  509.         TraceS(main_buf); //TraceNL();
  510. }
  511.  
  512.  
  513. void TraceError(int s, int v1, int v2, int v3, int v4, int v5, int v6, int v7, int v8)
  514. {
  515.     int main_buf[2048];
  516.     int buffer_pos; int string_pos; int q;
  517.     for ( ; s[string_pos] != '%'; ++string_pos )
  518.     {
  519.         main_buf[buffer_pos] = s[string_pos];
  520.         ++buffer_pos;
  521.     }
  522.    
  523.     int values[]={v1,v2,v3,v4,v5,v6,v7,v8};
  524.     int val_indx;
  525.     do
  526.     {
  527.         switch(s[string_pos+1])
  528.         {
  529.             case 'S':
  530.             case 's':
  531.             {
  532.                 for ( q = 0; v[q]; ++q ) //until we reach NULL
  533.                 {
  534.                     main_buf[buffer_pos+q] = values[val_index[q]];  //copy the string passed as a param
  535.                                     //over to the buffer
  536.                     ++buffer_pos;
  537.                 }
  538.                 break;
  539.                    
  540.             }
  541.             case 'F':
  542.             case 'f':
  543.             {
  544.                 int i_val[12];
  545.                 ftoa(i_val,values[val_index]);
  546.                 for ( q = 0; i_val[q]; ++q ) //until we reach NULL
  547.                 {
  548.                     main_buf[buffer_pos] = i_val[q];
  549.                     ++buffer_pos;
  550.                 }
  551.                 break;
  552.  
  553.             }
  554.             case 'D':
  555.             case 'd':
  556.             {
  557.                 int f_val[12];
  558.                 itoa(f_val,values[val_index]);
  559.                 for ( q = 0; f_val[q] ; ++q )
  560.                 {
  561.                     main_buf[buffer_pos] = f_val[q];
  562.                     ++buffer_pos;
  563.                 }
  564.                 break;
  565.  
  566.             }
  567.             default: ++buffer_pos; break;
  568.         }
  569.         //we copied the insertion, so, resume the rest o the string:
  570.         for ( ; s[string_pos] != '%'; ++string_pos ) //Until we reach NULL
  571.         {
  572.             //copy the rest of the string:
  573.             main_buf[buffer_pos] = s[string_pos];
  574.             ++buffer_pos;
  575.         }
  576.        
  577.         ++val_index; //increase for overloads
  578.        
  579.     }while((s[string_pos]));
  580.     //main_buf[buffer_pos+1] = '\n'; //Put the NL char in the input string!
  581.    
  582.         TraceS(main_buf); //TraceNL();
  583. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement