automatic typecasting of variables?

Discussion in 'Questions (Windows Mobile)' started by Stellaferox, Feb 4, 2008.

  1. Stellaferox

    Stellaferox Active Member Licensed User

    Hi,

    I want to know whether Basic4ppc automatically typecasts variables. I know it does in certain cases.
    The specific question I have is that I want to use a counter that counts up to 133784560. Does it change type when passing the integermaximum or do you have to typecast it from the start. If yes how do you typecast a variable at start?
    Marc
     
  2. agraham

    agraham Expert Licensed User

    B4PPC is a weakly typed language and normal (non-array) variables are not really typed at all. They are saved as strings and all numeric calculations are done by converting them to and from floating point doubles. Booleans are actually strings with the values "true" and "false".

    Arrays ARE typed but ONLY IF you declare them as such, otherwise they are like non-array variables. Calculations done using typed arrays can be somewhat faster than with ordinary variables or arrays as, while they are still converted to and from doubles for calculation, this is a faster process than string conversion.

    A note about libraries for completeness, their existence being the reason that B4PPC needs to know about types. B4PPC knows about certain types, such as Color, Boolean, Int16 etc, and converts its' non-array variables to and from these types when a library requires it. Arrrays, to save processing time, are not converted when passed to a library and so must be declared within B4PPC to be whatever type a library requires.
     
  3. Stellaferox

    Stellaferox Active Member Licensed User

    Agraham thanks,

    But what about ordinary variables? The counter I use starts of as an integer (4 bytes) and moves up to 133784560 (Int64).
     
  4. agraham

    agraham Expert Licensed User

    What makes you think that? If it is a normal non-array B4PPC variable it is effectively a string as I've said above.
     
  5. Stellaferox

    Stellaferox Active Member Licensed User

    Ahh, I see your point now. OK, that is clear. No worries then to start the procedure....
    Thnx
     
Loading...