Advertisement
ZoriaRPG

log.print() for ZScript

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