Hi!
I am writing piece of code to close all projects before I want to zip my data-files.
In the underlisted function CloseProjects I expect to return an array holding the projects names. But instead it just returns a single var.
What do I oversee?
-Bart
I am writing piece of code to close all projects before I want to zip my data-files.
In the underlisted function CloseProjects I expect to return an array holding the projects names. But instead it just returns a single var.
What do I oversee?
-Bart
Code:
LOCAL lcDay, lnM, lcMonth, lcYear, lcTime, lcBUName, lcAppName, lcUser, lnProjects
lcDay = ALLTRIM(STR(DAY(DATE())))
lnM = MONTH(DATE())
lcMonth = ICASE(lnM = 1,"Januari" ,lnM = 2 ,"Februari" ,lnM = 3,"Maart",;
lnM = 4,"April" ,lnM = 5 ,"Mei" ,lnM = 6,"Juni",;
lnM = 7,"Juli" ,lnM = 8 ,"Augustus" ,lnM = 9,"September",;
lnM =10,"Oktober" ,lnM =11 ,"November" ,lnM =12,"December")
lcYear = ALLTRIM(STR(YEAR(DATE())))
lcTime = CHRTRAN(TRANSFORM(TIME()), ':', '-')
lcBUName= INPUTBOX("Naam van Backup-bestand",_screen.Caption,"BU")
lcAppName = "MarlocApp"
lcUser = "MarlocUser"
lnProjects = 0
IF VARTYPE(oApp)="O" AND !ISNULL(oApp)
lcAppName = oApp.AppName
lcUser = oApp.CurrentUser
ENDIF
lcBUName= "Backup\" + lcBUName + "_" + lcAppName + "_"+ lcUser + "_" + lcDay + lcMonth + lcYear + "_" + lcTime
*close any projects to prevent DBC being not included in BU-zip file
laProjects = CloseProjects()
* here we actual zip the datamap into the backup-map
ln=azip(.T. ,lcBUName , "data\*.*" )
*restore 'environment'
=OpenProjects(laProjects)
*****************************************************************************************************
FUNCTION CloseProjects
LOCAL lnProjects, lnCnt, laProjects[1]
lnProjects = 0
lnCnt = 0
* eerst project(en) sluiten, anders wordt de dbc niet gebackupped
IF VERSION(2)<>0 && geen runtime versie
lnProjects = application.Projects.count
IF lnProjects > 0
DIMENSION laProjects[lnProjects]
STORE "" TO laProjects
FOR lnCnt = 1 TO lnProjects
laProjects[lnCnt] = application.Projects(1).name
Application.Projects(1).Close
ENDFOR
ENDIF
ENDIF
RETURN laProjects
*****************************************************************************************************
FUNCTION OpenProjects
LPARAMETERS taProjects
LOCAL lnCnt, lnProjects
lnCnt = 0
lnProjects = ALEN(taProjects,1)
* eerder gesloten projecten opnieuw opnenen
IF VERSION(2)<>0 && geen runtime versie
IF tnProjects > 0
FOR lnCnt = 1 TO lnProjects
MODIFY PROJECT (taProjects(lnCnt)) NOWAIT
ENDFOR
ENDIF
ENDIF
**************