The Number 1 independent website for ACL information!

TexasACL User Group
About Us
Training
Why ACL
Essays & Scripts
ACL News
Events
Links
FAQ
Site Map
Support Us
From the ACL Website the code to create a running total:
 
OPEN Inventory
running_total = 0.00
GROUP
    running_total = running_total + mktval
    EXTRACT ALL running_total AS "Running;Total" TO Invent_running_tot
END
OPEN Invent_running_tot
DELETE running_total OK
 
The idea code is admittedly a little more complex.  It keeps both a running total for the entire population and for the specific items:
'This Ideascript creates a new file and adds a numeric field called running total to the file
'The new field creates a running total for the numeric field using a specified index
'The new field then produces a running total for each different item within the index.
To adapt the above code AND to add dialog boxes to provide interactive script capabilities:
 

DIALOG (DIALOG TITLE "User Dialog" WIDTH 546 HEIGHT 426 ) (BUTTONSET TITLE "&OK;&Cancel" AT 370 12 DEFAULT 1 ) (TEXT TITLE "Select Table" AT 36 100 ) (ITEM TITLE "f" TO "v_table" AT 156 96 WIDTH 326 HEIGHT 284 )

 

OPEN %v_table%

 

DIALOG (DIALOG TITLE "User Dialog" WIDTH 574 HEIGHT 497 ) (BUTTONSET TITLE "&OK;&Cancel" AT 370 12 DEFAULT 1 ) (TEXT TITLE "Select amt field" AT 24 124 ) (ITEM TITLE "N" TO "v_field" AT 156 120 WIDTH 352 HEIGHT 314 ) (TEXT TITLE "Select item for breaks" AT 24 88 ) (ITEM TITLE "C" TO "v_item1" AT 156 84 WIDTH 345 HEIGHT 338 )


running_total = 0.00
item_total = 0.00
v_item = blank(50)

GROUP if v_item = v_item2
    running_total = running_total + v_field
    item_total = item_total + v_field
    EXTRACT ALL running_total AS "Running;Total" TO Invent_running_tot
    v_item = v_item2
ELSE
    running_total = running_total + v_field
    item_total =  v_field
    EXTRACT ALL running_total AS "Running;Total" TO Invent_running_tot

    v_item = v_item2

END
OPEN Invent_running_tot
DELETE running_total OK