Path: csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: "Wolfgang Riedmann" Newsgroups: comp.lang.clipper.visual-objects Subject: Re: Write to a dynamically create dbf file Date: Mon, 13 Mar 2017 10:54:17 +0100 Lines: 100 Message-ID: References: <5acf7471-a040-404f-875c-da510487f6f7@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 X-Trace: individual.net KFlQCLpO4caZp7ug5DSiCwhWHHQF2uUfXdjoOlpEnCM6ugAmE= Cancel-Lock: sha1:1psTq8yvuUiY3CV0jUI2Hjkd1to= User-Agent: XanaNews/1.18.1.6 Xref: csiph.com comp.lang.clipper.visual-objects:10278 Hi Michael, this is code I'm using when the structures of both DBFs are not the same, but only a few fields: nLen := oTarget:FCount for nI := 1 upto nLen nPos := oSource:FieldPos( oTarget:FieldName( nI ) ) if nPos != 0 oTarget:FieldPut( nI, oSource:FieldGet( nPos ) ) endif next Wolfgang beerhand wrote: > Hi all, > > it is a long time ago I used CAVO (2.6). I "mastered" to dynamically > create a "new dbf" file that was based on rows of an "existing dbf" > file (DBServer). Now I need to fill the "new dbf" from another "from > dbf" file. > > I am able to browse/append the "new dbf" through the StdDataWindow. > The problem now is that I want to fill the rows with data and do not > know how to access the fieldnames of the "new dbf". Using the mehtod > self:server:fieldget(i) I get a string with the corresponding > fieldname. e.g. (new dbf) self:server:fieldget(1) = "Alpha", > self:server:fieldget(2) = "Beta", etc > > Now I need to write data into this field (and the other fields). I do > not know how to access this like self:server:fieldget(1) := value. > > I can use Method DataServer:DBStruct but still have no idea how the > access the individual fields of the "new dbf" > > > Any help and ideally an example is highly appreciated. By the way I > am "just" an amateur developer. > > Thanks Michael > > Example: > > "Existing dbf" dbServer: > ---------------------------------------------- > Name, C, 50 > ---------------------------------------------- > Alpha > Beta > Gamma > + > + > ---------------------------------------------- > > "from dbf" existing dbServer > ---------------------------------------------- > ID, N,12 . Year - Beta, C 50 - Value, N, 12 > ---------------------------------------------- > 1 2017 Alpha 1000 > 2 2017 Beta 2000 > 3 2018 Alpha 500 > 4 2019 Gamma 100 > 5 2017 Beta 1000 > 6 2018 Alpha 100 > + > + > ----------------------------------------------- > > > "NEW DBF" - dynamically create dbf file (access through > stdDataWindow) but do not know how to fill the rows > ---------------------------------------------- Alpha, N,12 . Beta, > N 12 - Gamma - N, 12 <- how to access these fields? > ---------------------------------------------- ??? ???? > ???? + > + > ---------------------------------------------- > > > Result should look like this: > > "NEW DBF" filled by detail "from dbf" > Year, N,4 - Alpha, N,12 . Beta, N 12 - Gamma - N, 12 > ---------------------------------------------------------------------- > -- year Sum("alpha", year) Sum("beta", year) Sum("Gamma", > year) > ---------------------------------------------------------------------- > -- 2017 1000 2000+1000 0 2018 > 500 0 0 2019 0 > 0 100 + > + > ---------------------------------------------------------------------- --