Genii Weblog


Civility in critiquing the ideas of others is no vice. Rudeness in defending your own ideas is no virtue.


Wed 20 Aug 2003, 11:48 PM
This "Getting started..." series of articles will show simple code snippets to demonstrate how to use common features of the Midas Rich Text LSX.  These are not meant to be full fledged samples, for which you could go to the Midas Samples page, but rather small bits of code to show how to get started.  These articles will also appear in the Reference section of the Midas Help db in somewhat altered form.


The Midas Rich Text LSX lets you create and modify tables in a number of ways.  The most common tasks are creating a table, accessing cell values, and adding rows.  Below are some quick code snippets to show these tasks.  Additional information can be found in the Working with table properties reference in the Midas Help db and in information about the individual properties and methods which relate to tables, rows and columns.

Creating a table and starting to use it
Call rtitem.ConnectBackend(doc.Handle, "Body", True)
Set rtchunk = rtitem.DefineChunk("Everything")
Call rtchunk.AppendTable(11, 2, "TableWidth=Fit_To_Margins")
Set rtchunk = rtitem.DefineChunk("Table 1")

Setting cell values
Call rtitem.ConnectBackend(doc.Handle, "Body", True)
Set rtchunk = rtitem.DefineChunk("Table 1")
Call rtchunk.SetText("Row 1; Column 1", "Salesperson")
Call rtchunk.SetText("Row 1; Column 2", "Quota")
For i = 1 to 10
   Call rtchunk.SetText("Row " & Cstr(i+1) & "; Column 1", salesperson(i))
   Call rtchunk.SetText("Row " & Cstr(i+1) & "; Column 2", Cstr(quota(i)))
Next i
Set rtchunk = rtitem.DefineChunk("Table 1; Row 1")
rtchunk.Font = "Bold Blue"

Getting cell values
Call rtitem.ConnectBackend(doc.Handle, "Body", True)
Set rtchunk = rtitem.DefineChunk("Table 1; Row 1")
Do
   Messagebox rtchunk.GetText("Column 1") & "," & rtchunk.GetText("Column 2")
Loop Until Not rtchunk.GetNextTarget

Adding rows
Call rtitem.ConnectBackend(doc.Handle, "Body", True)
Set rtchunk = rtitem.DefineChunk("Everything")
Call rtchunk.AppendTable(1, 2, True, "Salesperson", "Quota")
Set rtchunk = rtitem.DefineChunk("Table 1")
For i = 1 to 10
   Call rtchunk.AppendRow(0, False, salesperson(i), Cstr(quota(i)))
Next i

Finding out how many rows and columns are in a table
Call rtitem.ConnectBackend(doc.Handle, "Body", True)
Set rtchunk = rtitem.DefineChunk("Table 1")
rows = rtchunk.GetCount("Row")
cols = rtchunk.GetCount("Row 1; Column")

Copyright © 2003 Genii Software Ltd.