========================================================================
Forwarded here by Ap van den Berg (2:280/801.348)
========================================================================
Area: WP-CRAFT
Date: 10 Nov 96 11:35:01 Public
From: Ap van den Berg
To: all
Subject: Some WP6 DOS macro's
========================================================================
Hi,
As I still prefer the DOS version of WP instead of windows (less
keys, and no mouse) I have written some macros for handling document
archiving and retrieving. I post them as you might benefit of them,
and ofcourse I'm interested in getting feedback. Certainly there are
more people writing WP macro's.
The first one retrieves a document into the current document with
less keys than doing it through WP itself
//ALTG.WPM
//Retrieves the file entered into the current document at cursor location
DLGCREATE(Result;"Insert file")
DLGCONTROL(CtrlLabel!;;"Insert file into current document (F5
filemanager")
DLGCONTROL(CtrlFileName!;FileName;"~Bestand: ";StyInitial!;;;50)
DLGEND
IF(Result = -1)
QUIT
ELSE
FileRetrieve(FileName)
ENDIF
QUIT
The second one is somewhat more complicated. One of the strong
points of WP6 are the quick directories. Unfortunately that is only
for retrieving files. For saving files directly to the quick
directories I have written this macro. It saves the file in the
quick directory of your choice, the filename is the same as the
quick directory name, the extension is an increasing number from 001
to 999. N.B. some routines of McComb's WP6 PowerTools book are used.
// Geautomatiseerd opslaan van bestanden via directlijst, met volgnummer
// januari 1996 eerste versie
// januari 1996 versnelde manier van opslag door tellen bestanden
// the variable Directory will have the full path for the listed directory.
If
// you've described the directories with their exact names, you can leave out
// the TYPE(32)
DISPLAY(On!)
// Routines from Powertools of Gordon McComb
USE("POWER")
// Do nothing when the document is empty
IF(?DocBlank = 1)
DLGCREATE(Result;"Archief Macro";DlgNoCancel!)
DLGCONTROL(CtrlLabel!;;"Document is leeg, macro wordt afgebroken.")
DLGEND
QUIT
ENDIF
//Check for existing document, then just save
IF(?Name"")
Save
QUIT
ENDIF
//Make document summary before we save
IF(?DocSummaryDescriptiveName="")
DLGINPUT(On!)
DocSummaryDlg
PressKey(-8166)
PressKey(-8166)
DLGINPUT(Off!)
ENDIF
//Get directory from quicklist
DlgInput(On!)
FileManagerDlg
PRESSKEY(-8155) //press F6 to display quicklist
Prompt("Ga naar directory, druk op ENTER")
Pausekey(EnterKey)
Type(32) //select edit, then field #2
QuickDirectory=?Entry
While (NOT ?EditScreen)
ExitDlg
ENDWHILE
DISPLAY(Off!)
// Show the user what we're doing
DLGCREATE(Result;"Archief Macro";DlgNoOk!+DlgNoCancel!+DlgInActive!)
DLGCONTROL(CtrlLabel!;;"Document wordt opgeslagen in: " + QuickDirectory)
DLGEND
// Check the number of files in the directory choosen
// Special care for . and .. as these are counted as well
FileManagerDlg
Type(QuickDirectory)
HardReturn
NumberOfFiles = ?List -1
While (NOT ?EditScreen)
ExitDlg
ENDWHILE
//Check for more than 999 files in directory
IF(NumberOfFiles > 999)
DLGCREATE(Result;"Archief Macro";DlgNoOk!)
DLGCONTROL(CtrlLabel!;;"Maxium aantal bestanden (999) in " +
QuickDirectory + " is be
reikt.")
DLGCONTROL(CtrlLabel!;;"Selecteer een andere directory, macro wordt
afgebroken.")
DLGEND
QUIT
ENDIF
//Add leading 0's if necessary
SWITCH(StrLen(NumberOfFiles))
CASEOF 1:
FileExtension = ".00" + NumberOfFiles
CASEOF 2:
FileExtension = ".0" + NumberOfFiles
CASEOF 3:
FileExtension = "." + NumberOfFiles
ENDSWITCH
// Parse directory name for building filename
Temp1 = ParsePath(QuickDirectory;&DirectoryArray)
FORNEXT(Count;1;Temp1;1)
FileBaseName = (DirectoryArray[Count])
ENDFOR
// And now we're finally saving!
FileSave(QuickDirectory + "\" + FileBaseName + FileExtension;WordPerfect_60!)
QUIT
--- PPoint 2.02
---------------
* Origin: Ap's software hell (2:280/801.348)
|