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

Global Subroutines II



Here's the second and last installment of Global routines in
XyWrite. There are plenty of other routines, and careful study
will be rewarded. I've run out of gas (and time) for now. Many
of the other routines s are of limited usefulness or involve
complications I don't want to get into. If you have specific
questions that you think are of general interest, pass 'em along
to the group. I'll try to answer. If you have trenchant observations about the
(a) sloppiness or (b) inconsistency of the programming or coding,
and it feels good to make them, let 'em rip. But I think I've
explained all that I am able. If I've made a misstatement in the
descriptions below, I'll cheerfully amend them.

(GrabExt) purpose: isolating the extension and the filename (so
you can add your own extension, or instance) input: S/G
40=[drive][path]filename.ext output:
  S/G 40=extension
  S/G 42=filename

(AddExt) purpose: adds an extension to a filename if user hasn't
supplied one (if you want to control for stuff like that and
don't trust the user) input:
  S/G 40=[drive][path]filename[.][ext]
  S/G 41=desired extension output: S/G
40=[drive][path]filename.newext other details: If user has
supplied an extension, it is used. If user has supplied just a
[.], user is queried and new extension is applied only if user
says yes. hint: If you want to *force* an extension regarless of
user input, use
(GrabExt) and simply add the period and extension to the contents
of S/G 42

(LeftString) purpose: to parse out the leftmost n characters in a
string input:
  S/G 40=string to parse
  S/G 45=number of characters to put in left part of string
output:
  S/G 41=left portion
  S/G 42=right portion

(RightString) purpose: to parse out the rightmost n characters in
a string input:
  S/G 40=string to parse
  S/G 45=number of characters to put in right part of string
output:
  S/G 41=left portion
  S/G 42=right portion notes: Surprise! I don't know what the
heck the CU label does, precisely.
 But it looks like it repeats an operation N times, with, in this
case, N being set in S/G 45. I'll be looking into it sometime.
Also, the VA|40 gives size the same as @siz(variable). It was a
late development (during a time of some chaos) and we didn't
exploit it fully. I think it had some limitations, but I never
learned precisely what they were. Note also that
(RightString) simply subtracts the desired number from total
length and then runs (LeftString).

(lwr) purpose: to lowercase a string of letters input and output:
S/G 40

(FileOpen) purpose: to see if the file you want to work on is
already open -- prevents your routine from doing a "blind save"
(sa %) to a file that's open and then saving the open file and
overwriting your work input: S/G 40=[drive][path]filename output:
return if no problem; jump to dialog if file is open

(WinOpen) purpose: to open a new window if one is available
input: none output: new window opens, or "No more windows are
available" is reported note: if there's an [UNTITLED] and
unmodified file open on-screen, a new window is not opened

(ForceWinOpen) purpose: to force open a new window even if
there's an unmodified [UNTITLED] file on-screen input: none
output: new window opens, or "No more windows are available" is
reported

You may be able to benefit from writing your own "Global"
routines, saving them into a U2 or U1 file, and referring to them
in your programming. I hope this stuff has been at least a
little inspiring for your own work/play!

Tim Baehr
T_baehr@xxxxxxxx