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


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

OK, I'm sorry, but what am I doing wrong/missing?

Started byJeff Rollo <jrollo64@gmail.com>
First post2018-09-17 23:48 -0700
Last post2018-09-19 05:24 -0700
Articles 4 on this page of 24 — 10 participants

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


Contents

  OK, I'm sorry, but what am I doing wrong/missing? Jeff Rollo <jrollo64@gmail.com> - 2018-09-17 23:48 -0700
    Re: OK, I'm sorry, but what am I doing wrong/missing? Stefano Costagli <stea@libero.it> - 2018-09-18 09:34 +0200
      Re: OK, I'm sorry, but what am I doing wrong/missing? Jeff Rollo <jrollo64@gmail.com> - 2018-09-18 00:58 -0700
        Re: OK, I'm sorry, but what am I doing wrong/missing? Robert van der Hulst <rjvanderhulst@gmail.com> - 2018-09-18 01:54 -0700
          Re: OK, I'm sorry, but what am I doing wrong/missing? Jeff Rollo <jrollo64@gmail.com> - 2018-09-18 02:07 -0700
            Re: OK, I'm sorry, but what am I doing wrong/missing? Stefano Costagli <stea@libero.it> - 2018-09-18 12:07 +0200
            Re: OK, I'm sorry, but what am I doing wrong/missing? Robert van der Hulst <rjvanderhulst@gmail.com> - 2018-09-18 03:10 -0700
              Re: OK, I'm sorry, but what am I doing wrong/missing? Franz Rachbauer <office@rachbauer.org> - 2018-09-18 12:34 +0200
                Re: OK, I'm sorry, but what am I doing wrong/missing? Jeff Rollo <jrollo64@gmail.com> - 2018-09-18 04:23 -0700
                  Re: OK, I'm sorry, but what am I doing wrong/missing? Mathias <mathias.hakansson@consultec.se> - 2018-09-18 04:57 -0700
                Re: OK, I'm sorry, but what am I doing wrong/missing? Jeff Rollo <jrollo64@gmail.com> - 2018-09-18 04:27 -0700
                  Re: OK, I'm sorry, but what am I doing wrong/missing? Franz Rachbauer <office@rachbauer.org> - 2018-09-18 14:00 +0200
                    Re: OK, I'm sorry, but what am I doing wrong/missing? Jeff Rollo <jrollo64@gmail.com> - 2018-09-18 05:05 -0700
                      Re: OK, I'm sorry, but what am I doing wrong/missing? Jeff Rollo <jrollo64@gmail.com> - 2018-09-18 05:06 -0700
                        Re: OK, I'm sorry, but what am I doing wrong/missing? Leo_Bond <l.bond@bk.ru> - 2018-09-18 05:37 -0700
                      Re: OK, I'm sorry, but what am I doing wrong/missing? "Wolfgang Riedmann" <wriedmann@gmail.com> - 2018-09-18 16:18 +0200
                  Re: OK, I'm sorry, but what am I doing wrong/missing? dlzc <dlzc1@cox.net> - 2018-09-18 06:48 -0700
    Re: OK, I'm sorry, but what am I doing wrong/missing? Mathias <mathias.hakansson@consultec.se> - 2018-09-19 04:43 -0700
      Re: OK, I'm sorry, but what am I doing wrong/missing? Mathias <mathias.hakansson@consultec.se> - 2018-09-19 05:03 -0700
      Re: OK, I'm sorry, but what am I doing wrong/missing? Jeff Rollo <jrollo64@gmail.com> - 2018-09-19 05:20 -0700
        Re: OK, I'm sorry, but what am I doing wrong/missing? "Jamal" <noooospam@example.com> - 2018-09-19 13:36 -0400
          Re: OK, I'm sorry, but what am I doing wrong/missing? Jeff Rollo <jrollo64@gmail.com> - 2018-09-19 15:42 -0700
        Re: OK, I'm sorry, but what am I doing wrong/missing? Mathias <mathias.hakansson@consultec.se> - 2018-09-20 02:46 -0700
    Re: OK, I'm sorry, but what am I doing wrong/missing? Sherlock <sherlock@sherlock.com.au> - 2018-09-19 05:24 -0700

Page 2 of 2 — ← Prev page 1 [2]


#11961

From"Jamal" <noooospam@example.com>
Date2018-09-19 13:36 -0400
Message-ID<pnu1fb$v1$1@news.albasani.net>
In reply to#11959
Did you resolve the issue or do you still need help?

Jamal

"Jeff Rollo"  wrote in message 
news:519964c7-50c4-4755-9852-51158b6bcfd7@googlegroups.com...

I'd love to read this Mathias, but I'm afraid no sprecken ze Deutch 😎. I 
followed the link but I always end up back at my original post..... 

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


#11966

FromJeff Rollo <jrollo64@gmail.com>
Date2018-09-19 15:42 -0700
Message-ID<4e4e892d-b0fb-4e0d-baf5-7282de839e32@googlegroups.com>
In reply to#11961
Yes, thank you very much Jamal.

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


#11969

FromMathias <mathias.hakansson@consultec.se>
Date2018-09-20 02:46 -0700
Message-ID<80eff860-c5c6-446b-9961-186a26a1a411@googlegroups.com>
In reply to#11959
Den onsdag 19 september 2018 kl. 14:20:23 UTC+2 skrev Jeff Rollo:
> I'd love to read this Mathias, but I'm afraid no sprecken ze Deutch 😎. I followed the link but I always end up back at my original post.....

There are some comments and method names in Swedish. Sorry about that... I'll try to translate...

function AEqual(a1 as array,a2 as array) as logic
	local i,l1,l2 as dword
	
	l1 := ALen(a1)
	l2 := ALen(a2)
	if l1 == l2
		for i := 1 upto l1
			if IsArray(a1[i])
				if IsArray(a2[i])	// Both items are arrays
					if !AEqual(a1[i],a2[i])
						return FALSE	// Arrays not equal
					endif
				else
					return FALSE	// Only one of the items is an array
				endif
			else
				if IsArray(a2[i])
					return FALSE	// Only one of the items is an array
				else	// None of the items are arrays
					if ValType(a1[i]) == ValType(a2[i])	// Items has the same data type
						if !(a1[i] == a2[i])
							if ValType(a1[i]) == "C"
								if !(Upper(a1[i]) == Upper(a2[i]))
									return FALSE	// Items not eqal
								endif
							else
								return FALSE
							endif
						endif
					else
						return FALSE	// Items of different data type
					endif
				endif
			endif
		next
	
		return TRUE
	else
		return FALSE
	endif
function ChangeDBStructure(db,astruct,oProgresWin,aDefault)
	local oTempDB as DBServer
	local driver,filename,indexext,memoext as string
	local oFileSpec,oFS as FileSpec
	local ps,ps1 as psz
	local oDBFileSpec as DBFileSpec
	local symclass as symbol
	local aindexlist as array
	local success,pwCreated as logic
//	local t1,t2 as string
	
	driver := db:driver
	filename := db:filespec:FullPath
	symclass := ClassName(db)
	aindexlist := db:indexlist
	indexext := db:indexext
	memoext := db:Info(DBI_MEMOEXT)
	
	db:Close()
	
	// Delete possible index file
	oFS := FileSpec{filnamn}
	ps := StringAlloc(oFS:drive + oFS:path + oFS:filename + indexext)
	DeleteFile(ps)
	MemFree(ps)
	
	// Copy database to temporary file
	oFileSpec := FileSpec{oFS:drive + oFS:path + "~" + oFS:filename + ".dbf"}
	oFileSpec:extension := "dbf"
	
	ps1 := StringAlloc(oFS:drive + oFS:path + "~" + oFS:filename + ".dbf")

	DeleteFile(ps1)
	success := FRename(filename,oFS:drive + oFS:path + "~" + oFS:filename + ".dbf")
	
	MemFree(ps1)

	if !success
		InfoBox{,"ChangeDBStructure",;
				"Could not rename " + filnamn + CrLf +;
				"It's probably used by another application or user."}:Show()
				
		return false
	endif

	// Memo file
	ps1 := StringAlloc(oFS:drive + oFS:path + "~" + oFS:filename + memoext)
	DeleteFile(ps1)
	FRename(oFS:drive + oFS:path + oFS:filename + memoext,oFS:drive + oFS:path + "~" + oFS:filename + memoext)
	MemFree(ps1)
	
	ApplicationExec(EXECWHILEEVENT)
	
	oDBFileSpec := DBFileSpec{}
	if oDBFileSpec:MathiasCreate(filnamn,astruct,driver,true)
		db := CreateInstance(klass,filnamn,DBEXCLUSIVE,DBREADWRITE)
		CreateIndex(db)
		oTempDB := DBServer{oFileSpec:fullpath,DBEXCLUSIVE,DBREADWRITE,driver}
		if oTempDB:reccount > 100
			if oProgresWin == null_object
				pwcreated := true
				oProgresWin := CallProgresWin{}
				oProgresWin:caption := "Databaskontroll"
				oProgresWin:Show()
			endif
		endif
		if oProgresWin != null_object
			oProgresWin:message := "Changing database structure of " + filename + "."
			ApplicationExec(EXECWHILEEVENT)
		endif
		
		oTempdb:SetOrder(0)	// Copy faster
		db := CreateInstance(symclass,filename,DBEXCLUSIVE,DBREADWRITE)
		db:SetOrder(0)
		
		CopyDB(oTempdb,db,oProgresWin,aDefault)
		
		if oProgresWin != null_object
			oProgresWin:percent := 100
			ApplicationExec(EXECWHILEEVENT)
		endif
		if pwcreated
			oProgresWin:EndDialog()
		endif
		db:Close()
		oTempDB:Close()
		
		ps := StringAlloc(oFileSpec:fullpath)	// Delete dbf
		DeleteFile(ps)
		MemFree(ps)
		
		ps := StringAlloc(oFileSpec:drive + oFileSpec:path + oFileSpec:filename + memoext)	// Delete fpt
		DeleteFile(ps)
		MemFree(ps)
	else
		InfoBox{,"ChangeDBStructure","Could not create the database " + filnamn}:Show()
		return false
	endif

	return true
method MathiasCreate( cFullPath, aDBStruct, cDriver, lWantAnsi, aRDDs ) class DbFileSpec
	local cAlias as string
	local lRetCode as logic
	local rddList as _RDDLIST
	local cPath as string
	local cFileName as string
	local cNewName as string
	local aFullPath as array
	local oSelf as DBFILESPEC
	local lOldAnsi as logic
	local cbOldErr as usual
	local oError as usual

	if IsInstanceOfUsual( cFullPath, #FileSpec )
		cFullPath := cFullPath:FullPath
	endif

	cbOldErr := ErrorBlock( { | oErr | _Break( oErr ) } )

	begin sequence
		if IsArray( cFullPath )
			if IsString( aDBStruct )
				cDriver := aDBStruct
			endif
			aDBStruct := cFullPath
		endif

		if Empty( cFullPath ) .OR. ! IsString( cFullPath )
			if SLen( self:cFSPath ) = RAt2( "\", self:cFSPath )
				cFullPath := self:cFSDrive + self:cFSPath + self:cFSFileName + self:cFSExtension
			else
				cFullPath := self:cFSDrive + self:cFSPath + "\" + self:cFSFileName + self:cFSExtension
			endif
		endif

		if Empty( aDBStruct ) .OR. ! IsArray( aDBStruct )
			cAlias := Symbol2String( __ConstructUniqueAlias( self:cFSFileName ) )
			if DBUSEAREA( true, self:RDD_Name, self:__FullPathAcc(), cAlias, true, true, , , self:RDDs )
				aDBStruct := DBSTRUCT()
				( cAlias ) -> ( DBCLOSEAREA() )
			else
				return false
			endif
		endif

		aFullPath := ArrayNew( 4 )
		oSelf := self

		cFullPath := Upper( cFullPath )
		__SplitPath( oSelf, cFullPath, aFullPath )

		if aFullPath[3] == NULL_STRING
			aFullPath[3] := self:cFSFileName
		endif

		if aFullPath[4] == NULL_STRING
			aFullPath[4] := self:cFSExtension
		endif

		cPath := aFullPath[1] + aFullPath[2]
		cFileName := aFullPath[3] + aFullPath[4]

*		if aFullPath[3] == self:cFSFileName
			cAlias := Symbol2String( __ConstructUniqueAlias( aFullPath[3] ) )
*		endif

		if SubStr2( cPath, SLen( cPath ) ) == "\"
			if ( cNewName := __NewName( cPath + cFileName ) ) != NULL_STRING
				cFileName := cPath + cNewName + aFullPath[4]
			else
				cFileName := cPath + aFullPath[3] + aFullPath[4]
			endif
		else
			if ( cNewName := __NewName( cPath + "\" + cFileName ) ) != NULL_STRING
				cFileName := cPath + "\" + cNewName + aFullPath[4]
			else
				cFileName := cPath + "\" + aFullPath[3] + aFullPath[4]
			endif
		endif


		aRdds := __RddList( cDriver, aRdds )
		rddList := __AllocRddList( aRdds )

		if Empty( lWantAnsi ) .OR. ! IsLogic( lWantAnsi )
			lOldAnsi := SetAnsi( self:lAnsi )
		else
			lOldAnsi := SetAnsi( lWantAnsi )
		endif

		lRetCode := VODBCreate( cFileName, aDBStruct, rddList, true, cAlias, "", false,false )

		MemFree( rddList )

		if lRetCode
			if self:HeaderSize == 0
				self:FullPath := cFileName
				lRetCode := self:DBFSGetInfo( aRDDs )
			endif
		endif

		SetAnsi( lOldAnsi )

	recover using oError
		ErrorBlock( cbOldErr )
		if oError:OsCode != 0
			oError:Description := VO_SPrintF( __CAVOSTR_SYSLIB_DOS_ERROR, NTrim( oError:OsCode ) + ;
				" ( " + DosErrString( oError:OsCode ) + " )" )
		endif

		self:oErrorInfo := oError
		lRetCode := false

	end sequence

	ErrorBlock( cbOldErr )

	return lRetCode

function DBCheck(file,symclass,oProgresWin,aDefault) as object
	local db,oLocal,bLastHandler
	local lerror,lNotCorrect,pwcreated,lDeleted as logic
	local astruct,ail as array
	local i,l,wargtype as dword
	local filename,indexext,sarg as string
	local oFileSpec as FileSpec
	local ps as psz
//	local oProgresWin as CallProgresWin

	if !Empty(file) .and. IsClass(symclass)
		bLastHandler := ErrorBlock({|oErr| MyErrorHandler(oErr,true) })
		
		lDeleted := SetDeleted(false)
		
		lerror := true
		while lerror
			begin sequence
				db := CreateInstance(symclass,file,DBSHARED,DBREADWRITE)
				
                // Check structure
				astruct := FieldDesc2Struct(db:fielddesc)
				if !AEqual(astruct,db:dbstruct)
					if StructureNeedsChanging(astruct,db:DBSTRUCT)//ALen(db:dbstruct) <= ALen(astruct)
						if ChangeDBStructure(db,astruct,oProgresWin,aDefault)
							db := CreateInstance(symclass,file,DBSHARED,DBREADWRITE)
						else
							lerror := false
						endif
					endif
				endif
		
				
				if lerror	// Continue checking
					// Check all orders
					lNotCorrect := false
					ail := db:indexlist
					if !Empty(ail)
						l := ALen(ail[1,DBC_ORDERS])
						for i := 1 upto l
							
							if db:OrderInfo(DBOI_NUMBER,,ail[1,DBC_ORDERS,i,DBC_TAGNAME]) != 0
								if db:OrderIsUnique(ail[1,DBC_ORDERS,i,DBC_TAGNAME]) == ail[1,DBC_ORDERS,i,DBC_DUPLICATE]
									lNotCorrect := true
								endif
								if db:OrderDescend(ail[1,DBC_ORDERS,i,DBC_TAGNAME]) == ail[1,DBC_ORDERS,i,DBC_ASCENDING]
									lNotCorrect := true
								endif
								if !(Upper(db:OrderInfo(DBOI_EXPRESSION,,ail[1,DBC_ORDERS,i,DBC_TAGNAME])) ==;
									 Upper(ail[1,DBC_ORDERS,i,DBC_KEYEXP]))
				 					lNotCorrect := true
				 				endif
								if !(Upper(db:OrderInfo(DBOI_CONDITION,,ail[1,DBC_ORDERS,i,DBC_TAGNAME])) ==;
									 Upper(ail[1,DBC_ORDERS,i,DBC_FOREXP]))
									lNotCorrect := true
								endif
							else
								lNotCorrect := true
							endif
						next
					endif
				
					if lNotCorrect
						
						filename := db:filespec:FullPath
						indexext := db:indexext
						
						db:Close()
						
						oFileSpec := FileSpec{filename}
						ps := StringAlloc(oFileSpec:drive + oFileSpec:path + oFileSpec:filename + indexext)
						DeleteFile(ps)
						MemFree(ps)
						
						db := CreateInstance(symclass,file,DBEXCLUSIVE,DBREADWRITE)
						
						if db:reccount > 1000
							if oProgresWin == null_object
								pwCreated := true
								oProgresWin := CallProgresWin{}
								oProgresWin:caption := "Database check"
								oProgresWin:Show()
							else
								pwCreated := false
							endif
						else
							pwCreated := false
						endif
						if oProgresWin != null_object
							oProgresWin:Message := "Creating new index for database " + db:filespec:fullpath + "."
							ApplicationExec(EXECWHILEEVENT)
						endif
						db:Pack()
						SkapaIndex(db,oProgresWin)
						if oProgresWin != null_object
							oProgresWin:percent := 100
							ApplicationExec(EXECWHILEEVENT)
						endif
						if pwCreated
							oProgresWin:EndDialog()
						endif
					
						db:Close()
						db := CreateInstance(symclass,file,DBSHARED,DBREADWRITE)
					endif
					
	
					lerror := false
				endif
			recover using oLocal
				ErrorBlock(bLastHandler)
				
				do case
					case oLocal:oscode == 2	// File missing. Lets create it.
						if CreateDB(oLocal)
							db := CreateInstance(symclass,file,DBEXCLUSIVE,DBREADWRITE)
							if !CreateIndex(db)
								lerror := false
								Eval(bLastHandler,oLocal)
								db := CreateInstance(klass,fil,DBSHARED,DBREADWRITE)
							else
								db:Close()
								db := CreateInstance(klass,fil,DBSHARED,DBREADWRITE)
								lerror := false
							endif
						else	// Create standard error
							lerror := false
							Eval(bLastHandler,oLocal)	// Create common error message.
						endif
					case oLocal:oscode == 32	// Sharing violation. The file is already open.
						InfoBox{,"Database check",;
								  "Tried to adjust database " + file + ", but failed due to sharing violation!" + CrLf +;
								  ListStack()}:Show()
						lerror := false
						db := CreateInstance(symclass,file,DBSHARED,DBREADWRITE)
					case oLocal:oscode == 5	// Access denied
						InfoBox{,file,"Could not open " + file + ". Insufficient permissions or file is write protected"}:Show()
						lerror := false
					case InList(oLocal:subcode,2035,2006)	// fpt-file missing, or write protected. Corrupted
						InfoBox{,fil,oLocal:operation}:Show()
						lerror := false
					otherwise
						lerror := false
						if !Empty(oLocal:ArgNum) .and. (oLocal:ArgNum <= ALen(oLocal:Args))
							sArg := AsString(oLocal:Args[oLocal:ArgNum])
							wArgType := UsualType(oLocal:Args[oLocal:ArgNum])
						endif

						InfoBox{,"DBCheck error",file + CrLf + CrLf + sarg + Str(wargtype) + Symbol2String(oLocal:funcsym) +;
												  oLocal:operation + Str(oLocal:subcode) + oLocal:Subcodetext +;
												  Str(oLocal:oscode) + CrLf + ListStack()}:Show()
*						InfoBox{,"DBCheck error",sarg + Str(wargtype) + Symbol2String(oLocal:funcsym) + oLocal:operation + Str(oLocal:subcode) + Str(oLocal:oscode) + CrLf + ListStack()}:Show()
						*Eval(blastHandler,oLocal)	// Create common error message.
				endcase
			end sequence
		enddo
	
		ErrorBlock(bLastHandler)
		
		SetDeleted(lDeleted)
	endif

	return db
function FieldDesc2Struct(afielddesc as array) as array
	local i,l as dword
	local astruct as array

	l := ALen(afielddesc)
	astruct := ArrayCreate(l)
	for i := 1 upto l
		astruct[i] := {afielddesc[i,DBC_NAME],afielddesc[i,DBC_FIELDSPEC]:ValType,afielddesc[i,DBC_FIELDSPEC]:length,;
					   afielddesc[i,DBC_FIELDSPEC]:decimals,afielddesc[i,DBC_NAME]}
	next

	return astruct
static global Gcount as dword
static global GoProg as object
static global GProgress as dword
procedure CopyDB(dbfrom,dbto,oProgresWin,aDefault)
	local oLocal,bLastHandler
	local astruct					as array
    local l,i,j,records,n,dwlDef	as dword
    local fieldnamne					as string
    local lDeleted					as logic
	
	Default(@aDefault,{})
	
	astruct := {}	// Check common fields
	l := ALen(dbfrom:dbstruct)
	for i := 1 upto l
		fieldname := dbfrom:dbstruct[i,DBS_NAME]
		j := AScan(dbto:dbstruct,{|x| x[DBS_NAME] == fieldname })
		if j > 0
			if dbfrom:dbstruct[i,DBS_TYPE] == dbtill:dbstruct[j,DBS_TYPE]
				AAdd(astruct,dbfrom:dbstruct[i,DBS_NAME])
			endif
		endif
	next

	// Check default values.
	l := ALen(aDefault)
	i := 1
	while i <= l
		if AScan(astruct,Symbol2String(aDefault[i,1])) != 0
			ADel(aDefault,i)
			ASize(aDefault,ALen(aDefault) - 1)
			l -= 1	
		else
			++i
		endif
	enddo
	dwlDef := ALen(aDefault)

	l := ALen(astruct)
	lDeleted := SetDeleted(true)
	dbfrom:SuspendNotification()	// Makes this routine a little bit faster, but not much.
	dbto:SuspendNotification()
	records := dbfrom:reccount
	
	n := 0
	dbfrom:GoTop()
	
	bLastHandler := ErrorBlock({|oErr| MyErrorHandler(oErr,false) })
	
	while !dbfrom:EOF
		if !dbto:Append()
			InfoBox{,"Copy DB","Failed creating record"}:Show()
		endif
		
		for i := 1 upto l
			begin sequence
				dbtill:FIELDPUT(astruct[i],dbfran:FIELDGET(astruct[i]))
			recover using oLocal
				Tone(440,10)
			end sequence
		next
		
		// Write defaults
		for i := 1 upto dwlDef
			begin sequence
				dbto:FIELDPUT(aDefault[i,1],aDefault[i,2])
			recover using oLocal
				Tone(440,10)
			end sequence
		next
		
		dbfrom:Skip()
		
		if oProgresWin != null_object
			oProgresWin:percent := ++n*100.0/records
			ApplicationExec(EXECWHILEEVENT)
		endif
	enddo

	ErrorBlock(bLastHandler)

	dbfrom:ResetNotification()
	dbto:ResetNotification()
	SetDeleted(lDeleted)


	return
function MyErrorHandler(oError, lLocalHandler)
	if lLocalHandler
		break oError
	endif

	return nil
static function progress() as logic
	if GoProg != NULL_OBJECT
		Gprogress += 1
		if Gcount != 0
			GoProg:percent := 100.0*Gprogress/Gcount
		endif
	endif

	return true
function CreateDB(oLocal as Error) as logic
	local astruct,afielddesc as array
	local driver as string
	local oDBFileSpec as DBFileSpec

	// Create structure array
	afielddesc := IVarGet(oLocal:methodself,#fielddesc)
	astruct := FieldDesc2Struct(afielddesc)

	// Undocumented function. Many thanks to Rod da Silva for revealing it.
	// IVarGetSelf gets a variable from within the object, which means that you can access instance and protect variables.
	driver := IVarGetSelf(oLocal:methodself,#xdriver)
	
  	oDBFileSpec := DBFileSpec{oLocal:filename,"dbfcdx"}
	
	return oDBFileSpec:Create(oLocal:filename,astruct,driver,true)
function CreateIndex(db,oProgresWin)
	local aIndexList as array
	local indexCount,orderCount,i,j,recordCount as dword
	local indexfilename as string
	local lcreated as logic
	
	Gprogress := 0
	recordCount := db:reccount
	indexfilename := db:filespec:drive + db:filespec:path + db:filespec:filename
	aindexlist := db:IndexList
	indexCount := ALen(db:IndexList)
	GoProg := oProgresWin
	for i := 1 upto indexCount
		orderCount := ALen(aIndexList[i,DBC_ORDERS])
		Gcount := orderCount*recordCount/100.

		for j := 1 upto orderCount
				db:SetOrderCondition(aIndexList[i,DBC_ORDERS,j,DBC_FOREXP],,,,{|| progress() },100,,,,,;
											!aIndexList[i,DBC_ORDERS,j,DBC_ASCENDING])
				if j == 1
					lcreated := db:CreateOrder(aIndexList[i,DBC_ORDERS,j,DBC_TAGNAME],indexfilename,aIndexList[i,DBC_ORDERS,j,DBC_KEYEXP],,;
													  !aIndexList[i,DBC_ORDERS,j,DBC_DUPLICATE])
				else
					lcreated := db:CreateOrder(aIndexList[i,DBC_ORDERS,j,DBC_TAGNAME],,aIndexList[i,DBC_ORDERS,j,DBC_KEYEXP],,;
													  !aIndexList[i,DBC_ORDERS,j,DBC_DUPLICATE])
				endif
				if !lcreated
					InfoBox{,"CreateIndex",;
							  'Failed to create order "' + aIndexList[i,DBC_ORDERS,j,DBC_TAGNAME] + '"'}:Show()
					db:Close()
					return false
				endif

		next
	next

	if !db:Close()
		InfoBox{,"CreateIndex","Close failed"}:Show()
	endif

	return true
function StructureNeedsChanging(nystruct as array,oldstruct as array) as logic
	local l,i,j		as dword
	local fieldname	as string

	l := ALen(newstruct)
	for i := 1 upto l
		fieldname := newstruct[i,DBS_NAME]
		j := AScan(oldstruct,{|x| x[DBS_NAME] == fieldname })
		if j == 0
			return true
		else
			if (newstruct[i,DBS_LEN] > oldstruct[j,DBS_LEN]) .or. (newstruct[i,DBS_TYPE] != oldstruct[j,DBS_TYPE])
				// Field has been extended or changed data type
				return true
			endif
		endif
	next

	return false


/Mathias

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


#11960

FromSherlock <sherlock@sherlock.com.au>
Date2018-09-19 05:24 -0700
Message-ID<75c34336-0ec7-404c-a8d1-fd5dba39a883@googlegroups.com>
In reply to#11938
Use 

Setdefault("C:\whereIwantmydatafiles\")

[toc] | [prev] | [standalone]


Page 2 of 2 — ← Prev page 1 [2]

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


csiph-web