Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 112

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 112

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 112

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 112
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3368: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3370: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3371: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3372: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
OrbWorks Community Forum • View topic - Hotsync Name to Digits
Page 1 of 1

PostPosted: Thu Apr 05, 2007 7:18 pm
by sangahm
I went back and read the earlier messages on putting in basic registration using hotsync name:
http://pocketc.net/forum/topic.asp?TOPIC_ID=318

However am stumped on how to convert chars to int, using the following line in PocketC:
checksum = checksum + username@[i];

There doesn't seem to be a similar function as username@ in OrbDesigner. I've searched around, and tried different things to Cast and am not getting anywhere.

Any help?

PostPosted: Thu Apr 05, 2007 11:09 pm
by samps
You can get the value of each chararcter of the string in succession, and then add them up as you go:


char a;
int ascii_value;
ascii_value = (int)a;


or if you are getting the chars by parsing through a string, you can do the cast directly:


int ascii_value, sum;
string text;
int counter;

while (counter<=length(text)
{
sum=sum+(int)text[counter];
inc(counter);
}



cheers
Samps

PostPosted: Thu Apr 05, 2007 11:41 pm
by sangahm
Thanks samps. What you suggest was my first thought on how to do it, however it didn't seem to work. Maybe it was casting back when I put it out to the form in the field.text

I'll experiment around a bit more, since it seems that I was actually on the right path, but messing up someplace else.

Edit: Yep, I knew it was something easy. I tried to do a cast on the initial .text field which kept yielding a zero value. Fixing that made everything operational.

PostPosted: Mon May 07, 2007 7:28 pm
by mlambrigger
There is another system which is based on the handango RPNstring system. See the code below:
Code: Select all
/*
   File:         RPNString.oc
   Author:         Lambrigger Marc
   Date:         31 October 2005
   Description:
      Handango RPN string caculation
   Tested:         31 october 2005
*/

/*
   logical operator:
      &&   and
      ||   or
      !   not
      
   test operator
      ==   equal
      >=    greater or equal
      
   bitwise operators
      <<   shift left
      >>   shift right
      ~   invert
      &   and
      |   or
   
   arithmetic operator
      +   plus
      -   minus
      *   multiplication
      /   division
      %   modulo
*/
const int STLEN = 10;

int unstack(int * intstack){
   int i, op = intstack[0];
   for(i=0; i<STLEN-1; i++) intstack[i] = intstack[i+1];
   return op;
}

void instack(int * intstack, int op){
   int i;
   for(i=1; i<STLEN; i++) intstack[STLEN-i] = intstack[STLEN-(i+1)];
   intstack[0] = op;
   return;
}

//      &&   and
   void and(int * intstack){ intstack[0] = unstack(intstack) && intstack[0]; return; }
//      ||   or
   void or(int * intstack){ intstack[0] = unstack(intstack) || intstack[0]; return; }
//      !   not
   void not(int * intstack){ intstack[0] = !intstack[0]; return; }
//      ==   equal
   void equal(int * intstack){ intstack[0] = unstack(intstack) == intstack[0]; return; }
//      >=    greater or equal
   void greater(int * intstack){int op = unstack(intstack); intstack[0] = intstack[0] >= op; return; }
//      <<   shift left
   void shfl(int * intstack){ int op = unstack(intstack); intstack[0] = intstack[0] << op; return; }
//      >>   shift right
   void shfr(int * intstack){ int op = unstack(intstack); intstack[0] = intstack[0] >> op; return; }
//      ~   invert
   void not_b(int * intstack){ intstack[0] = ~intstack[0]; return; }
//      &   and
   void and_b(int * intstack){ intstack[0] = unstack(intstack) & intstack[0]; return; }
//      |   or
   void or_b(int * intstack){ intstack[0] = unstack(intstack) | intstack[0]; return; }
//      +   plus
   void plus(int * intstack){ intstack[0] = unstack(intstack) + intstack[0]; return; }
//      -   minus
   void minus(int * intstack){ int op = unstack(intstack); intstack[0] = intstack[0] - op; return; }
//      *   multiplication
   void mult(int * intstack){ intstack[0] = unstack(intstack) * intstack[0]; return; }
//      /   division
   void div(int * intstack){ int op = unstack(intstack); intstack[0] = intstack[0] / op; return; }
//      %   modulo
   void mod(int * intstack){ int op = unstack(intstack); intstack[0] = intstack[0] % op; return; }

string RPNcalc(string CDUI, string RPNstr){
   // Parse and calculate the RPN string
   int* stack;
   string strStack[50];
   int c, key, i;
   int ind, ind_max = 0;
   char * car;
   
   stack = new int[STLEN];
   
   // Parsing rpn string
   RPNstr += " ";
   for(i=0; i<strlen(RPNstr); i++){
      while(RPNstr[i] != " "){
         strStack[ind_max] += RPNstr[i];
         i++;
      }
      ind_max++;
   }
   // troncate the CDUI if needed
   if(strlen(CDUI) > 10) CDUI = substr(CDUI, 0, 5) + substr(CDUI, strlen(CDUI) - 5, 5);
   // variables init
   key = 0;  c = 0; car = new char[2];
   // calculation loop
   for(i=0; i<strlen(CDUI); i++){
      // CDUI char
      c = strstoc(substr(CDUI, i, 1), car); c = (int) *car;
      for(ind=0; ind<ind_max; ind++){
         switch(strStack[ind]){
            case "&&":   and(stack); break;
            case "&":    and_b(stack); break;
            case "/":    div(stack); break;
            case "==":    equal(stack); break;
            case ">=":    greater(stack); break;
            case "-":    minus(stack); break;
            case "%":    mod(stack); break;
            case "*":    mult(stack); break;
            case "!":    not(stack); break;
            case "~":    not_b(stack); break;
            case "||":    or(stack); break;
            case "|":   or_b(stack); break;
            case "+":   plus(stack); break;
            case "<<":   shfl(stack); break;
            case ">>":   shfr(stack); break;
            case "i":   instack(stack, i); break;
            case "c":   instack(stack, c); break;
            case "key":   instack(stack, key); break;
            default:   instack(stack, (int)lparse(strStack[ind]));
         }
         //alert(""+stack[0]+"\n"+stack[1]+"\n"+stack[2]+"\n"+stack[3]);
      }
      key = stack[0]; alert(key);
      free(stack);
      stack = new int[STLEN];
   }
   // return result or empty string (error)
   key = key & 65535;
   free(car); free(stack);
   return substr("00000"+key, strlen("00000"+key)-5, 5);
}


Marc Lambrigger

PostPosted: Mon May 07, 2007 8:36 pm
by sangahm
Very nice. I'll have to build this into the next version of my program.

PostPosted: Tue May 08, 2007 6:03 am
by mlambrigger
See the Handango registration system for more infos or contact me. I want to build web site to share open OrbForm Code. Did you have some ideas for that?

Marc Lambrigger

PostPosted: Tue May 08, 2007 10:27 pm
by sangahm
Yes, there are several things I can contribute on open code, share what I've learned, and see how others are handling things that have me stumped (see my other message on entering a new datebook or calendar item).