Displaying Miscellaneous Chart Examples


The Main Menu of AlphaSports contains a button labeled "Miscellaneous Examples". This button runs an Action Script, which in turn runs an Xbasic script named "MiscExamples" using the Scripts > Run a Script action. This script displays pie and bar charts created with a SimpleChart ActiveX control. This is a feature of Alpha Five Version 7.

Understanding the MiscExamples Script 

First, we create the variables that the script will use.

DIM dlg_title as C = "Miscellaneous Examples"
DIM arrExamples[1] as P
DIM t as P
DIM count as N
DIM nExample as N
DIM Description as C

Next, the script opens the MiscExamples to count the number of examples.

t = table.open("MiscExamples", FILE_RO_SHARED)
count = t.records_get()

The script then reads the MiscExamples table's data into an array. This makes it easy for the script to jump between different examples.

arrExamples.initialize_from_table("MiscExamples", "", "Category")
nExample = 1

Next, the script creates a new minimized window, loads its button onto the Window Bar, loads it into the list of windows under the Windows menu, tests for its existence, and sets focus to it.

a5_mdi_windowclass_add("AlphaSportsMiscExamples", dlg_title, "a5_ball_blue")
IF ui_modeless_dlg_exist(dlg_title)

Finally, the script creates the contents of the new window. The window contains a tree control that displays the contents of the arrExamples[] array. When you click the Go to Example button, the script displays either the BarChart or PieChart forms.

ui_modeless_dlg_box(dlg_title, <<%dlg%
Select an Example:;
<*20,1.5Go to Example!goto_example>;
%dlg%, <<%code%
IF left(a_dlg_button, 8) = "example_"
    IF A_dlg_button = "example_change"
        IF nExample > 0
            Description = arrExamples[nExample].Description
            Description = ""
        END IF
    ELSE IF a_dlG_button = "example_dblclick"
        ui_dlg_event(dlg_title, "goto_example")
    END IF
    a_dlg_button = ""
ELSE IF a_DlG_button = "activate"
    DIM toolbar_name as C
    DIM pDummy as P
    toolbar_name = a5_system_toolbar_show(pDummy, a5_toolbar_def_load("MiscEx"))
ELSE IF a_dlg_button = "deactivate"
    a_Dlg_button = ""
    IF ui_modeless_dlg_exist(toolbar_name)
    END IF
ELSE IF a_Dlg_button = "goto_example"
    a_dlg_button = ""
ELSE IF a_dlG_button = "close"
    a_dlg_Button = ""

See Also