BLHTML.org

BLHTML.org / Web Programming / BLHTML / BLHTML Manual / BLHTML funktion list / BLHTML funktion list /

 
  SUM 3474 0
#SUM# is a database function
Rights to use this function #SUM#:
  • BASIC

  • #SUM# Manage numbers, counting and formatting numbers and $variables

    Guidelines for #SUM#: data($array[+]) + value("calculation"):
    data shall be separated by spaces.
    The first number is positive, unless otherwise stated.
    Operator is and is authentic until a new operator is set.

    Note that #SUM# counting from left to right and put the sum in the stack and process the next field to right (number operators numbers -> stack). The last stack is returned.

    values:  defaults:  description:
    type rnd
    min
    max
    avg
    group
    count
    last
    dechex
    hexdec
    decbin
    bindec
    from=1 to=6 randomize number from to blhtml=on BLHTML executes from and to
    Get the smallest number from data
    Get the largest number of data
    Mean
    Picks out all the unique strings / variables
    Counting the number of variables from data
    The last variable from data
    Converts decimal to hexadecimal
    Converts hexadecimal to decimal
    Converts decimal to binary
    Converts binary to decimal
    data#SUM type data(array[+])# type manage the data attribute
    valueValue to be calculated
    nullnull=true returns 0 if no value
    decimalTurns fixt decimals
    blhtmlblhtml=on BLHTML executes value
    returnreturn=variable stores the results in $variable

    Example type:
    #$no[+](3 4 5 6 7 8 9 10 11 12 13 14)#

    no: #$no[+]#<br><br>

    min: #SUM type=min data($no[+])#<br>
    max: #SUM type=max data($no[+])#<br>
    avg: #SUM type=avg data($no[+])#<br>
    count: #SUM type=count data($no[+])#<br>
    last: #SUM type=last data($no[+]) decimal=2#<br>
    last + 1: #SUM type=last data($no[+]) value=1#<br><br>

    #$n=1#
    #$m=8#

    SUM(18 + 2) = #SUM value($n$m 2)#<br>
    rnd(100) = #SUM to=100 type=rnd#<br>

    #SUM type=decbin data=85 return=db#
    decbin: #$db#<br>
    #SUM type=bindec data($db) return=db#
    bindec: #$db#<br><br>

    #SUM type=dechex data($db) return=db#
    dechex: #$db#<br>
    hexdec: #SUM type=hexdec data($db)#
    Outcome:
    no: 3 4 5 6 7 8 9 10 11 12 13 14

    min: 3
    max: 14
    avg: 8.5
    count: 12
    last: 14.00
    last + 1: 15

    SUM(18 + 2) = 20
    rnd(100) = 1
    decbin: 1010101
    bindec: 85

    dechex: 55
    hexdec: 85

    Example value:
    #SUM value(1 + 2 + 3 - 3 - 1 * 8 / 2 / 2 / 2 - 1 + 9)#
    #SUM value(1 2 3 - 3 1 * 8 / 2 2 2 - 1 + 9)#


    /*
    Calculation:
    1 + 2 -> stack + 3 -> stack - 3 -> stack - 1 -> stack * 8 -> stack / 2 -> stack / 2 -> stack / -> stack 2 -> stack - 1 -> stack + 9 -> stack
    */

    These calculations are the same and return 10 in each example.
    Other example is a simplified BLHTML variant

    #SUM value(1 3 * 2)#
    // blir (1 + 3) * 2 = 8 and inte 1 + (3 * 2) = 7
    // Calculation: 1 + 2 -> stack * 2 -> stack

    To start with a negative number:
    #SUM value(- 11 / 2)#
    // Return -5.5 note the space after the minus.

    To mix numbers and $variables:
    #SUM value($field1 $field2 * 1.25)#
    // Calculation: $field1 + $field2 -> stack * 1.25 -> stack

    More information:
  • Variable handling
  • array
  • #ARRAY#
  • Array handling
  • Dynamic variables
  • #STR# string handler
  • To load the database to look: #READ#
  • operator
  • BLHTML forum  


    apache MySQL PHP No to software patents! BLHTML
    © 2003, 2010 BLHTML
    This page is created with BLHTML in 0.0692 seconds