V4MD search in API way and cXtraStringGrid example request

info at vallemediatime.com info at vallemediatime.com
Wed Mar 30 16:42:36 CST 2005


Hi Ruslan and Igor
I'm trying API way, buto I don't understand how display some "selected"
field...
e.g.
Table: STUDENTS
Field: Name, LastName, Andress, Phone, and so on
I want find a student with "Paolo" name and I want display only name of
STUDENTS table
in SQL this is easy:  SELECT FieldName from STUDENTS...
but in API way?

I've copied my code for display data with cXtraStringGrid (only for
windows), I ask you if in the next week it's possible to create a
dir-example for this useful xtra. The code of example works...but it has
been hard to understand like the iterator works... The iterator is new and
not easy for now; in the docs I don't see many explanations...
Paolo


-- CODE
on mSearchByName me, rs, table
global gResult
global gTable
Studenti = gDb.table("Studenti")
searchString = member("searchString").text
result = studenti.field("sF2").findValue(searchString)
if CheckValError() then exit
gResult = result
gTable = Studenti
DisplayResultSetOnTable(result, studenti)
tableData = ProduceCursorData(result, studenti)
end

on DisplayResultSetOnTable (rs, table)
member("searchResult").text = string(rs.itemCount)
end

-- CODE  for display data in cXtraStringGrid
on ProduceCursorData (rs, table)
n = 5  -- Sprite Channel
myData = []
row = []
recCount = value(member("searchResult").text)

-- Prepare table header
HeaderList = ["ID", "Num", "Cognome", "Nome", "S", "C.F.", "nG", "nM","nA",
"nComune", "nProv", "nStato",\
"rVia", "rCAP", "rComune", "rProv", "Tel.1", "Tel.2","mail", "ssG",
"ssM","ssA", "dG", "dM","dA","Orario pref",\
"Lavoro", "Turn.", "Tit.Studio", "Data arrivo"]

sprite(n).SetRow(0, string(HeaderList))
sprite(n).rowCount = RecCount +1
sprite(n).colCount = HeaderList.count
fieldCount = table.fieldCount

-- Prepare table rows
recCount = rs.itemCount
if recCount > 0 then
iter = rs.makeNewIterator()
if iter.firstItem() then
repeat with i = 1 to recCount
table.recId = iter.value
repeat with j = 0 to fieldCount
f = table.field(j)
sprite(n).SetCellText(j, i, string(f.value))
end repeat
iter.nextItem()
end repeat
end if
end if
sprite(n).ColAutoSize()
return myData
end



-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.8.6 - Release Date: 30/03/2005



More information about the Valentina-beta mailing list