home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
High Voltage Shareware
/
high1.zip
/
high1
/
DIR36
/
KEXX.ZIP
/
POP.KEX
< prev
next >
Wrap
Text File
|
1992-12-29
|
4KB
|
139 lines
************************************************
* POP.KEX
*
* Function: POP function for a simple KEDIT context stack
* To run: See PROGMACS.DOC
* Requires: KEDIT 5.0
* Version: 1.1 (December, 1992)
*
* Parameters:
* Name - The name of the entry on the stack to be popped
* OldLocation - "NO" says don't change the current file and location
*
* This macro POPs all stacked contexts thru named context
*
************************************************
Parse Arg Name OldLocation
Name = Upper(Name)
If OldLocation = "NO" Then Do
CurrentFile = Fileid.1()
"SOS Save"
End
If Name = "" Then Name = "DEFAULT"
Call ErrorCheck 'Editv Get StackEntries.'Name
Entries = StackEntries.Name
If \DataType(Entries, 'n') | Entries = '0' Then
Return 0
If Name \= "" Then Do
Do Until PoppedName = Name | PoppedName = "STACKEMPTY"
PoppedName = PopEntry(Name)
End
End
Else
Call PopEntry
Call ErrorCheck 'Editv Set StackEntries.'Name Entries - 1
If OldLocation = "NO" Then Do
"Kedit" CurrentFile
"SOS Restore"
End
Return Entries
************************************************
* Function to POP a single context from the stack
* Returns the name of the entry if it had been named
************************************************
PopEntry: Procedure
Parse Arg Name
* Get the size of the stack
'NoMsg Editv Get StackSize'
If \DataType(StackSize, "N") | StackSize = 0 Then
Return "STACKEMPTY"
* Get stuff for top entry
Call ErrorCheck "Editv Get StackFID."StackSize
Call ErrorCheck "Editv Get StackName."StackSize
Call ErrorCheck "Editv Get StackKeys."StackSize
Parse Var StackFID.StackSize Fid C1 C2
NameSave = StackName.StackSize
KeysToDef = StackKeys.StackSize
* Back to original file and location
Call ErrorCheck "Kedit" Fid "(New"
If Size.1() \= 0 Then Do
* The file is still in the ring
'Locate .stack'StackSize
* Note: RC = 1 would mean TOF or EOF
If RC \= 0 & RC \= 1 Then Do
"EMsg Unable to relocate the old location in this file"
"EMsg It's likely the line was deleted or the file was removed from the ring"
End
Call ErrorCheck "Cursor Screen" C1 C2
'Set Point .stack'StackSize 'Off'
End
Else 'QQuit'
Do While KeysToDef \= ""
* Redefine saved key
Parse Var KeysToDef NextKey KeysToDef
* Lowercase to circumvent a bug handling case in Editv variable tails
NextKey = Translate(NextKey, 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')
Call ErrorCheck "Editv Get StackKey."StackSize"."NextKey
Call ErrorCheck "Define" NextKey StackKey.StackSize.NextKey
* Delete entry
Call ErrorCheck "Editv Set StackKey."StackSize"."NextKey
End
* Remove stack values
Call ErrorCheck "Editv Set StackFID."StackSize
Call ErrorCheck "Editv Set StackName."StackSize
Call ErrorCheck "Editv Set StackKeys."StackSize
* Set new stack size
StackSize = StackSize - 1
Call ErrorCheck "Editv Put StackSize"
If NameSave \= Name Then Do
Call ErrorCheck 'Editv Get StackEntries.'Name
Entries = StackEntries.Name
If DataType(Entries, 'n') & Entries \= '0'
Then Call ErrorCheck 'Editv Set StackEntries.'Name Entries - 1
Else Call FatalErr 99 "Internal error in context stack."
End
Return NameSave
************************************************
* Subroutine to bail out with error message in alert box
* Note: This subroutine never returns to it's caller
************************************************
FatalErr:
Parse Arg ReturnCode ErrorMessage
'Alert' Delimit(ErrorMessage) 'Title $POP$'
Exit ReturnCode
************************************************
* Execute command and check for zero return code
* If RC is not 0, then bail out with FatalErr
************************************************
ErrorCheck:
Parse Arg CmdString
"NoMsg" CmdString
If RC \= 0 Then
Call FatalErr RC LastMsg.1()
Return