Serialnumbers for plugin



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 12/10/2005 at 21:10, xxxxxxxx wrote:

    Lennart, do it in main(), first thing (or after loading resources if needed). main() is only called once at the start of the plugin.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 14/10/2005 at 17:42, xxxxxxxx wrote:

    Thanks! I now now how to find and read files.
    But...even if the serial number is a number it is still a string in the coffee code.
    In my search all I find is "stringToReal" but it seems as it is a C++ thing?

    What should I look into to get number characters seen as numbers instead? So I can use the serial number and the external textfile(password in numbers) for calculations.

    Cheers
    Lennart



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 14/10/2005 at 18:18, xxxxxxxx wrote:

    Use Filename class to construct/hold file paths and names.

    Use BrowseFiles class to search directories.

    Use BaseFile class to read/write files.

    I don't see anything in COFFEE to convert a string to a number. If the string represents an integer, there are methods to build the number from the individual numerical characters:

    var numString = "1234567890";
    var j;
    var k;
    var t = 1;
    for (j = sizeof(numString)-1; j >= 0; --j)
    {
    k = k + (numString[j] * t);
    t = t * 10;
    }
    print(numString+" = "+tostring(k));

    What this does is extract each digit from the lowest order (end of string) to highest order (start of string), multiplies by a power of 10 (t), and adds that to the accumulating number.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 14/10/2005 at 21:46, xxxxxxxx wrote:

    One thing that I missed:

    (numString[j] * t) needs to be ((numString[j]-48) * t)

    In ASCII/Unicode, "0" = 48 (yes, text characters have numeric values). Subtracting 48 from the ASCII value turns it into the pure number "0" = 48 - 48 = 0.

    Been some time since doing this, pulling the code off the top of my head. :)



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 15/10/2005 at 07:01, xxxxxxxx wrote:

    Thanks Robert. I see how you think (but don't understand it yet :) )

    I use a "nothing" plugin to test only this part (your example).
    To me it looks as if it may be a little of a catch22.
    The line:

    k = k + ((numString[j]-48) * t);

    gives a Incompatible value NIL / INTEGER, COFFEE error message.
    Given that numString is a string, it doesn't look as it can be calculated.
    I do most likely make a mistake somewhere here....

    (The reading of textfiles work fine, using FileName- and BaseFile classes but in this test that part is taken out, only using "var numstring = "1234567890" " as input)

    Thanks again
    Lennart



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 15/10/2005 at 13:52, xxxxxxxx wrote:

    The problem isn't numString[j], it's 'k'. 'k' is uninitialized. Change 'var k;' to 'var k = 0;' and it will work!



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 15/10/2005 at 15:50, xxxxxxxx wrote:

    Oh, great!
    I'll investigate further this week.
    Many thanks (but I'm dure I might return in the issue :) )

    Cheers
    Lennart



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 16/10/2005 at 16:31, xxxxxxxx wrote:

    Gosh Robert, it really works! You will be rewarded, I promise.

    May I check one more thing? The registration method I'm thinking of is to provide the user with a .txt file (Plain text). This .txt file contains the usercode. The .txt file is to be placed at a certain location to be read by Cinema. So far that works fine. However, I'm on Mac. Will a .txt file done on a Mac be the same on a PC? Or is there a risk that it will be interpretet as "something else"? (Magicaly become a .doc or whatever)

    Cheers
    Lennart



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 16/10/2005 at 22:57, xxxxxxxx wrote:

    Yes, should work identically. Cinema 4D's file read/write facilities compensate for the platform differences (little-endian/big-endian, filesystem, etc.).

    One caveat to be aware of when converting strings representing integers to actual integers: there is a limit to the sizes available. 32-bit unsigned precision for integers is from 0 to 4294967296. COFFEE's int is signed, so you are limited to the range –2147483648 to 2147483647. After that, you'll get errors. Basically, anything 9 digits or more is in the 'danger zone'.

    Now, one can circumvent this by breaking the string and the conversions into multiples. So, "999999998888888" can be converted by splitting the string appropriately (every 8 digits, for instance) and converting into several int variables. Then do your comparisons on the individuals ints.

    Or, you can do the calculations on the string characters, individually. You can always employ the (x-48) to convert the digit character into an integer from 0 to 9 if needed.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 26/08/2008 at 15:42, xxxxxxxx wrote:

    Since your setup has worked flawlessly Robert, I haven't had any reason to look into it, until today when I just found the
    evaluate("1234") COFFEE function!

    So far it handles anything I throw at it.
    (Number textfiles, tostring("123")etc.)

    Cheers
    Lennart


Log in to reply