home *** CD-ROM | disk | FTP | other *** search
- /*
- * global-search - if given an argument, goto the top of the first buffer,
- * and start searching for that argument. If not given an argument, then use
- * the default search string, and start searching from where we are.
- * *
- * When a search fails in any buffer, we go to the next buffer and try again.
- * when we run out of buffers, we return with an error.
- */
- option failat 2
-
- signal on error
- 'rexx-buffer-list' buflist
- if buflist.0 = 0 then signal error /* No buflist is an error! */
-
- if arg(1, 'Exists') then do /* start from the top */
- search = arg(1)
- if search = "" then search = '\^M'
- 'switch-to-buffer "'buflist.1.name'"'
- 'beginning-of-buffer'
- buf = 1
- end
- else do /* Start where we are now */
- do buf = 1 to buflist.0 while pos("CURRENT", buflist.buf.status) = 0
- nop
- end
- if buf > buflist.0 then signal error /* No current buffer!?!? */
- search = '\^M'
- end
-
- signal off error
-
- /* Ready to start searching */
- do forever
- 'search-forward "'search'"'
- if rc = 0 then exit 0
- buf = buf + 1
- if buf > buflist.0 then signal error
- 'switch-to-buffer "'buflist.buf.name'"'
- if rc ~= 0 then signal error
- 'beginning-of-buffer'
- if rc ~= 0 then signal error
- end
- /*
- * This loop should never exit. However, if it does, the fall through
- * to error will do the righ thing.
- */
-
- /*
- * trivial error handler for the setup phase. We do it on the spot in the
- * search phase.
- */
- error: exit 1
-