_startup = 'cmdEdit.prg' && Add path if neededcmdEdit.prg has the following code, you'll notice some hard coding stuff that it would be better if changed
* This program adds a date string as a comment in _command.prg to easily visualize * When a new day of commands started in our command window * In order to be automatically executed, it should be included in the config.fpw file as: * _startup = 'x:\foxv\prog\cmdedit.prg' #define kNewLine Chr(13) local lcCmd, lnSelect, lcUser, lcPreLine, lcInfoLine, lcPostLine, llReturn, llError, loDialog, lcSafety lnSelect = Select() llReturn = .f. llError = .f. if not File('c:\fox\_command.prg') or Version(2) = 0 && Check that the file _command exists and it is not a RunTime version return .f. endif try select 0 use x:\foxv\cmdedit lcUser = Upper(getenv('USERNAME')) if Seek(lcUser, 'cmdEdit', 'User') or Seek('*', 'cmdEdit', 'User') lcCmd = Filetostr('c:\fox\_command.prg') lcInfoLine = getLine(cmdEdit.InfoLine) if At(lcInfoLine, lcCmd) = 0 and cmdEdit.Active SaveHistory(lcCmd, lcUser) && Saves the _command content in the x:\fox\command folder lcPreLine = getLine(cmdEdit.PreLine) + kNewLine lcInfoLine = lcInfoLine + kNewLine lcPostLine = getLine(cmdEdit.PostLine) + kNewLine lcCmd = lcCmd + lcPreLine + lcInfoLine + lcPostLine lcSafety = Set("Safety") set safety off llReturn = Strtofile(lcCmd, 'c:\fox\_command.prg') > 0 set safety &lcSafety else llReturn = .T. endif endif catch loDialog = SkyDialog('*Could not update _command file', 'Errors found while running cmdEdit.prg', '', '', 'Arial;11;;255;000;000,Default', 5000, '', 117, '', '') llError = .T. finally use in Select('cmdedit') select (lnSelect) _shell = '' endtry if not llError and not llReturn loDialog = SkyDialog('*Could not update _command file', 'Failed to write changes into c:\fox\_command.prg', '', '', 'Arial;11;;255;000;000,Default', 5000, '', 117, '', '') endif return llReturn ************************************************************************************************************** function getLine(tcText) try lcText = Evaluate(tcText) catch lcText = tcText endtry lcText = Alltrim(Iif(Vartype(lcText)='C', lcText, Transform(lcText))) lcText = Iif(Left(lcText, 1)='* ', '', '*') + lcText return lcText ************************************************************************************************************** function SaveHistory(tcCommand, tcUser) local lcFolder, lcPost, lnFiles, laFiles(1) if CmdEdit.HistSize > 0 lcFolder = Addbs(Iif(Empty(CmdEdit.HistFolder), 'C:\FOX', Alltrim(CmdEdit.HistFolder))) if Directory(lcFolder, 1) lnFiles = Adir(laFiles, lcFolder + tcUser + '_command@*') if lnFiles >= CmdEdit.HistSize && Delete older files create cursor c_files (file C(30), size i, date D, time C(10)) append from array laFiles index on Dtos(date) + time tag date descending go Top Skip (CmdEdit.HistSize - 1) scan rest delete File (lcFolder + Alltrim(c_files.File)) endscan use in Select('c_files') endif lcPost = Dtos(Date()) + Strtran(time(), ':', '') Strtofile(tcCommand, Forceext(lcFolder + tcUser + '_command@' + lcPost , '.PRG')) else md (lcFolder) endif endifYou'll notice that there are two "features", one is that we use a table so each one of us can use a different "TimeStamp" for when they start, and second is that we make a copy of _command in a separate folder to keep a "History" just in case
Field Field Name Type Width Dec Index Collate Nulls Next Step 1 USER Character 5 Asc Machine No 2 PRELINE Character 80 No 3 INFOLINE Character 80 No 4 POSTLINE Character 80 No 5 HISTSIZE Integer 4 No 6 ACTIVE Logical 1 No 7 HISTFOLDER Character 64 NoNote that User is only 5 chars for that is the policy in here, you should change it and as you can see it has an index on it so we can find the record for the user, and * is the default (keep in mind I do not remember all the details!)
'Session started for ' + longdate(date()) + ' at ' + time() && Longdate is a custom functionor
'Session started for ' + longdate(date())Also, I just noticed there is a bug in SaveHistory, as I checked my folder and have 761 saved commands, so they are not getting deleted.
********************************************************************************* *Session started for Thursday, January 10, 2008 *********************************************************************************[Update]