name Insert command "&Insert" group "&Learning"; Property CurrentFile = 0; -- shared global without a mainline sub CheckFileOpen flag = false; file = qedit.activefile; -- we need an object to insert into if typeof(file)=qedit.typeundefined result=dialog("You must have a file open"); else CurrentFile = file; -- update shared Global variable flag = true; endif; return flag; endsub sub timestamp if CheckFileOpen() timestamp = datetime(); --result = dialog(string(timestamp)); -- debugging display timestamp = timestamp.fmtshortdatetime(); --result = dialog(timestamp); -- debug display: formatted timestamp CurrentFile.insert(timestamp); -- CurrentFile is global endif endsub on command "&Timestamp" timestamp(); endon sub signature if CheckFileOpen() sig = {"Ralph J. Smith", "Email: smithr@ourfriendlyfirm.com", "Telephone: 345-678-9012"}; -- create a list of 3 strings --result = dialog(string(sig)); CurrentFile.insert(sig); -- CurrentFile is shared global file object endif endsub on command "&Signature" -- you cannot call a command signature(); endon << Author: bgreen@robelle.com Date: Nov 5, 1999 Web: insert04.qsl Comments: 1. You will run this script from the Script Menu. 2. Save as '\c:\qslwork.insert03.qsl". 3. Click Menu | Manage Scripts, then click 'Add' and browse to your qsl file. Click OK to add it. The script should now be on your menu under the "Learning" group. 4. Look in Script Menu and click 'Learning'. You should see "Insert" as a sub-choice, with a shortcut key of 'I' (configured by the 'command "&Insert"' code added to the 'name' statement). 5. Click "Insert" or type 'I'. You should see two 2 sub-menu choices: 'Timestamp' and 'Signature'. 6. Click either one and see the results. 7. Notice the shared global Property CurrentFile. It is declared outside the scope of any sub and is therefore available to all. The keyword Property exports it to any other scripts that may load() this script. If you leave 'Property' out the script will still work, but you will have an empty mainline menu item that doesn't do anything (actually, it does 'CurrentFile=0'). 8. See insert03.qsl for date/time object and methods. See Insert02.qsl for Lists and error checking. 9. You may add other Commands to this script as you need them. To make this an autoload script, click Options | Preferences and 'Change' your script directory, then create an Autoload subfolder for this script (for example, "c:\qslwork\autoload\insert04.qsl"). 10. Each function has both a Sub block which is exported to other scripts and an On block which is limited to a single sub call. On blocks cannot be called by external scripts. >>