• PicŪ Basic


  • macroFORMAT formats and displays values up to 31 bytes wide as a string

    With macroFORMAT you can now format and display any value up to 31 bytes wide as a string.
    This is especially usefully in debugging and displaying routines in Alberto's NBitMATH.

    Formating includes a thousands separator, decimal places and negative offset.
    Thousands separator will add an apostrophe per thousands.
    A 1 in the macro thousands parameter will add apostrophes and a 0 will not.

    Decimal places will place a decimal point as user sets in the macro parameter.
    User is to multiply the calculation value by 10 per decimal point.
    This is extremely useful when using division.

    Negative offset will display as a negative any value less than the user set value in the negative macro parameter.
    User is to add to the calculation the maximum negative value required.
    For instance if the macro resulting value is 990 and the negative parameter is 1000 macroFORMAT will display a -10.
    If the macro resulting value is 0 and the negative parameter is 1000 macroFORMAT will display a -1000.


    'An example macroFORMAT display of an integer with thousands separator, 3 decimal places and a negative offset of 1000:
    dMY_VAL_PTR = 2147483648 'Enter integer to display
    yMY_VAL_LEN = 0 'Set to 0 to display an integer
    macroFORMAT yMY_VAL_LEN, dMY_VAL_PTR, 1, 3, 1000
    HSerOut[sFORMATED,13] 'will display "+2'146'483.648"

    'An example macroFORMAT display of a variable with thousands separator, 3 decimal places and a negative offset of 1000:
    dMY_VAL = 990000
    dMY_VAL_PTR = VarPtr(dMY_VAL) 'Enter variable to display.
    yMY_VAL_LEN = SizeOf(dMY_VAL) 'Enter variable to display.
    macroFORMAT yMY_VAL_LEN, dMY_VAL_PTR, 1, 3, 1000
    HSerOut[sFORMATED,13] 'will display "-10.000"

    'An example macroFORMAT display of an NBitMath register with thousands separator, 4 decimal places and a negative offset of 0:
    'Requires Alberto Freixanet's P-NBitMath.inc
    'Download macroFORMAT Demo.bas for complete example
    MOVE_CVA 4294967295, REG_B 'LOAD REG_B
    MOVE_CVA 4294967200, REG_C 'LOAD REG_C
    MATH_MUL REG_B, REG_C, REG_A 'equivalent of REG_B * REG_C = REG_A
    dMY_VAL_PTR = VarPtr(REG_A) 'Enter register to display.
    yMY_VAL_LEN = SizeOf(REG_A) 'Enter register to display.
    macroFORMAT yMY_VAL_LEN, dMY_VAL_PTR, 1, 4, 0
    HSerOut[sFORMATED,13] 'will display "1'844'674'365'709'772.400'0"
    'macroFORMAT can display full width of NBitMath register at any point in a calculation.

    Download the latest version of macroFORMAT or additionally see NBitMath to calculate in values up to 31 bytes wide.

    macroFORMAT formats and displays values up to 31 bytes wide as a string forum.

    Thanks to JohnB for help with macro's.

    Norm