Hello,
I have just started on programming for Mac, coming from Windows.
My code is in more files, but when I compile it the program hangs. When I put ti in one file it works OK. What am I missing? Below my code:
When I open the database in plantenkennis.prg the program runs, but exits on mouse-scroll
When I open the database using function in functions.prg, the app hangs
Rene Koot
file: plantenkennis.prg;
#include "FiveMac.ch"
#include "Functies.prg"
function Main()
local oWnd, oBrw
local cpath:=Path()
PUBLIC leigen := .T.
PUBLIC lPro := .T.
PUBLIC lEtiket := .F.
PUBLIC cDataBasePad := cPath + "/databases/"
PUBLIC aDatabases[0][8]
PUBLIC aIndexFiles[0][2]
RK_FillArrays()
RK_BestandsControle()
RK_OpenTables()
*USE (cDatabasePad + 'latnaam') INDEX (cDatabasePad + 'Latnum'), (cDatabasePad + 'Latnaam'), (cDatabasePad + 'Latkode') ALIAS Latnaam NEW
DEFINE WINDOW oWnd TITLE "Plantenkennis" ;
FROM 30, 70 TO 650, 820
@ 48, 20 BROWSE oBrw ;
FIELDS Plantkode, Naam ;
HEADERS "Latnaam->Kode", "Latnaam->Naam" ;
OF oWnd SIZE 672, 563 ALIAS Alias()
oBrw:SetColWidth( 1, 300 )
oBrw:SetColWidth( 2, 500 )
ACTIVATE WINDOW oWnd
return nil
File functies.prg:
#include "FiveMac.ch"
#define CR_LF Chr(13) + Chr(10)
FUNCTION RK_FillArrays()
*hier worden alle benodigde arrays gevuld
*date: 24-11-2015
*alle databases, volgorde: filenaam, alias, aantal indexes, indexnamen
AADD(aDataBases, {'latnaam.dbf', 'Latnaam', 3, 'Latnum', 'Latnaam', 'Latkode', '', ''})
AADD(aDataBases, {'planten.dbf', 'Planten', 1, 'Planten', '', '', '', ''})
AADD(aDataBases, {'nednaam.dbf', 'Nednaam', 2, 'Nednum', 'Nednaam', '', '', ''})
*AADD(aDataBases, {'gegeven.dbf', 'Gegeven', 1, 'Gegeven', '', '', '', ''})
*AADD(aDataBases, {'criteria.dbf', 'Criteria', 1, 'Criteria', '', '', '', ''})
*AADD(aDataBases, {'geslacht.dbf', 'Geslacht', 1, 'GeslachtNaam', '', '', '', ''})
*AADD(aDataBases, {'groep.dbf', 'Groep', 1, 'Groep', '', '', '', ''})
*AADD(aDataBases, {'familie.dbf', 'Familie', 1, 'FamilieNaam', '', '', '', ''})
*AADD(aDataBases, {'fotograaf.dbf', 'FotoGraaf', 0, '', '', '', '', ''})
*AADD(aDataBases, {'beheerlijst.dbf' 'BeheerLijst', 0, '', '', '', '', ''})
*AADD(aDataBases, {'lijst.dbf', 'Lijst', 5, 'Lijstloc', 'Lijstkode', 'LijstLat', 'LijstNed', 'LijstNed'})
*AADD(aDataBases, {'plantlib.dbf', 'PlantLib', 2, 'LibNaam', 'Libkode', '', '', ''})
*AADD(aDataBases, {'selectie.dbf', 'Selectie', 3, 'SelecKode', 'Selectie', 'SelecNed', '', ''})
*AADD(aDataBases, {'sneltext.dbf', 'Sneltext', 1, 'SnelText', '', '', '', ''})
*AADD(aDataBases, {'snoei.dbf', 'Snoei', 1, 'Snoei', '', '', '', ''})
*AADD(aDataBases, {'snoeiwijze.dbf', 'Snoeiwijze', 1, 'SnoeiWijze', '', '', '', ''})
*AADD(aDataBases, {'afstanden.dbf', 'Familie', 1, 'afstanden', '', '', '', ''})
IF lPro
* AADD(aDataBases, {'lijsten\klanten.dbf', 'Klanten', 1, 'KlantNaam', '', '', '', ''})
* AADD(aDataBases, {'lijsten\maten.dbf', 'Maten', 1, 'MaatPlant', '', '', '', ''})
* AADD(aDataBases, {'lijsten\beheer.dbf', 'Beheer', 2, 'BeheerKlant', 'BeheerLijst', '', '', ''})
* AADD(aDataBases, {'lijsten\plantlijst.dbf', 'PlantLijst', 5, 'Lijstnr', 'Naam', 'Type', 'Vak', 'Locatie'})
ENDIF
* AADD(aDataBases, {'etiketten\lblsize.dbf', 'LabelSize', 0, '', '', '', '', ''})
* AADD(aDataBases, {'etiketten\papersiz.dbf', 'PaperSize', 0, '', '', '', '', ''})
* AADD(aDataBases, {'etiketten\lblayout.dbf', 'LabelLay', 0, '', '', '', '', ''})
* AADD(aDataBases, {'etiketten\lbmanage.dbf', 'LabelManage', 0, '', '', '', '', ''})
* AADD(aDataBases, {'etiketten\listlay.dbf', 'ListLay', 0, '', '', '', '', ''})
* AADD(aDataBases, {'etiketten\listman.dbf', 'ListManage', 0, '', '', '', '', ''})
* AADD(aDataBases, {'etiketten\exportexcel.dbf', 'ExportExcel', 0, '', '', '', '', ''})
IF lEtiket
ENDIF
IF lEigen
* AADD(aDataBases, {'algemeen.dbf', 'Algemeen', 1, '', '', '', '', ''})
* AADD(aDataBases, {'duitsnaam.dbf', 'DuitsNaam', 1, '', '', '', '', ''})
* AADD(aDataBases, {'engelsnaam.dbf', 'EngelsNaam', 1, '', '', '', '', ''})
* AADD(aDataBases, {'fransnaam.dbf', 'FransNaam', 1, '', '', '', '', ''})
ENDIF
AADD(aIndexFiles, {'Latnum', 'PlantNum'})
AADD(aIndexFiles, {'Latnaam', 'Naam'})
AADD(aIndexFiles, {'Latkode', 'PlantKode'})
AADD(aIndexFiles, {'Planten', 'PlantNum'})
AADD(aIndexFiles, {'Nednum', 'PlantNum'})
AADD(aIndexFiles, {'Nednaam', 'UPPER(NederNaam)'})
RETURN NIL
*************************************************
FUNCTION RK_BestandsControle()
*om alle bestanden te controleren of ze aanwezig zijn
*date: 24-11-2015
LOCAL cBestand := '', cIndexFile := '', cField := '', r := 0
LOCAL cBarBestand := '', cBarIndex := ''
LOCAL n, i
FOR n = 1 TO LEN(aDataBases)
cBestand := cDataBasePad + aDataBases[n,1]
cBarBestand := aDataBases[n,1]
IF .NOT. FILE(cBestand)
MSgInfo(cBestand + ' is niet aanwezig' + CR_LF + 'Het programma wordt afgesloten')
RETURN
ELSE
IF aDataBases[n,3] > 0
FOR i = 1 TO aDataBases[n,3]
cIndexFile := cDataBasePad + aDataBases[n, i+3] + '.ntx'
cBarIndex := aDataBases[n, i+2]
IF .NOT. FILE(cIndexFile)
r := ASCAN(aIndexFiles, { |x| x[1] == aDataBases[n,i+3]})
IF r > 0
cField := aIndexFiles[r,2]
USE &cBestand
* Win_Main.StatusBar.Item(1) := 'Index maken voor: ' + cBarBestand + ' -> ' + cBarIndex
INDEX ON &cField TO &cIndexFile EVAL NtxProgress() EVERY LASTREC()/100
USE
ELSE
* MsgInfo('foutje in de indexarray')
ENDIF
ENDIF
NEXT
ENDIF
ENDIF
NEXT
RETURN NIL
*************************************************
FUNCTION NtxProgress()
LOCAL nComplete := INT((RECNO()/LASTREC()) * 100)
*Win_Main.StatusBar.Item(2) := 'Gedaan: ' + ALLTRIM(STR(nComplete)) + ' %'
*DO EVENTS
RETURN .T.
*************************************************
FUNCTION RK_OpenTables()
*hier worden alle bestanden geopend
*date: 25-11-2015 (aangepaste vesie)
LOCAL cDataBase := '', aIndex[0], cAlias := ''
*LOCAL cTekst := ''
FOR n = 1 TO LEN(aDataBases)
ASIZE(aIndex, 0)
cDataBase := cDataBasePad + aDataBases[n,1]
cAlias := aDataBases[n,2]
IF aDatabases[n,3] > 0
FOR i = 1 TO aDataBases[n,3]
AADD(aIndex, cDataBasePad + aDataBases[n,i+3])
NEXT
ENDIF
IF LEN(aIndex) == 0
USE (cDataBase) NEW ALIAS &cAlias SHARED
ELSEIF LEN(aIndex) == 1
USE (cDataBase) INDEX (aIndex[1]) NEW ALIAS &cAlias SHARED
ELSEIF LEN(aIndex) == 2
USE (cDataBase) INDEX (aIndex[1]), (aIndex[2]) NEW ALIAS &cAlias SHARED
ELSEIF LEN(aIndex) == 3
USE (cDataBase) INDEX (aIndex[1]), (aIndex[2]), (aIndex[3]) NEW ALIAS &cAlias SHARED
ELSEIF LEN(aIndex) == 4
USE (cDataBase) INDEX (aIndex[1]), (aIndex[2]), (aIndex[3]), (aIndex[4]) NEW ALIAS &cAlias SHARED
ELSEIF LEN(aIndex) == 5
USE (cDataBase) INDEX (aIndex[1]), (aIndex[2]), (aIndex[3]), (aIndex[4]), (aIndex[5]) NEW ALIAS &cAlias SHARED
ELSEIF LEN(aIndex) == 6
USE (cDataBase) INDEX (aIndex[1]), (aIndex[2]), (aIndex[3]), (aIndex[4]), (aIndex[5]), (aIndex[6]) NEW ALIAS &cAlias SHARED
ENDIF
NEXT
MsgInfo('tables opened')
RETURN NIL