Ole Automation using OpenInsight

Ole Automation using OpenInsight
A Series of Practical Examples
Overview
The goal of this whitepaper is to offer practical examples of calling OLE Objects. I will
describe the Basic+ functions used to control OLE objects, provide an overview of how
to obtain sample code from a Visual Basic dialect and translate that to Basic+, and I will
provide example code that I have found useful.
Terms
OLE
OLE (Object Linking and embedding) is a Microsoft technology for allowing
components to interact as high level objects. Other acronyms, for example COM and
Activex are also used to describe the technology. The core idea is that components
represent themselves as objects with properties and methods. Working with an OLE
object involves calling a function to create an instance of that component, then
manipulating the object by setting properties and executing methods. Microsoft
established standard interfaces which every OLE object must use to publish their
properties and methods. Roughly speaking, any program that can work with these
interfaces can work with any OLE object.
Object
Object, Control and Component are interchangeable words for an OLE control.
ProgId
The public name of an Object. May be called the Class Name. You need to know the
progid to use the object. It is the name which you pas to the OLECreateInstance function
to begin using the object. For example the progid for Microsoft Excel is
“Excel.Application”.
Class
The word “Class” is used to talk about an ole control when discussing its capabilities.
Instance
The word “Instance” in used to talk about a specific instance of the control running on a
machine. For example you can start several instances of the XmlHttp object. Each
instance will have its own set of properties. One property of the instance is its handle.
The handle corresponds to the CtrlEntId of an OpenInsight control. In the OpenInsight
Debugger, Ole Handles are displayed as “<idispatch>”. A handle is also called a
“reference”.
DOM
Document Object Model. Classes may comprise collections or hierarchies of other
classes. The DOM describes the hierarchy and the properties and methods and how they
relate to each other.For instance, the Excel.Application class contains the Workbooks
Collection. The workbooks contains one or more instances of the workbooks class. Each
instance of Workbooks can contain one or more Worksheets. Each Worksheet contains
multiple instances of Range Objects. If you want to change the value of a cell you need
to start with an Excel.Application instance and Navigate the DOM to create a Range
object which references the appropriate cell. Learning the DOM for a class is the biggest
challenge to working with OLE objects.
Registered Object
OLE Objects need to be registered on the computer where your code will run.
Registration creates an entry in the registry of that computer. Installing an application
usually performs the registration for you. When you copy dlls to a machine without
running an installation program you may need to register the dll yourself. The end result
of registering the object is a registry key with the progId. The symptom of needing to
register the object is an error message like ‘Automation Error 429 Unable to Create
Object’. To register an object you use the program regsvr32 with the path to the dll.
Property
A fact or an attribute about the Ole object. Some properties are read/write, meaning you
can alter them, others are read-only meaning you can use them but not alter them. Ole
properties are very similar to OpenInsight control properties. A key difference is that
OLE controls can return references (handles) to other objects. “Visible” and “Size” are
typical properties
Method
A function you can call to accomplish something with the object. “Print” and “Quit” are
typical methods.
Event
Equivalent to OpenInsight Events.
Not supported in the Basic+ syntax.
Supported by the OLE Control in OpenInsight Forms.
OpenInsight Support for OLE
As of version 7.21, OpenInsight offers an OLE Control, which allows you to embed
Activex Controls in an OpenInsight form, and a series of Basic+ command that work
with the COM interfaces, so you can write Basic+ scripts which interact with COM
objects. I will only be describing the Basic+ commands in this document.
Syntax
OLECREATEINSTANCE Function
Description Creates an instance of an OLE object
Syntax
object = OLECREATEINSTANCE(classname)
Parameters The function has the following parameters:
Parameter Description
classname The OLE classname.
Returns
An OLE object of the Classname class.
Remarks The OleCreateInstance function is used to create instances of an OLE Object
for use in Basic+ scripts.
See also OleGetProperty function, OlePutProperty subroutine, OleCallMethod
function, OleStatus function
OleGetProperty Function
Description
Returns the value of the specified property of an OLE object.
Syntax
Parameters
olePropery = OleGetProperty(object,PropertyName)
The function has the following parameters:
Parameter
Description
Object
The OLE object from which to request the
property.
PropertyName The name of the property
Returns
The value of the property requested from PropertyName.
Remarks
The OleCreateInstance function is used to create instances of an
OLE Object for use in Basic+ scripts and must be issued prior to
calling the OleGetProperty.
See also
OleCreateInstance function, OlePutProperty subroutine,
OleCallMethod function, OleStatus function
OlePutProperty Subroutine
Description Establishes the PropertyName property of the ole object.
Syntax
return = OlePutProperty(object, PropertyName[, Index1, Index2, ...], Value)
Parameters The function has the following parameters:
Parameter
Description
PropertyName The property to be set.
Value
The value to set.
Returns
Remarks The OleCreateInstance function is used to create instances of an OLE Object
for use in Basic+ scripts and must be issued prior to calling the
OlePutProperty.
See also OleCreateInstance function, OleGetProperty function, OleCallMethod
function, OleStatus function.
OleRequestLicKey Function
Description Returns the runtime license key associated with the Classname class.
Syntax
licKey = OleRequestLicKey(classname)
Parameters The function has the following parameters:
Parameter Description
Classname The OLE classname.
Returns
The runtime license key.
Remarks The OleCreateInstance function is used to create instances of an OLE
Object for use in Basic+ scripts and must be issued prior to calling the
OleRequestLicKey.
How do I solve a problem
Start with an Example
The best approach is to find a code example in one dialect of the BASIC programming
language and translating that example to our dialect, Basic+. The internet is a geat
source of code examples. A technique for Microsoft Office products is to using the
macro recorder to create a script. Many downloadable objects offer
Google for code
Choose a clear Example
VbScript is the easiest to translate. VBA andVisual Basic are the next easiest. .Net
examples do not apply.
Convert vbscript to Basic+
' VBScript source code
public function execute()
dim xmlhttp
Set xmlhttp = CreateObject("Microsoft.XMLHTTP")
xmlhttp.open "POST", Url & "/" & Method, false
xmlhttp.setRequestHeader "Content-Type", "application/x-wwwform-urlencoded"
xmlhttp.send Parameters.toString
response = xmlhttp.responseText
set xmlhttp = nothing
end function
xmlhttp = OleCreateInstance("Microsoft.XMLHTTP")
x = xmlhttp->open("POST", Url : "/" : Method, 0)
x= xmlhttp->setRequestHeader( "Content-Type", "application/x-wwwform-urlencoded")
x=xmlhttp->send( parameters )
response = xmlhttp->responseText
xmlhttp = ""
Use Macro Recorder
Tools/Macro/Record Macro
Tools/Macro/Visual Basic Editor
Macro Recorder creates macros in Visual Basic For Applications
Recorder often uses DOM Shortcuts that need to unrolled.
Use VBA editor to learn properties of OLE Objects
The Vba Editor (Excel, Tools, Macro, Visual Basic Editor) is a good tool to learn about
third party
Convert the Example
Unroll the DOM
Properties versus Methods
Item Property in Collections
Examples
Add data to an Excel Spreadsheet
Word
Bookmark wordmerge
Subroutine Ole_Word_Example(argDoc, argTable, argId )
/*
Use OLE and
argDoc
argTable
argId
Bookmarks to print a word document
= full path to Word Document
= Oi table name
= id (key) of the row from the table
Create a word Document, add bookmarks where you want to place data from OI columns
The bookmark names should be the name of the columns.
Note:
In Office XP the last bookmark won't fill in,
so add a meaningless bookmark to the document.
* ----------------------------------------------------------09-23-2006
rjc
Created
*/
Declare function Dialog_Box, get_Property
declare function GetTempFilename, GetTempPath
Declare subroutine set_status
$Insert Msg_Equates
$Insert logical
$insert Dict_Equates
equ crlf$ to \0D0A\
equ tab$ to \09\
equ wdGoToBookmark to -1
if assigned(argDoc) then doc = argDoc else doc = ''
if assigned(argTable) then table = argTable else Table = ''
if assigned(argId) then id = argId else id = ''
err = ''
if err then
set_status(1, err)
return ''
End
osread document from doc else
document = ''
err = 'Invalid Word Document'
set_status(1, err)
return ''
End
* Create temp document to edit
filename = doc[-1,'B\']
buffer = space(256)
ret = GetTempPath(len(buffer), buffer)
path = buffer[1,ret]
IF path[-1,1] = '\' else path := '\'
targetfile = path:filename
oswrite document on targetfile
open 'DICT.':table to @dict else @dict = ''
read fields_rec from @dict, '%FIELDS%' else
fields_rec = ''
End
colnames = fields_rec<fields_name$>
convs
= fields_rec<fields_conv$>
@id = id
@record = Xlate(table, @ID, '', 'X')
swap @tm with crlf$ in @record
oWrd
= OleCreateInstance("Word.Application")
oDocuments = oleGetProperty(oWrd, 'Documents')
oDoc
= OleCallMethod(oDocuments, 'OPEN', targetfile)
Selection = OWrd->Selection
oMarks
= oDoc->Bookmarks
mcnt = oMarks->count
for i = 1 to mcnt
oMark = oMarks->Item(i)
colname = oMark->Name
convert @lower.case to @upper.case in colname
locate colname in colnames using @vm setting pos then
conv = convs<1,pos>
val = calculate(colname)
if len(conv) then
val = Oconv(val, conv)
end
convert @vm to char(10) in val
end else
val = ' '
end
x = Omark->Select()
x = Selection->TypeText(val)
next
* leave word open, let the user edit
OlePutProperty(oWrd,'Visible', -1)
return ''
MsWord Mail Merge
Subroutine Ole_WordMerge_Example(argDoc, argTable, argIds )
/*
Use OLE and Mailmerge to print pile of word documents
argDoc
= full path to Word Document
argTable = Oi table name
argIds
= vm delimited list of ids (keys) from the table
Create a word Document, set up for mail merge add mergefields where you want to place
data from OI columns
* ----------------------------------------------------------09-23-2006
rjc Created
*/
Declare function Dialog_Box, get_Property
declare function GetTempFilename, GetTempPath
Declare subroutine set_status
$Insert Msg_Equates
$Insert logical
$insert Dict_Equates
equ
equ
equ
equ
equ
crlf$ to \0D0A\
lf$ to \0A\
tab$ to \09\
dquote$ to \22\
wdGoToBookmark to -1
if assigned(argDoc) then doc = argDoc else doc = ''
if assigned(argTable) then table = argTable else Table = ''
if assigned(argIds) then ids = argIds else ids = ''
err = ''
begin case
case dir(doc)<1> < 1
err = 'Invalid Word Document'
case not( TableExists( table))
err = 'Invalid table name'
end case
if err then
set_status(1, err)
return ''
end
at_dict = @dict
at_Record = @record
at_id = @id
at_mv = @mv
*--* Use a copy of the document
* else multiple users have trouble
*--osread document from doc else
document = ''
err = 'Invalid Word Document'
set_status(1, err)
return ''
end
filename = doc[-1,'B\']
buffer = space(256)
ret = GetTempPath(len(buffer), buffer)
path = buffer[1,ret]
IF path[-1,1] = '\' else path := '\'
targetfile = path:filename
oswrite document on targetfile
open 'DICT.':table to @dict else
@dict = ''
end
read fields_rec from @dict, '%FIELDS%' else
fields_rec = ''
end
colnames = fields_rec<fields_name$>
convs
= fields_rec<fields_conv$>
*
* Start Word
*
oWrd = OleCreateInstance("Word.Application")
oDocuments = oleGetProperty(oWrd, 'Documents')
oDoc = OleCallMethod(oDocuments, 'OPEN', targetfile)
OlePutProperty(oWrd,'Visible', -1)
*
* Pull Colnames from mergefields
*
mergecnt = 0
mergenames = ''
mergeconvs = ''
oCollection = oDoc->Fields
cnt = oCollection->count
for i = 1 to cnt
ofield = oCollection->Item(i)
code = ofield->Code
type = trim(field(code, dquote$, 1))
mergename = field(code, dquote$, 2)
if type _eqc "MERGEFIELD" then
colname = mergename
convert @lower.case to @upper.case in colname
locate colname in colnames using @vm setting pos then
mergecnt +=1
mergenames<1,mergecnt> = mergename
mergeconvs<1,mergecnt> = convs<1,pos>
end
end
Next
*
* Build datafile, Write to temp path
*
datafile = path:'mrg_':date():'_':time():'.txt'
mergedata = mergenames
icol = ''
loop
remove @id from ids at icol setting imark
if len(@id) then
@record = Xlate(table, @ID, '', 'X')
ccol = ''
line = ''
for i = 1 to mergecnt
conv = convs<1,i>
colname = mergenames<1,i>
val = calculate(colname)
if len(conv) then
val = Oconv(val, conv)
end
* Hack to wrap mv's
convert @vm:@tm to lf$:' ' in val
line<1,i> = val
next
mergedata:=@fm:line
end
while imark
repeat
convert @vm to tab$ in mergedata
swap @fm with crlf$ in mergedata
oswrite mergedata on datafile
*
* Merge the datafile into the document
*
oMerge = oDoc->MailMerge
x = oMerge->OpenDataSource(datafile)
x = oMerge->Execute()
* leave word open, let the user edit
@dict = at_dict
@record = at_Record
@id = at_id
@mv = at_mv
return ''
MS Word – Swap Merge
A low tech approach similar to Arev Merges. Write your document using field names in
braces, for example {LAST_NAME}, wherever you want columns to appear. This
Script will use words search and replace to swap out the colname
Subroutine Ole_StringMerge_Example(argDoc, argTable, argId )
/*
Use OLE and Mailmerge to print pile of word documents
argDoc
= full path to Word Document
argTable = Oi table name
argId
= id (key) from the table
Create a word Document, set up for mail merge add mergefields where you want to place
data from OI columns
* ----------------------------------------------------------09-23-2006
rjc Created
*/
Declare function Dialog_Box, get_Property
declare function GetTempFilename, GetTempPath
Declare subroutine set_status
$Insert Msg_Equates
$Insert logical
$insert Dict_Equates
equ
equ
equ
equ
equ
crlf$ to \0D0A\
lf$ to \0A\
tab$ to \09\
dquote$ to \22\
wdReplaceAll to 2
if assigned(argDoc) then doc = argDoc else doc = ''
if assigned(argTable) then table = argTable else Table = ''
if assigned(argId) then id = argId else id = ''
err = ''
begin case
case dir(doc)<1> < 1
err = 'Invalid Word Document'
case not( TableExists( table))
err = 'Invalid table name'
end case
if err then
set_status(1, err)
return ''
end
at_dict = @dict
at_Record = @record
at_id = @id
at_mv = @mv
*--* Use a copy of the document
* else multiple users have trouble
*--osread document from doc else
document = ''
err = 'Invalid Word Document'
set_status(1, err)
return ''
end
filename = doc[-1,'B\']
buffer = space(256)
ret = GetTempPath(len(buffer), buffer)
path = buffer[1,ret]
IF path[-1,1] = '\' else path := '\'
targetfile = path:filename
oswrite document on targetfile
open 'DICT.':table to @dict else
@dict = ''
end
read fields_rec from @dict, '%FIELDS%' else
fields_rec = ''
end
colnames = fields_rec<fields_name$>
convs
= fields_rec<fields_conv$>
*
* Start Word
*
oWrd = OleCreateInstance("Word.Application")
oDocuments = oleGetProperty(oWrd, 'Documents')
oDoc = OleCallMethod(oDocuments, 'OPEN', targetfile)
OlePutProperty(oWrd,'Visible', -1)
*
* Pull Colnames from tokens
*
mergecnt = 0
mergenames = ''
mergeconvs = ''
equ
equ
equ
equ
wdFindStop to 0
wdFindContinue to 1
vbTrue to -1
vbFalse to 0
Selection = OWrd->Selection
*-* Make a list of distinct instances of "{COLNAME}" tokens, like Arev WordMerge
*-oFind = Selection->Find
x=oFind->ClearFormatting()
oFind->Text = "\{*\}"
oFind->MatchWildcards = vbTrue
oFind->Forward = vbTrue
oFind->Wrap = wdFindStop
; * Single pass to get the tags
mergenames = ''
loop
while oFind->Execute()
colname = Selection->Text
convert "{}" to "" in colname
convert @lower.case to @upper.case in colname
* Same colname can be in multiple places in doc
locate colname in mergenames using @vm setting pos else
* Valid colname?
locate colname in colnames using @vm setting pos then
mergecnt +=1
mergenames<1,mergecnt> = colname
mergeconvs<1,mergecnt> = convs<1,pos>
end
end
repeat
*--* Replace tokens with text
*--@id = id
@record = Xlate(table, @ID, '', 'X')
for i = 1 to mergecnt
conv = convs<1,i>
colname = mergenames<1,i>
val = calculate(colname)
if len(conv) then
val = Oconv(val, conv)
end
* Hack to wrap mv's
convert @vm:@tm to lf$:' ' in val
token = '{':colname:'}'
oFind->Text = token
oFind->Replacement.Text = "value"
oFind->MatchWildcards = vbFalse
oFind->Forward = vbTrue
oFind->Wrap = wdFindContinue
; * wrap to get all tags
x = oFind->Execute("","","","","","","","","","","",wdReplaceAll)
next
* leave word open, let the user edit
@dict = at_dict
@record = at_Record
@id = at_id
@mv = at_mv
return ''
Office Web Components
subroutine Ole_Chart_Example(void)
/*
** Create a Chart Object Using Microsoft Office Web Components
** Can save as image, use in a bitmap control, OIPI printout, or
return as INET_IMAGE
** This example uses bitmap control. To test, create a window, add a
bitmap, add a button which calls this function
** 12-07-2006 rjc
Based on
http://www.asp101.com/articles/chris/aspcharts/default.asp
*/
Declare function GetTempPath,GetTempFilename
$insert Logical
equ tab$ to \09\
equ eos$ to \00\
ChartSpace = OleCreateInstance("OWC11.ChartSpace")
x = ChartSpace->Clear()
c = ChartSpace->Constants
* Add a chart
Charts = ChartSpace->Charts
Chart = Charts->Add()
Chart->Type = c->chChartTypeColumClustered
Chart->HasLegend = True$
Chart->HasTitle = True$
Title = Chart->Title
Title->Caption = "Random Walk " : timedate()
* Add Series
SeriesCollection = Chart->SeriesCollection
for i = 1 to 4
Series = SeriesCollection->Add()
Series->Caption = 'Q' : i
Categories=""
Vals=""
For j = 1 To 5
Categories<j> = "Region ":j
Vals<j> = Rnd(100)
Next
convert @fm to tab$ in categories
convert @fm to tab$ in vals
x = Series->SetData(c->chDimCategories, c->chDataLiteral,
Categories)
x = Series->SetData( c->chDimValues, c->chDataLiteral, Vals)
next
* Export the chart to the temporary file
buffer = space(255)
ret = GetTempPath(len(buffer),buffer)
path = buffer[1,eos$]
ret = GetTempFilename(path, 'img', 0, buffer)
file = buffer[1,eos$]
x = ChartSpace->ExportPicture(file, "JPG", 640, 480)
osread image from file else image = ''
* Assume current window has a generic bitmap control
call Set_property(@window:'.BITMAP_1', 'IMAGE', image)
osdelete file
return ''
Access
Copy table definitions from MS Access to OI
Subroutine Import_Mdb(ByVal_MdbFile, byVal_Location)
/*
** Import an access database
*/
$insert Logical
$Insert Dict_Equates
$Insert Msg_Equates
$insert environ_constants
equ nothing to ""
equ vbTab to \09\
equ vbCrLf to \0D09\
equ dbAutoIncrField to 16
Equ msoAutomationSecurityLow To 1
If Assigned(ByVal_MdbFile) then mdbfile = ByVal_mdbFIle Else mdbfile = ""
If Assigned(byVal_Location) Then location = byVal_Location Else location = ""
* Where do I make the OI tables?
If location = '' then
location = @Environ_Set<ENV_DEFAULT_DATA_VOL$>
End
* File Exists?
is_ok = ( mdbfile # '' ) and dir(mdbfile)<2> > 0
if is_ok else goto ExitFunction
Import_Dicts:
* Database Available?
Application = OleCreateInstance("Access.Application")
Application->AutomationSecurity = msoAutomationSecurityLow
x = Application->OpenCurrentDatabase(mdbfile )
is_ok = is_ok and OleStatus() = 0
if is_ok else
goto ExitFunction
End
* Any Tables?
cdb = Application->CurrentDb()
tdefs = cdb->TableDefs
tcount = tdefs->Count
is_ok = is_ok And tcount And OleStatus() = 0
if is_ok else
goto ExitFunction
end
tnames_oi = ''
tnames_ac = ''
* Process Non System tables
For i = 1 To tcount
tdef = OleGetProperty(tdefs,'ITEM',i - 1)
tname_ac = tdef->Name
If tname_Ac # '' and tName_ac[1,4] _nec "MSYS" Then
* Key Names?
keys = ""
indices = tdef->Indexes
jcnt = indices->Count
For j = 1 To jcnt
while is_Ok
indice = OleGetProperty(indices,'ITEM',j - 1)
iname = indice->Name
props = indice->Properties
prop = OleGetProperty(props,'ITEM',"Primary")
is_Primary = ( prop->value # 0 )
If is_Primary Then
flds = indice->Fields
kcnt = flds->Count
For k = 1 To kcnt
fld = OleGetProperty(flds, 'ITEM', k - 1)
fname = fld->Name
keys<-1> = fname
Next
end
is_ok = is_ok and OleStatus() = 0
Next
colnames = ""
colinfo = ''
colparts = ''
colfmcs = ''
flds = tdef->Fields
jcnt = flds->Count
For j = 1 To jcnt
while is_Ok
fld = OleGetProperty(flds,'ITEM',j - 1)
fname = fld->Name
ftype = fld->Type
fsize = fld->Size
fattribs = fld->Attributes
* If autoinc, then add to keys even if not flagged as a key
is_autoincrement = bitAnd(fattribs, dbAutoIncrField)
If is_autoincrement Then
locate fname in keys using @fm setting kpos else
keys<-1> = fname
end
End
colnames<j> = fname
colinfo<j> = ftype : @vm : fsize
row = fname : vbTab : ftype : vbTab : fsize
call Send_Dyn( row )
is_ok = is_ok and OleStatus() = 0
Next
end
if is_ok else
goto ExitFunction
end
*
* build the table
*
tname_oi = tname_ac
Convert ' ' To '_' In tname_oi
Convert @lower.Case To @upper.Case In tname_oi
colcnt = Count(colnames, @fm) + ( colnames # '')
If tableExists(tname_oi) then
call clear_Table('DICT.':tname_oi)
End Else
call attach_table(LOCATION, tname_oi, '')
If tableExists(tname_oi) Else
attribs = ''
attribs<1> = 1000
attribs<2> = '501'
attribs<3> = colcnt
attribs<4> = '2048'
attribs<5> = '80'
call create_Table(location, tname_oi, true$, '', attribs, false$)
call create_Table(location, tname_oi, false$, '', attribs, false$)
call Attach_Table(location, tname_oi, '')
end
end
Open 'DICT.':tname_oi to d_tname else
d_tname = ''
is_ok = false$
end
colheads = colnames
Convert @lower.Case To @upper.Case In colnames
Convert @lower.Case To @upper.Case In keys
Convert ' ' To '_' In colnames
Convert ' ' To '_' In keys
next_fmc = 1
For j = 1 To colcnt
While is_ok
colname = colnames<j>
Locate colname In keys Using @fm setting keypart then
this_fmc = 0
this_part = keypart
End else
this_fmc = next_fmc
next_fmc +=1
this_part = ""
end
ac_type = colinfo<j,1>
this_size = colinfo<j,2>
BEGIN CASE
Case ac_type = '1'
* Boolean
oi_type = 'BOOLEAN'
pattern = '(B)'
conv= 'B'
just = 'R'
length = 3
Case ac_type = '3' Or ac_type = '4'
* Integer
oi_type = 'INTEGER'
pattern = '(MDO)'
conv= 'MD0,'
just = 'R'
length = 14
case ac_type = '8'
* datetime
oi_type = 'DATETIME'
pattern = '(DT)'
conv= 'DT'
just = 'R'
length = '14'
case ac_type = '19'
* Numeric
oi_type = 'INTEGER'
pattern = '(DT)'
conv= 'DT'
just = 'R'
length = '14'
case ac_Type = '5'
* Currency
oi_Type = 'DOLLARS'
pattern = '(MD2)'
conv= 'MD2$'
just = 'R'
length = '14'
case ac_Type = '9' or ac_Type = '17'
* BINARY
oi_Type = 'VARBINARY(65531)'
pattern = 'VB'
conv= 'VB'
just = 'R'
length = '100'
Case ac_type = '10'
* text
oi_type = 'VARCHAR(255)'
pattern = ''
conv= ''
just = 'L'
length = this_size
Case ac_type = '12'
oi_type = 'TEXT'
pattern = ''
conv= ''
just = 'L'
length = this_size
If length < 1 then
length = 50
end
case 1
* default to text
oi_type = 'VARCHAR(255)'
pattern = ''
conv= ''
just = 'L'
length = this_size
End case
If length < 1 then
length = 50
end
drec = Xlate('DICT.':tname_oi, colname, '','X')
orig = drec
drec<DICT_TYPE$> = 'F'
drec<DICT_COLUMN_NO$> = this_fmc
drec<DICT_DISPLAY$> = colheads<j>
drec<DICT_SM$> = 'S'
drec<DICT_PART$> = this_part
drec<DICT_CONV$> = conv
drec<DICT_LENGTH$> = length
drec<DICT_JUST$> = just
drec<DICT_PATTERN$> = pattern
drec<DICT_GENERIC_TYPE$> = oi_type
If drec # orig then
Write drec On d_tname, colname else
err = 'Unable to write DICT ' : tname_oi : ', column ' : colname
is_Ok = false$
Goto ExitFunction
end
end
colfmcs<j> = this_fmc
colparts<j> = this_part
Next
tnames_ac<1,-1>= tname_ac
tnames_oi<1,-1> = tname_oi
Next
* Keep a list of the MsAccess tables and corresponding OI tables
rec = ''
Return
InternetExplorer
ADO
XMLHttp
function Ole_GetWebpage(url, method, payload)
/*
Use The XMLHttp object to Send a web request to a server
Notes:
This function allows you to send POST requests, as if the data was submitted from a web
form. XmlHttp can also process https requests.
*/
if assigned(url) else url = ''
if assigned(method) else method = ''
if assigned(payload) else payload = ''
equ sync$ to 0
equ async$ to 1
convert @lower.case to @upper.case in method
if method = 'POST' else method = 'GET'
oHttp = OleCreateInstance('MsXml2.ServerXmlhttp')
x = oHttp->Open(method, url, sync$)
x = oHttp->Send(payload)
html = oHttp->ResponseText
return html