FINDNAME
                                ========

Given a function or procedure name, FINDNAME searches the nametable for
a match.

©pjwitte 2oo2++             Use at own risk!


System requirements:
--------------------

Compatible with SMSQ/E, Qdos and compiled

Turbo: With flag% = 1 or -1 you could crash your system! But no flag or
       flag% = 0 should be ok.


Usage:
------

        type% = FINDNAME%(name$ [, flag%])

        where type% = 0 => no match found
                      1 => procedure found
                      2 => function found

              name$ = upper or lower case (complete) name to search for

              flag% = 0 => check global name table only (default if no par)
                      1 => check local name table only
                     -1 => first check local then, if not found, global nt

Note on flag: If uesd from job #0, local and global are the same, so only
a global name table scan is performed.


Examples of use:
----------------

Use in compiled program to test whether a given command is available, and
if not take an alternative course of action:

        IF NOT FINDNAME%("Q_L") THEN
           ErrMsg "This program needs Qlib_run pre-loaded!": QUIT -7
        ENDIF

or

        IF FINDNAME%("PEEK$") THEN
           text$ = PEEK$(address + 2, PEEK_W(address))
        ELSE
           text$ = PeekString$(address)
        END IF

In SMSQ/E's SBASIC daughter jobs, any global command that is named in your
program will immediadely be added to your local name table, but you can
load extensions locally that will not appear in the global name table.
FINDNAME cannot differentiate between commands that are loaded globally
and eponimous commands loaded locally. (But you could add a DUMMY
command to your toolkit and test for that instead, if need be..)

If you need to RUN such an SBASIC program multiple times in an SBASIC
daughter job you could make your life easier by:

        IF NOT FINDNAME%("BOOBY", 1): LRESPR 'win1_tks_booby_bin'
        ..
        BOOBY

This will load the booby toolkit only if it isnt already loaded, ie not
repeatedly for every time you try to RUN the program.

It is often useful in program installation scripts etc to check whether
certain toolkits are pre-loaded or whether the intallation script needs to
load them itself to enable your super-duper program to run at the end of
it. You could use FINDNAME for this, of course, but your target user many
not like to be lumbered with a toolkit s/he doesnt use and cant get rid
of. For such cases I recommend my FindKey S*BASIC routine, which does
pretty much the same as FINDNAME in BASIC, without leaving a residue. This
routine can be found at Knoware.no under Articles / FindTheKey!


Programming notes:
------------------

This software uses some of my standard library routines. These are
generalised routines and so relatively bulky. If you package more of my
commands into a single toolkit the overhead is likely to be shared and the
relative size goes down. Alternatively you could replace the library calls
with bespoke routines for a (slightly) slimmer, standalone version.


Software status
---------------

V0.03, pjw, 2004 Jul 11, bug fix. Now works in Qdos
V0.04, pjw, 2019 Apr 16, added SMSQ/E mnemonics, no functional change
V0.05, pjw, 2020 Jan 27, bug fix (and linked to correct library this time!)
V0.06, pjw, 2022 Apr 04, scan local and/or global name table

You may incorporate and use this command in your own programs provided you
acknowledge the author.

The source code is included so you can make any modifications or bug fixes
you require, or simply to see how it works.

Enjoy!

         Conditions of use and DISCLAIMER as per Knoware.no