JCode help

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Carmine Castiglia

    JCode help

    At the moment, I know virtually nothing about programming JCode and this is
    not a good time to try to learn. But, I do have a JCode requirement and am
    wondering if someone would like to tackle what I suspect is only 20 or so
    lines of code...

    Palmgear.com (a purveyor of application software for Palm OS devices) offers
    a "dynamic registration" tool which allows developers to have a registration
    or "unlock" code dynamically generated by the palmgear shopping cart system.
    The code is generated by a small block of developer-customized JCode within
    a larger JCode source file. Palmgear offers the following example code
    block:

    int unlockCode = 0;
    for (int i=0; i < userID.length() ; i++) {
    unlockCode = unlockCode + (byte)userID.ch arAt(i);
    }
    result = Integer.toStrin g(unlockCode & 0xFFFF);


    Which, as I said, is a small block of code within a larger JCode app. My
    need is to replace that block with a block which will do the following:

    1) If the length of the userID string is greater than 10, take only the
    first and last 5 characters, disposing of any characters in the middle of
    the string.

    2) Sum the values of the ascii character code for each character in the
    shortened userID string.

    3) Multiply the previous sum by some number, let's say 12.

    4) Add some number, perhaps 234, to the previous result.

    5) The final result must be between 0 and 65535. If the result is > 65535,
    'overflow' it so that 65536 becomes 0, 65537 becomes 1, 65538 becomes 2,
    etc.

    6) Present the final result as a 5 character zero-filled string.

    7) Using the parameters above, userID "John Doe" should generate the code
    "09766"

    Any takers?


Working...