Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.clipper.visual-objects > #3221 > unrolled thread

How do I Enumerate / List all Fields in a DBServer Object? (VO 2.8)

Started byjames@multiexpress.com
First post2012-03-20 11:14 -0700
Last post2012-03-22 02:25 -0700
Articles 8 — 6 participants

Back to article view | Back to comp.lang.clipper.visual-objects


Contents

  How do I Enumerate / List all Fields in a DBServer Object? (VO 2.8) james@multiexpress.com - 2012-03-20 11:14 -0700
    Re: How do I Enumerate / List all Fields in a DBServer Object? (VO 2.8) Willie Moore <williem@wmconsulting.com> - 2012-03-20 19:30 +0000
      Re: How do I Enumerate / List all Fields in a DBServer Object? (VO 2.8) james@multiexpress.com - 2012-03-20 12:42 -0700
        Re: How do I Enumerate / List all Fields in a DBServer Object? (VO 2.8) james@multiexpress.com - 2012-03-20 14:35 -0700
          Re: How do I Enumerate / List all Fields in a DBServer Object? (VO 2.8) "Willie Moore" <williem@wmconsulting.com> - 2012-03-21 08:35 -0500
    Re: How do I Enumerate / List all Fields in a DBServer Object? (VO 2.8) Jean-Pierre <jp.maertens@gmail.com> - 2012-03-21 08:59 -0700
    Re: How do I Enumerate / List all Fields in a DBServer Object? (VO 2.8) Mathias <mathias.hakansson@consultec.se> - 2012-03-22 00:41 -0700
    Re: How do I Enumerate / List all Fields in a DBServer Object? (VO 2.8) Johan Nel <johan.nel@xsinet.co.za> - 2012-03-22 02:25 -0700

#3221 — How do I Enumerate / List all Fields in a DBServer Object? (VO 2.8)

Fromjames@multiexpress.com
Date2012-03-20 11:14 -0700
SubjectHow do I Enumerate / List all Fields in a DBServer Object? (VO 2.8)
Message-ID<28542568.1989.1332267267928.JavaMail.geo-discussion-forums@pbbpx3>
Hi all,

I am trying to write a function that takes a DBServer object pointed at a DBF, and loops through all the fields, getting the fieldname and value for each one (value from at the current row). Does anyone have any sample code or pointers as to which function I should use?

Many thanks,
James

[toc] | [next] | [standalone]


#3222

FromWillie Moore <williem@wmconsulting.com>
Date2012-03-20 19:30 +0000
Message-ID<1016611229353964451.892318williem-wmconsulting.com@news.aioe.org>
In reply to#3221
<james@multiexpress.com> wrote:
> Hi all,
> 
> I am trying to write a function that takes a DBServer object pointed at a
> DBF, and loops through all the fields, getting the fieldname and value
> for each one (value from at the current row). Does anyone have any sample
> code or pointers as to which function I should use?
> 
> Many thanks,
> James

James,

In VO you will have to use a for/next loop. I can send you a sample that
loops through a DBF. I used that to reformat data before I converted my DBF
data to SQL. 

Regards,
Willie
Vulcan VIP

[toc] | [prev] | [next] | [standalone]


#3223

Fromjames@multiexpress.com
Date2012-03-20 12:42 -0700
Message-ID<22145903.870.1332272560494.JavaMail.geo-discussion-forums@pbcjk1>
In reply to#3222
Thanks, that sounds perfect. Please send to my email address that I posted with on here !

James

[toc] | [prev] | [next] | [standalone]


#3227

Fromjames@multiexpress.com
Date2012-03-20 14:35 -0700
Message-ID<14379672.4780.1332279328154.JavaMail.geo-discussion-forums@pbcr5>
In reply to#3223
Just to clarify, my email is james *at* multiexpress.com

You could just post it here, at least the relevant section of code. It might be beneficial to others with the same question.

Thanks,
James

[toc] | [prev] | [next] | [standalone]


#3231

From"Willie Moore" <williem@wmconsulting.com>
Date2012-03-21 08:35 -0500
Message-ID<jkclev$tnj$1@speranza.aioe.org>
In reply to#3227
James,

You should have received the info last night. If not please check your spam 
filters. The message might have sneded up there.

Regards,
Willie
Vulcan VIP

wrote in message 
news:14379672.4780.1332279328154.JavaMail.geo-discussion-forums@pbcr5...

Just to clarify, my email is james *at* multiexpress.com

You could just post it here, at least the relevant section of code. It might 
be beneficial to others with the same question.

Thanks,
James 

[toc] | [prev] | [next] | [standalone]


#3232

FromJean-Pierre <jp.maertens@gmail.com>
Date2012-03-21 08:59 -0700
Message-ID<52900c12-fa30-413c-8ce5-adc37c62c484@z31g2000vbt.googlegroups.com>
In reply to#3221
Perhaps something like this ?


METHOD Record2Array() CLASS JPServer
	LOCAL aTabel AS ARRAY
	LOCAL x AS DWORD

	aTabel:=ArrayCreate(SELF:FCount+1)
	FOR x:=1 UPTO SELF:FCount
	    aTabel[x]:={self:fieldname,self:fieldget(x)}
	NEXT

	aTabel[x]:={"Recordnum",SELF:RecNo} // add the recordnumber : used by
other methods

	RETURN aTabel

[toc] | [prev] | [next] | [standalone]


#3235

FromMathias <mathias.hakansson@consultec.se>
Date2012-03-22 00:41 -0700
Message-ID<5391337.2764.1332402110696.JavaMail.geo-discussion-forums@vbiz13>
In reply to#3221
Hi James,

You could get some inspiration from a database copy routine that I use for tables with minor errors. It opens an original database, creates a new database with the same structure, copies all records and reports all fields that it is unable to copy.

method PBCopy( ) class DBCheck 
	local oDBOrig,oDBCopy	as DBServer  
	local dwi,dwl,i,l			as dword
	local oDBFileSpec			as DbFileSpec
	local bLastHandler,oLocal			
	                      
	self:oDCProgressBar:Range := Range{0,100}
	bLastHandler := ErrorBlock({|oErr| MyErrorHandler(oErr,true) })
	
	begin sequence
		oDBOrig := DbServer{self:oDCSLEOriginal:currenttext,DBEXCLUSIVE,DBREADONLY,"dbfcdx"}
	recover using oLocal
		InfoBox{,"Copy","Failed to open the original file " + self:oDCSLEOriginal:currenttext + "!"}:Show()
		
		return nil 
	end sequence
	    
	oDBFileSpec := DbFileSpec{}
	if !oDBFileSpec:MathiasCreate(self:oDCSLECopy:currenttext,oDBOrig:DbStruct,"DBFCDX",true)
		InfoBox{,"Copy","Failed to create copy " + self:oDCSLECopy:currenttext + "!"}:Show()
		oDBOrig:Close()
		
		return nil
	endif
	oDBCopy := DbServer{self:oDCSLECopy:currenttext,DBEXCLUSIVE,DBREADWRITE,"dbfcdx"}
		
	oDBOrig:SetOrder(0)
	dwl := oDBOrig:reccount      
	dwi := 0               
	l := ALen(oDBOrig:DbStruct)
	oDBOrig:GoTop()
	while !oDBOrig:EOF     
		oDBCopy:Append()
		
		for i := 1 upto l
			begin sequence
				oDBCopy:FIELDPUT(oDBOrig:DbStruct[i,1],oDBOrig:FIELDGET(oDBOrig:DbStruct[i,1]))
			recover using oLocal
				self:oDCMLEInfo:currenttext += "Failed to copy record " + NTrim(oDBOrig:RECNO) + " field " + oDBOrig:DbStruct[i,1] + CrLf 
			end sequence
		next
		                 
		oDBCopy:Commit()
		oDBOrig:Skip()
		++dwi                                       
		
		if dwi%10 == 0
			self:oDCProgressBar:position := dword(float(dwi)/float(dwl)*100.)
			ApplicationExec(EXECWHILEEVENT)
		endif
	enddo
	
	oDBOrig:Close()
	oDBCopy:Commit()
	oDBCopy:Close()
	
	InfoBox{,"Copy","Finished!"}:Show()          
	
return nil

/Mathias

Den tisdagen den 20:e mars 2012 kl. 19:14:27 UTC+1 skrev ja...@multiexpress.com:
> Hi all,
> 
> I am trying to write a function that takes a DBServer object pointed at a DBF, and loops through all the fields, getting the fieldname and value for each one (value from at the current row). Does anyone have any sample code or pointers as to which function I should use?
> 
> Many thanks,
> James

[toc] | [prev] | [next] | [standalone]


#3236

FromJohan Nel <johan.nel@xsinet.co.za>
Date2012-03-22 02:25 -0700
Message-ID<72225f9b-66f1-4714-af63-e6735905f7ed@do4g2000vbb.googlegroups.com>
In reply to#3221
James,

FUNCTION Rec2Array(oDbf AS DbServer) AS ARRAY
  LOCAL aRec AS ARRAY
  LOCAL nFld, nFldCount AS INT
  aRec := {}
  nFldCount := oDbf:FCount
  FOR nFld := 1 UPTO nFldCount
    AAdd(aRec, {oDbf:FIELDNAME(nFld), oDbf:FIELDGET(nFld)})
  NEXT
  AAdd(aRec, {"RECNO", oDbf:RecNo})
RETURN aRec

Regards,

Johan Nel
Vulcan VIP
Durban, South Africa.

On Mar 20, 8:14 pm, ja...@multiexpress.com wrote:
> Hi all,
>
> I am trying to write a function that takes a DBServer object pointed at a DBF, and loops through all the fields, getting the fieldname and value for each one (value from at the current row). Does anyone have any sample code or pointers as to which function I should use?
>
> Many thanks,
> James

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.clipper.visual-objects


csiph-web