[Date Prev][Date Next][Subject Prev][Subject Next][ Date Index][ Subject Index]

Global Subroutines I



Here's the first instalment of a series of articles on the global
subroutines found in XY4.DLG.

The global subroutines were written to assist us in writing
dialog boxes and dialog box routines. Our intention was to
provide us with reusable code that we could run simply by calling
it rather than having to repeat the code in our other routines.
They consist of status checkers and changers, string
manipulators, etc.

Why should you care? If you run Xy4 with the menu/dialog system
loaded, or if you want to isolate the globals into a stand-alone
resource file, you can use them in your XPL programming. In a
sense, they become shorthand -- almost like function calls -- for
complicated routines.

The general way to use these global routines is to (1) put input,
if any, into a Save/Get (usually 40 to 45 as needed); (2) issue a
JM function call followed by the routine's name in parentheses --
like JM (LeftString); and
(3) manipulate the output, if any. Output is usually in S/G 40-45.

In the following account, the global subroutine name is in parentheses.
 Although they're not case-sensitive, I have maintained case as it appears in
XY4.DLG. The numbers (40, 41, etc.) refer to Save/Gets in the routine.

(IniSaveGets) purpose: to initialize (set to null) a range of
numbered Save/Gets. Handy for clearing memory or for making sure
other operations won't fail to identify existing S/Gs input:
  40=number of the first Save/Get to initialize
  41=number of the last Save/Get to initialize output: Your
Save/Gets are initialized (if they didn't exist) or emptied out
(if they did) example:
  ≪SV40,995≫≪SV41,1005≫JM (IniSaveGets) result:
   S/Gs 995 to 1005 are now initialized.

(SetIO0) ["set eye-oh zero"] purpose: temporarily sets Doc Info
default to zero use: for preventing Doc Info information from
being appended to a file you create input: none output: IO
default set to zero note: saves existing default to a S/G; run
(RestoreIO) to get existing state back

(RestoreIO) purpose: to reset Doc Info default to what it was
before you made it zero

(SetNW3)
(SetNW0)
(RestoreNW) purpose: to temporarily set the New Window default
and restore it later notes: used in pairs, with RestoreNW the second part
  NW3 automatically opens and closes windows; NW0 prevents
automatic opening and closing of windows; see documentation use:
for controlling what happens to text windows when you are
opening, storing, creating, aborting files, etc.

(SetDT1)
(SetDT9)
(SetDT12)
(SetDT20)
(SetDT0)
(RestoreDT) purpose: for temporarily setting display type before
opening or creating a file

(SetER11) purpose: to initialize the $er error number report
buffer reason: XyWrite has no other way to zero out the number of
the most recent error use: for trapping a particular error number
in an XPL routine notes: As you develop XPL, force the error you
want to trap. On the command line, type VA/NV $ER to get the
error number. Then JM to (SetER11) and try one of these:
  ≪if(≪er≫)&(≪va$er≫==xx)≫
  ≪if≪va$er≫==xx≫ where xx is the error number you were
looking for. (I don't recall without looking, but the number in
the xx positon may have to be surrounded by quotes).

(SetEP0)
(RestoreEP) purpose: to temporarily disable all error prompts,
run a routine, and restore the original state

(SetReturn) purpose: to put carriage returns into S/Gs input:
none output: S/G 78=one CR; S/G 79=two CRs

(SetTab) purpose: to put a tab character into a S/G input: none
output: S/G 67=one tab character

(SetSpace) purpose: to put a space character into a S/G input:
none output: S/G 1880=one space

(GrabPath) purpose: to parse path info out of path+filename
input: S/G 40=drive+path+filename in valid format (e.g.
C:\XY4\MYFILE.TXT) output:
  S/G 40=path (e.g. C:\XY4\
  S/G 41=filename (e.g. MYFILE.TXT)

All for now. Next: GrabExt, LeftString, RightString, and other
goodies.

Tim Baehr