MapleTableAlloc
create a table in external code
MapleTableAssign
assign into a table in external code
MapleTableSelect
select from a table in external code
MapleTableDelete
delete an element in a table in external code
MapleTableHasEntry
test if an element exists in a table in external code
Calling Sequence
Parameters
Description
Examples
MapleTableAlloc(kv)
MapleTableAssign(kv, table, ind, val)
MapleTableSelect(kv, table, ind)
MapleTableDelete(kv, table, ind)
MapleTableHasEntry(kv, table, ind)
kv
-
kernel handle returned by StartMaple
table
Maple table object
ind
index or key that maps to the data in a table
val
value to assign into the table
These functions are part of the OpenMaple interface to Microsoft Visual Basic.
MapleTableAlloc creates a new table object. Tables are dynamic and grow as needed, so unlike MapleListAlloc, no size parameter is needed.
MapleTableAssign sets the element at index ind of the table to the value val, that is, table[ind] := val. An index can be any valid Maple object. Elements can be removed and inserted from tables at any time (unlike MapleListAssign, which can only be used immediately after creating a list).
MapleTableSelect retrieves the element at index ind of the table. If no element exists at the index ind, then 0 is returned.
MapleTableDelete removes the element at index ind of the table. If no element exists at the index ind, the table is unmodified.
MapleTableHasEntry returns True if there exists an element at index ind of the table, and False if nothing exists at that index.
Public Sub TestTable(ByVal kv As Long)
Dim table, seven As Long
table = MapleTableAlloc(kv)
seven = ToMapleInteger(kv, 7)
MapleTableAssign kv, table, _
ToMapleString(kv, "color"), ToMapleString(kv, "red")
seven, ToMapleFloat(kv, 3.14)
MapleALGEB_Printf1 kv, "table[color] = %a", _
MapleTableSelect(kv, table, ToMapleString(kv, "color"))
MapleALGEB_Printf1 kv, "table[7] = %a", _
MapleTableSelect(kv, table, seven)
MapleTableDelete kv, table, seven
If MapleTableHasEntry(kv, table, seven) Then
MapleALGEB_Printf0 kv, "should not get here"
End If
If MapleTableHasEntry(kv, table, ToMapleString(kv, "color")) Then
MapleALGEB_Printf0 kv, "good"
End Sub
See Also
OpenMaple
OpenMaple/VB/API
OpenMaple/VB/Examples
trademarks
Download Help Document