[python-win32] How to add a record to a record list??
Bob Gailer
bgailer at alum.rpi.edu
Wed Jul 30 16:00:23 EDT 2003
At 10:11 PM 7/30/2003 +0200, kbond wrote:
>Hello,
>
>I am sorry for this long mail but I am completly stuck with the following
>problem I hope that someone will
>be able to help me even if my problem is link to a propriatary software.
>
>I am trying to translate into python some very basic VB script using an
>application called SMARTEAM.
>I getting a pb to add a record to a record list.
>I think I am missing something but I don't know what
>
>here It is an extract of the VB source script:
>
>Sub Main()
> Dim RecList As Object
> Dim SmRecord As Object
> Dim SpecRecValArrays() As String
> Dim HeaderCnt As Integer,i As Integer
>
>
> On Error GoTo ErrorTreat
>'================================Creating an SmRecordList
>object===============================
> Set RecList = CreateObject("SmRecList.SmRecordList")
>
>'================================Filling SmRecordList with headers and
>values===============================
> RecList.AddHeader "First Name",20,sdtchar
> RecList.AddHeader "Last Name",20,sdtchar
> RecList.AddHeader "ID",20,sdtchar
> RecList.AddHeader "Date of birth",8,sdtDate
> ' Adding first record Values
> RecList.Value("First Name",0) = "Joe"
> RecList.Value("Last Name",0) = "Smith"
> RecList.Value("ID",0) = "2145687-9"
> RecList.FormattedValueAsString("Date of birth",0,"dd/mm/yyyy") =
> "23/06/1968"
>
> 'Adding second record values
> RecList.Value("First Name",1) = "Sue"
> RecList.Value("Last Name",1) = "Ellen"
> RecList.Value("ID",1) = "7654980-7"
> RecList.FormattedValueAsString("Date of birth",1,"dd/mm/yyyy") =
> "12/10/1977"
>
>the translation in python give me something like this:
>
>import win32com.client
>
>#===========================Creating an SmRecordList
>object=====================
>
>recList=win32com.client.Dispatch("SmRecList.SmRecordList")
>
>#================Filling SmRecordList with headers and
>values===================
>recList.AddHeader("FirstName", 20, 1) #####my fist problem I do not
>understand why
>recList.AddHeader ("Last Name",20,1) ####I cannot give name of the
>Standard Data
>recList.AddHeader ("ID",20,7) ####Type but I Have to
>give the rank of this data type in the enum.
>
>#==========================Adding first record
>Values===========================
>#Here is my major problem I cannot a valu to the first Record
>#Till now I have tried the following syntaxe but none of them was ok
>###----1----
>recList.Value("FirstName",0,"joe")
> File
> "E:\users\install\Python23\Lib\site-packages\wxPython\tools\boa\ExternalLib\PythonInterpreter.py",
> line 69, in push
> exec code in self.locals
> File "<console>", line 1, in ?
>'''exceptions.TypeError : Value() takes at most 3 arguments (4 given)'''
>###----2----
>recList.Value("FirstName",1) = "joe"
>'''exceptions.SyntaxError : can't assign to function call'''
In VB () are overloaded; they can mead a function call or an indexing
operation.
Set RecList = CreateObject("SmRecList.SmRecordList") ' is an example of a
function call
RecList.Value("First Name",0) = "Joe" ' is an example of indexed assignment
In Python indexing and indexed assignment is expressed using []
So try
recList.Value["FirstName",1] = "joe"
[snip]
Bob Gailer
bgailer at alum.rpi.edu
303 442 2625
-------------- next part --------------
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.500 / Virus Database: 298 - Release Date: 7/10/2003
More information about the Python-win32
mailing list