Welcome to Personal Stock Monitor user forum. You must have an account to post to the forum. See the forum instructions page for some instructions on how to use the forum.
Subscribe to RSS Feed
Personal Stock Monitor Users Forum -> New Script: Search All Acct Tabs
Not logged in.
2011-03-19 20:13:10
1 of 8
#3168
Today, I'm posting a script I wrote for PSM that allows me to search through all of the Account Tabs in my currently open portfolio file, for some text I enter, such as ticker symbol, company name, etc. The script looks in the ticker Symbol, company Name, and Notes columns (fields) and displays each individual match it finds. The match found display provides the Account Tab name, folder/sub-folder name path, and ticker Symbol.

This script is provided for FREE in the hopes that other PSM users find it useful. You can modify it to meet your own needs, but if you do, I won't be able to help you if it becomes "broken", as I won't have your code.

This script does NOT modify any PSM data (displayed or stored data) nor does it modify your PSM portfolio file in any way. It has only been run/tested with MY recent versions of PSM (9.2.9.362 to 9.3.1.367). So, it may or may not function correctly on earlier versions of PSM. If you have an older version of PSM and find that it works okay for you, please post a message here with your version number so we all know.

These files were submitted to the DTLink programmers for their review and hopeful addition to the forum server so that a simple download link can be provided in the near future. But, it may be some time before they have the time to do this.

[3/21/2011 - For a list of updates performed on this script, please see the end of this message. I will post all changes made to the script in both Zip file and will modify the code sections below in this forum post.]

In the meantime, since the forums don't have a means for us to upload script, text or Zip files, I zipped the two files, named the Zip file "SearchAllTabs.zip", and uploaded it to a free file sharing service (4Shared). The file is small, at only 9 KB. To download the Zip file, click the following link: http://www.4shared.com/file/VG_fLLPo/SearchAllTabs.html

Look for and click the "Download Now" button, wait for their timer, click the "Download file now" text link (above the timer graphic), and save the Zip file to your PC in a location you will remember.

Unzip the file and read the "PSM Search All Tabs User Guide 1-7.rtf" file for further instructions.

Please post a message here to let me know how the script runs on your version of PSM (and maybe PSS).

If you have comments, suggestions, questions, etc. you can post a message here or send me a Private message via this forum: http://www.personalstockmonitor.com/fv-m/dgoyette

---------------------------------------------

I've also posted the script and readme files below in plain text forum message format. Here are the steps to get these files onto your PC ...

* Open TWO new plain text files/documents on your PC (Notepad works fine).

* Use the mouse pointer to select ALL of the text in the gray display text area of a message, using click and drag.

* Right-click the selected text and choose Copy.

* Paste the copied text into the new plain text document you created above.

* Save the new document as PLAIN TEXT (without formatting) ...

  - For the script file, Save it as "Search All Tabs 1-7.vbs" to a location on your PC that you will remember.

  - For the Readme text, Save it as "PSM Search All Tabs User Guide 1-7.txt" to the same location.

* READ the ReadMe file and follow the instructions for Installing the script.


Hope you all enjoy this script and find it useful.

-Don

==================================================
SCRIPT UPDATES

8/8/2011 - Ver. 1.7
* Bug Fix: Script was not looking at the ticker symbols in a Tab, which are NOT contained in Folders, before looking in the Folders themselves. Sorry 'bout that! FIXED.

3/24/2011 - Ver. 1.6
* Removed color="white" from the HTML body attribute. On MY system (WinXP SP3), without this setting, it SEEMS that PSM uses the current Windows color setting for dialog box backgrounds. Please let me know if it does NOT work this way on YOUR system.

3/21/2011 - Ver. 1.5 --
* Added "min_pss_version" statement so the script will also run in Personal Stock Streamer.

Posted by: dgoyette
2011-03-19 20:15:04
2 of 8
#3169
in reply to #3168
Thank you very much!
Posted by: Yermo
2011-03-19 20:15:06
3 of 8
#3170
in reply to #3168
File: "PSM Search All Tabs User Guide 1-7.txt" file ...


Search All Tabs - ReadMe/User Guide
-----------------------------------

This is a script extension for Personal Stock Monitor (PSM) written in VBScript (Visual Basic Scripting language).  This script is provided free of charge and WITHOUT support.  You may modify this script in any way you wish to suit your specific needs.

There is no guarantee that this script will do what it says it's supposed to do; that it will do what you want it to do; or that it won't harm your computer in any way.  This script does NOT modify any PSM data nor does it modify your PSM portfolio file in any way.

By running this script, you accept FULL RESPONSIBILITY for whatever this script (or it's misuse) does to your computer and/or your Personal Stock Monitor portfolio file.

ALWAYS BACKUP YOUR PORTFOLIO DATA FILES!

This script was submitted to the programmers at DTLink Software, who created Personal Stock Monitor and Personal Stock Streamer for their review.  They do not endorse this script, but will hopefully look at it and run their own tests to insure that it does not intentionally perform any harmful actions.


Script Information
------------------
   Script Name: Search All Tabs

   Description: Allows a user to search through all account tabs for any text entered.
                This script looks in the ticker Symbol, company Name, and Notes fields.

       Version: 1.7
          Date: August 8, 2011

   Written For: Personal Stock Monitor (only tested on version 9.2.9.362 and newer)
                This script may or may not function on earlier versions of PSM.
    Written By: Don Goyette
  Contact Info: Send a private message via the PSM forums ...
                http://www.personalstockmonitor.com/fv-m/dgoyette

         NOTES:
                * When Search Type "Partial" is selected, the search text is
                  case-sensitive.

                * When Search Type "Full" is selected, the search text is NOT
                  case-sensitive.  This searches the Symbol field

                * In order to insure that the variable names in this script are unique
                  and will not interfere with other scripts, all internal, non-PSM
                  variable names are prefixed with "SAT_", which is the acronym for
                  "Search All Tabs".

                * All Global variables are prefixed with "G_SAT_".

                * All class and function names are also prefixed with "SAT_" as well.

       UPDATES: Refer to the script code for updates, additions, modifications, etc.
                that have been performed to this script.


Installing the Script
---------------------
 1) After unzipping the SearchAllTabs.zip file, determine where you want to store your
    PSM scripts and extensions and create a new folder, if you haven't already created
    a folder.  Personally, I created a folder under the "C:\Program Files\PSM" folder
    and named it "Extensions" -- the location of your PSM folder may be different.
    Thus, I have a folder named: "C:\Program Files\PSM\Extensions".  ... OR ... you
    can just store the script in PSM's main folder, without creating a new folder.

 2) Move the "Search All Tabs x-x.vbs" file to the folder determined in #1 above.
    Note: "x-x" is the current version number, ie. "1-4".

 3) In PSM, click on the Tools menu and select the "Extensions..." option.  The
    "Installed Extensions" dialog box should now be displayed.

 4) Click the "Install..." button.  The "Open" dialog box should now be displayed.

 5) Navigate to the location determined in #1 and double-click the SearchAllTabs.vbs
    file.

 6) PSM should then display a box telling you that this is an "Unsigned Extension"
    and ask if you want to install it.  Click the Yes button, as I do not have a
    digital signature to sign scripts with.

 7) PSM should then display a message box telling you the script was installed
    successfully and that PSM must be restarted for the changes to take effect.
    Click the OK button.

 8) The "Installed Extensions" dialog box should now have focus again.  Click the
    Close button.

 9) Exit PSM (File-->Exit).

10) Wait a few seconds after PSM closes, to insure that all background tasks have
    stopped as well, then re-start PSM.

11) If you look in the Edit menu, you should now see an option at the bottom of
    the menu named "Search All Tabs".


Uninstalling the Script
-----------------------
 1) In PSM, click on the Tools menu and select the "Extensions..." option.  The
    "Installed Extensions" dialog box should now be displayed.

 2) Scroll down through the list of installed extension until you see "Search All Tabs"
    and select it by clicking on it

 3) Click the "Uninstall" button.

 4) PSM should then display a box asking you if you are sure you want to uninstall
    "Search All Tabs".  Click the Yes button.

 5) PSM should then display a message box telling you the extension was uninstalled and
    that PSM must be restarted for the changes to take effect.  Click the OK button.

 6) The "Installed Extensions" dialog box should now have focus again.  Click the Close
    button.

 7) Exit PSM (File-->Exit).

 8) Wait a few seconds after PSM closes, to insure that all background tasks have
    stopped as well, then re-start PSM.

 9) If you look in the Edit menu, you should now see that the "Search All Tabs"
    option is no longer listed.


Running the Script
------------------
When you want to search through all tickers in all of the account tabs in your currently open PSM portfolio, select the "Search All Tabs" option in the Edit menu.

Using the mouse pointer, click in the "Search Text:" edit box and enter the text you want to search for.



Search Type: Full  (Searching for a Ticker Symbol)
--------------------------------------------------
When you want to locate a ticker Symbol stored inside of the Symbol, Name or Notes columns, enter the ticker symbol in the Search Text box.  You do not need to enter the correct case (uppercase / lowercase) as the script automatically uppercases your text entry AND each ticker Symbol it looks at.  Thus comparing both in uppercase looking for a match.  After entering your text, select Search Type: Full, which tells the script to look for a ticker Symbol.


Search Type: Partial  (Searching for Any Text)
----------------------------------------------
When you want to locate any text in the Symbol, Name or Notes columns, enter the Search Text text the same case you would have entered it into PSM (uppercase/lowercase).  After entering the text to be located, select Search Type: Partial, which tells the script to look for the text anywhere inside of a Symbol, Name or Notes column, in the exact case you entered.  Thus, if you entered the text "Wal-Mart" somewhere in your portfolio, you must enter the Search Text exactly as you entered it in PSM ... "Wal-Mart" (capital W and capital M).

When you're ready to run the search, click the Run button.  If you decide not to run the search, click the Close button.


Search Results
--------------
If NO matches are located, the next message box you see informs you that the "Search Function Completed", showing "Found count: 0".  Click OK and enter some different text if you want to try another search, or click the Close box to end the Search All Tabs script.

Every time the script finds a match to your search text, it will display a message box telling you where the text was found (Symbol, Name, Notes), the ticker Symbol, the Company Name, and the account tab/folder path where the text was found.

For example, if you enter Search Text "wmt" and select Search Type "Full", the script will look for a ticker Symbol with the letters "wmt" in any mix of case ("wmt", "WMT", "Wmt", "WmT", etc.).  If it finds a match, a message box will be displayed that looks like the following:

  +-----------------------------------------------------------------------------------+
  |  Search All Tabs                                                                  |
  +-----------------------------------------------------------------------------------+
  |                                                                                   |
  |  'WMT' was found in the SYMBOL of Ticker Symbol WMT (Name: Wal-Mart Stores Inc.)  |
  |  in the following location:                                                       |
  |                                                                                   |
  |    watchlist / Consumer-Based Spending / Retailers                                |
  |                                                                                   |
  |  -- Continue looking?                                                             |
  |                                  [Yes]    [No]                                    |
  |                                                                                   |
  +-----------------------------------------------------------------------------------+

This tells you that the text you were looking for was found in the Symbol column of Ticker Symbol "WMT", in the "watchlist" Account Tab, in the "Retailers" sub-folder of the "Consumer-Based Spending" folder.  Where "SYMBOL" is displayed, this value will be either of the following: SYMBOL, NAME or NOTES.

If you want to continue looking for other matches, click the Yes button.  If not, click the No button.

If you click the No button, the script will display a message box telling you the search function was ended by user request.  Click OK to close the message box.

If you click the Yes button, the script will continue looking for matches to the text you entered.  As it finds them, it will display the found message box as described above for each match it finds.

When the search function finds no further matches, a message box is displayed letting you know the search function is done and displays the number of matches it found.  Click OK to close the message box.

You may now enter different search text, select a different Search Type and perform another search, or click the Close button to end the Search All Tabs script.

=====================================================================================

If you have suggestions or if an error occurs, please use the Contact Info above to contact me.  I hope you find this PSM script extension useful.

Posted by: dgoyette
\n\n\n[/code]");
2011-03-19 20:16:36
4 of 8
#3171
in reply to #3168
File: "Search All Tabs 1-7.vbs" ...


<pss_extension name="Search All Tabs" version="1.7" min_pss_version="9.0">Searches all account tabs for user-entered text in the Symbol, Name and Notes fields.

<author name="Don Goyette">
  <![CDATA[
'   **************************************************************************
'
'       Script Name: Search All Tabs
'
'       Description: Allows a user to search through all account tabs for
'                    any text entered.  This script looks in the ticker
'                    Symbol, company Name, and Notes fields.
'
'           Version: 1.7
'
'              Date: August 8, 2011
'
'       Written For: Personal Stock Monitor (only tested on version 9.2.9.362
'                    and newer).  This script may or may not function on
'                    earlier versions of PSM.
'
'        Written By: Don Goyette
'
'      Contact Info: Send a private message via the PSM message forums ...
'                      http://www.personalstockmonitor.com/fv-m/dgoyette
'
'             NOTES:
'                    * When Search Type "Partial" is selected, the search text
'                      is case-sensitive.
'
'                    * When Search Type "Full" is selected, the search text is
'                      NOT case-sensitive.  This searches the Symbol field
'
'                    * In order to insure that the variable names in this
'                      script are unique and will not interfere with other
'                      scripts, all internal, non-PSM variable names are
'                      prefixed with "SAT_", which is the acronym for
'                      "Search All Tabs".
'
'                    * All Global variables are prefixed with "G_SAT_".
'
'                    * All class and function names are also prefixed with
'                      "SAT_" as well.
'
'           UPDATES:
'                    Mar 19, 2011 (Version 1.4)  Bug Fix
'                      When No was clicked to answer the 'Continue?'
'                      question, the script did not stop.
'
'                    Mar 21, 2011 (Version 1.5)  Addition
'                      Added min_pss_version statement so the script will run
'                      in Personal Stock Streamer.
'
'                    Mar 24, 2011 (Version 1.6)  Change
'                      Removed color="white" from the HTML body attribute.
'                      On MY system (WinXP SP3), without this setting, it
'                      SEEMS that PSM uses the current Windows color setting
'                      for dialog box backgrounds.
'
'                    Aug 8, 2011 (Version 1.7)  Bug Fix
'                      Script was not looking at the ticker symbols in a Tab,
'                      which are NOT contained in Folders, before looking in
'                      the Folders themselves.
'
'   **************************************************************************
  ]]>
</author>


'   HTML text for the mini-browser window form to be displayed later ...
    <resource name="SAT_EntryFormResource">
      <![CDATA[
        <body>
          <form name="SAT_EntryForm" method="post" target="x">
            <table width="100%" cellspacing="0" cellpadding="2" border="0">

              <tr>
                <td align="center"><br />  Search Text:  
                  <input  type="text"  size="25"  name=SAT_Form_searchtext  value="{Search Text}"/>
                  <br /> 
                </td>
              </tr>

              <tr>
                <td align="center"> Search Type:  
                  <input type="radio" name="SAT_Form_searchtype" value="Full" checked="checked" /> Full    
                  <input type="radio" name="SAT_Form_searchtype" value="Partial" /> Partial 
                                   
                </td>
              </tr>

              <tr>
                <td align="left">
                  <br />         <b>Full:</b> 
                    Your entry must fully match the field contents.
                  <br />  
                  <br />    <b>Partial:</b> 
                    Your entry may be located anywhere in:
                  <br />           
                             Symbol, Name or Notes.
                  <br /> 
                </td>
              </tr>

              <tr>
                <td align="center">
                  <input type="submit" value="Run" />     
                  <input type="submit" value="Close" />
                </td>
              </tr>

            </table>
          </form>
        </body>
      ]]>
    </resource>


<script language="VBScript">

<![CDATA[

  Class SAT_FormHandlerClass


'-----------------------------------------------------------------------------
  Public Function OnMenuItemSelected ( id )
'   Triggered when a PSM menu item is selected.
'-----------------------------------------------------------------------------
'   If the menu id is not OURS, exit the script (don't execute our code) ...
    If (id <> G_SAT_MyForm) Then
      Exit Function
    Else
      G_SAT_MyScriptName = "Search All Tabs"  ' Define our global script-name text
    End If

'   Define variables used in this function ...
    Dim SAT_SearchText

'   Clear the global variables ...
    G_SAT_TabName = ""
    G_SAT_SearchType = ""
    G_SAT_SearchText = ""
    G_SAT_EndScript = 0
    G_SAT_wndBrowser = ""
    G_SAT_FormText = ""
    G_SAT_WindowText = ""
    G_SAT_FolderArrayCounter = 0
    G_SAT_CallLevel = ""
    Erase G_SAT_FolderArray

'   Build and display a PSM mini-browser window to get the search
'   Text and Type information from the user ...

'   Create a PSM mini-browser window ...
    Set SAT_wndManager = Application.GetObject("WindowManager")
    Set G_SAT_wndBrowser = SAT_wndManager.CreateBrowserWindow(300, 225, me)

'   Get the pre-defined HTML form text (defined above) ...
    G_SAT_FormText = Script.GetResource("SAT_EntryFormResource")

'   Set the HTML form text default values ...
    SAT_ProcessForm False

'   Move the finalized HTML text into the PSM mini-browser window ...
    G_SAT_wndBrowser.SetHTML(G_SAT_WindowText)
    G_SAT_wndBrowser.Title = G_SAT_MyScriptName

'   Set return value to indicate the menu selection was processed ...
    OnMenuItemSelected = True

  End Function  ' OnMenuItemSelected



'-----------------------------------------------------------------------------
  Public Function OnFormSubmitted ( Form )
'   Triggered when the form is submitted (Run or Close button clicked).
'-----------------------------------------------------------------------------
'   Define variables used in this function ...
    Dim SAT_SearchText

    If (Form.Value("submit") = "Run") Then  ' The Run button was clicked ...
'     Check the search Text and Type entered by the user ...
      SAT_SearchText = CStr(Form.Value("SAT_Form_searchtext"))

      If SAT_SearchText = "" Then  ' No search Text was entered ...
        MsgBox "Please enter some text to search for.", vbOKOnly, G_SAT_MyScriptName
        Exit Function
      Else  ' Check the search Type ...
        G_SAT_SearchType = CStr(Form.Value("SAT_Form_searchtype"))
        If G_SAT_SearchType > "" Then
'         If a Full search Type was selected, UpperCase the SAT_SearchText.
'         Otherwise, leave it in the user-entered case ...
          If G_SAT_SearchType = "Full" Then
            G_SAT_SearchText = UCase(SAT_SearchText)
          Else
            G_SAT_SearchText = SAT_SearchText
          End If

'         Process the form ...
          SAT_ProcessForm True
          G_SAT_wndBrowser.SetHTML(G_SAT_WindowText)

        Else  ' A search Type was not selected ...
          MsgBox "Please select a Search Type.", vbOKOnly, G_SAT_MyScriptName
          Exit Function
        End If

      End If

    Else  ' The Close button was clicked, release the form window ...
      Set G_SAT_wndBrowser = Nothing
    End If

'   Set return value to indicate the form was submitted ...
    OnFormSubmitted = True

  End Function  ' OnFormSubmitted



'-----------------------------------------------------------------------------
  Public Function SAT_ProcessForm ( Process )
'   Handles processing of the form.
'-----------------------------------------------------------------------------
'   Define variables used in this function ...
    Dim SAT_FoundText

'   Set the mini-browser window text to the form text ...
    G_SAT_WindowText = G_SAT_FormText

'   Process is either True or False (True=Process, False=Set default values)
    If Process Then
'     Clear the local variables ...
      G_SAT_RtnCode = 0
      SAT_FoundText = ""
      G_SAT_FoundCount = 0

'     Perform the search and display the results ...
      SAT_PerformTheSearch

      If G_SAT_RtnCode > 0 Then
        If G_SAT_EndScript = 1 Then
          MsgBox "Search function ended by user request.", vbOKOnly, G_SAT_MyScriptName
        Else
          MsgBox "Search function ended due to an error.", vbOKOnly, G_SAT_MyScriptName
        End If
      Else
        MsgBox "Search Function Completed." & VBCrLf & VBCrLf _
              & "Found count: " & G_SAT_FoundCount, vbOKOnly, G_SAT_MyScriptName
      End If

'     Fill in the form text ...
      G_SAT_WindowText = Replace(G_SAT_WindowText, "{Search Text}", CStr(G_SAT_SearchText))

    Else
'     Define the default form values to display ...
      G_SAT_WindowText = Replace(G_SAT_WindowText, "{Search Text}", CStr(G_SAT_SearchText))
    End If

  End Function  ' SAT_ProcessForm



'-----------------------------------------------------------------------------
  Public Function SAT_PerformTheSearch ( )
'   Main search function.  Reading account tabs and folders starts here.
'-----------------------------------------------------------------------------
'   Define variables used in this function ...
    Dim SAT_Document
    Dim SAT_AllTabs
    Dim SAT_Tab
    Dim SAT_Ticker
    Dim SAT_FolderCounter
    Dim SAT_TabCounter
    Dim SAT_Tickers

'   Get the active document (Portfolio filename <FileName>.stkx) ...
    Set SAT_Document = Application.ActiveDocument

'   Get the portfolios (tabs)  collection ...
    Set SAT_AllTabs = SAT_Document.Portfolios

'   Look through all TABS in the currently open file ...
    SAT_TabCounter = 1

    For Each SAT_Tab in SAT_AllTabs
      G_SAT_TabName = CStr(SAT_Tab.Name)
'     MsgBox "Tab: " & G_SAT_TabName & " contains " & SAT_Tab.Folders.Count & " folders.", vbOKOnly, G_SAT_MyScriptName
      G_SAT_FolderArrayCounter = 1
      SAT_FolderCounter = 1

'     ----------------------------------------------------------------------
'     Look through all TICKERS in this Tab that are NOT in a Folder ...
      Set SAT_Tickers = SAT_AllTabs.Item(SAT_TabCounter).Tickers

      G_SAT_FolderArray(G_SAT_FolderArrayCounter) = CStr(G_SAT_TabName)
      G_SAT_EndScript = 0
      G_SAT_CallLevel = "T"  ' Ticker level

'     Perform the ticker search ...
      SAT_SearchTickers SAT_Tickers

'     Check for continue or end ...
      If G_SAT_EndScript = 1 Then
        G_SAT_RtnCode = 1
'       MsgBox "Function: SAT_PerformTheSearch -- Ending tickers not in a folder.", vbOKOnly, G_SAT_MyScriptName
        Exit Function
      End If

      SAT_FolderCounter = SAT_FolderCounter + 1

'     ----------------------------------------------------------------------
'     Look through all FOLDERS in this Tab ...
      For Each Folder in SAT_Tab.Folders
        G_SAT_FolderArray(G_SAT_FolderArrayCounter) = CStr(Folder.Name)

'       Look through all TICKERS in this folder and it's sub-folders ...
        G_SAT_EndScript = 0
        Set SAT_Tickers = Folder.Tickers
        G_SAT_CallLevel = "F"  ' Folder level

'       Perform the folder loop ...
        SAT_RecurseFolder Folder, SAT_Tickers

'       Check for continue or end ...
        If G_SAT_EndScript = 1 Then
          G_SAT_RtnCode = 1
'          MsgBox "Function: SAT_PerformTheSearch -- Ending folders in a tab.", vbOKOnly, G_SAT_MyScriptName
          Exit Function
        End If

        SAT_FolderCounter = SAT_FolderCounter + 1
      Next  ' Folder

      SAT_TabCounter = SAT_TabCounter + 1
    Next  ' SAT_Tab

    G_SAT_CallLevel = ""
    G_SAT_RtnCode = 0
  End Function  ' SAT_PerformTheSearch



'-----------------------------------------------------------------------------
  Public Function SAT_RecurseFolder ( Folder, SAT_Tickers )
'   Searches in each ticker of all sub-folders inside a folder.
'-----------------------------------------------------------------------------
'   Process this folder and all sub-folders ...
    Dim SAT_Folders
    Dim SAT_FolderIndex

'   Perform the ticker-by-ticker search ...
    SAT_SearchTickers SAT_Tickers

'   Check for continue or end ...
    If G_SAT_EndScript = 1 Then
      G_SAT_RtnCode = 1
'     MsgBox "Ending function: SAT_RecurseFolder.", vbOKOnly, G_SAT_MyScriptName
      Exit Function
    End If

'   Recursively loop through any SUBfolders and their tickers & sub-folders...
    Set SAT_Folders = Folder.Folders

    For SAT_FolderIndex = 1 To SAT_Folders.Count
      G_SAT_FolderArrayCounter = G_SAT_FolderArrayCounter + 1
      G_SAT_FolderArray(G_SAT_FolderArrayCounter) = CStr(SAT_Folders.Item(SAT_FolderIndex).Name)
      Set SAT_Tickers = SAT_Folders.Item(SAT_FolderIndex).Tickers

      SAT_RecurseFolder SAT_Folders.Item(SAT_FolderIndex), SAT_Tickers

      G_SAT_FolderArrayCounter = G_SAT_FolderArrayCounter - 1
    Next

    G_SAT_RtnCode = 0
  End Function  ' SAT_RecurseFolder



'-----------------------------------------------------------------------------
  Public Function SAT_SearchTickers ( SAT_Tickers )
'   Search through individual tickers.
'-----------------------------------------------------------------------------
    Dim SAT_CountIndex
    Dim SAT_Ticker
    Dim SAT_TickerIndex
    Dim SAT_WholePath
    Dim SAT_FoundIn

'   Look through all tickers for the user-specified text ...
    For SAT_TickerIndex = 1 To SAT_Tickers.Count
      Set SAT_Ticker = SAT_Tickers.Item(SAT_TickerIndex)
      SAT_FoundIn = ""

      If G_SAT_SearchType = "Partial" Then
'       This section will check for the user-specified text ANYWHERE inside the
'       ticker Symbol, Name or Notes, regardless of it's position or text case ...
        If  ( InStr(1, SAT_Ticker.GetProperty("Symbol"), G_SAT_SearchText, 1) ) Then
          SAT_FoundIn = "SYMBOL"
        ElseIf ( InStr(1, SAT_Ticker.GetProperty("Name"), G_SAT_SearchText, 1) ) Then
          SAT_FoundIn = "NAME"
        ElseIf ( InStr(1, SAT_Ticker.GetProperty("Notes"), G_SAT_SearchText, 1) ) Then
          SAT_FoundIn = "NOTES"
        End If

      ElseIf G_SAT_SearchType = "Full" Then
'       This section will check for the user-specified text as a full match
'       against the ticker Symbol, Name and Notes ...
        If  ( UCase(SAT_Ticker.GetProperty("Symbol")) = G_SAT_SearchText ) Then
          SAT_FoundIn = "SYMBOL"
        ElseIf ( UCase(SAT_Ticker.GetProperty("Name")) = G_SAT_SearchText ) Then
          SAT_FoundIn = "NAME"
        ElseIf ( UCase(SAT_Ticker.GetProperty("Notes")) = G_SAT_SearchText ) Then
          SAT_FoundIn = "NOTES"
        End If

      End If  ' G_SAT_SearchType

      SAT_WholePath = G_SAT_TabName

      If SAT_FoundIn > "" Then
        If G_SAT_CallLevel = "F" Then  ' Folder level ..
          For SAT_CountIndex = 1 To G_SAT_FolderArrayCounter
            SAT_WholePath = SAT_WholePath & " / " & G_SAT_FolderArray(SAT_CountIndex)
          Next
        End If

        G_SAT_FoundCount = G_SAT_FoundCount + 1

        SAT_Ans = MsgBox ("'" & G_SAT_SearchText & "' was found in the " & SAT_FoundIn _
          & " of Ticker Symbol " & SAT_Ticker.GetProperty("Symbol") _
          & " (Name: " & SAT_Ticker.GetProperty("Name") & ")" & VBCrLf _
          & " in the following location:" & VBCrLf & VBCrLf _
          & "    " & SAT_WholePath & "    " & VBCrLf & VBCrLf _
          & "-- Continue looking?", vbYesNo, G_SAT_MyScriptName)

        If SAT_Ans = vbNo Then  ' The No button was clicked)
          G_SAT_EndScript = 1
' *!*!*!
'       ElseIf SAT_Ans = vbCancel Then
'       Code will be added here when/if the PSM scripting function allows a script to
'       change the currently selected account tab.  This new code will allow you to
'       click a button not currently displayed in the MsgBox and have PSM go to the
'       location where it found a match.
'
'         & "-- Continue looking? (N=Exit, Cancel=Go to tab)", vbYesNoCancel, G_SAT_MyScriptName)
'       SAT_MenuManager.SelectItem(<CStr(<AccountTabName>)>)
' *!*!*!
        End If

      End If  ' SAT_FoundIn > ""


'     Check for continue or end loop ...
      If G_SAT_EndScript = 1 Then  ' User clicked No (don't continue)
'       MsgBox "Function: SAT_SearchTickers -- Ending SAT_TickerIndex loop.", vbOKOnly, G_SAT_MyScriptName
        Exit For  ' Exit the For...Next loop
      End If

    Next  ' SAT_TickerIndex


'     Check for continue or end search ...
    If G_SAT_EndScript = 1 Then  ' User clicked No (don't continue)
'     MsgBox "Ending function: SAT_SearchTickers.", vbOKOnly, G_SAT_MyScriptName
      Exit Function
    End If

    G_SAT_RtnCode = 0
  End Function  ' SAT_SearchTickers



'-----------------------------------------------------------------------------
' Define our Global variables ...
'-----------------------------------------------------------------------------
' MsgBox "Define Global variables", vbOKOnly, G_SAT_MyScriptName
  Dim G_SAT_MyForm
  Dim G_SAT_MyScriptName
  Dim G_SAT_SearchText
  Dim G_SAT_EndScript
  Dim G_SAT_wndBrowser
  Dim G_SAT_FormText
  Dim G_SAT_WindowText
  Dim G_SAT_FoundCount
  Dim G_SAT_RtnCode
  Dim G_SAT_CallLevel  ' T=Ticker, F=Folder


' The FolderArray is used for each individual element in a complete path.
' The counter is used to determine how many folders deep the path is.
  Dim G_SAT_TabName
  Dim G_SAT_FolderArray(255)
  Dim G_SAT_FolderArrayCounter
  Dim G_SAT_SearchType

End Class  ' SAT_FormHandlerClass



'-----------------------------------------------------------------------------
' Initialization ...
'
'   When PSM is run, the following code is executed thus adding the defined
'   menu entry.
'-----------------------------------------------------------------------------
  
' Get the Event & Menu Manager objects ...
  Set SAT_EventManager = Application.GetObject("EventManager")
  Set SAT_MenuManager = Application.GetObject("MenuManager")

' Create a new FormHandler object ...
  Set SAT_FormHandler = new SAT_FormHandlerClass

' Add a sub-menu item to the Edit top-level menu ...
  If (Not SAT_MenuManager Is Nothing) Then
    Set SAT_MainMenu = SAT_MenuManager.MainMenu
    SAT_nEditMenu = SAT_MainMenu.Find("Edit")

'   Create the Edit top-level menu if it doesn't exist ...
    If (SAT_nEditMenu = -1) Then
      SAT_nHelpMenu = SAT_MainMenu.Find("Help")
      Set SAT_EditMenu = SAT_MainMenu.InsertMenu(SAT_nHelpMenu, "Edit")
    Else
      Set SAT_EditMenu = SAT_MainMenu.GetSubMenu(SAT_nEditMenu)
    End If

'   Actually create the sub-menu item ...
    If (Not SAT_EditMenu Is Nothing) Then
      SAT_EditMenu.InsertSeparator SAT_EditMenu.ItemCount  ' Insert a separator line
      SAT_FormHandler.G_SAT_MyForm = SAT_EditMenu.InsertItem(SAT_EditMenu.ItemCount, "&Search All Tabs")
    End If
  End If

' Register our event handlers ...
  If (Not SAT_EventManager Is Nothing) Then
    SAT_EventManager.RegisterHandlerMethod SAT_FormHandler, "OnMenuItemSelected"
  Else
'   Could not get EventManager object.
  End If



]]>
</script>
</pss_extension>

Posted by: dgoyette
2011-03-19 20:17:41
5 of 8
#3172
in reply to #3169
You're welcome Yermo. I hope other users find it useful.

-Don
Posted by: dgoyette
2011-03-21 17:09:18
6 of 8
#3177
in reply to #3168
Added a parameter today that will allow this script to be run in Personal Stock Streamer as well as Personal Stock Monitor.
Posted by: dgoyette
2011-03-24 17:45:43
7 of 8
#3192
in reply to #3168
3/24/2011 - Ver. 1.6

Removed color="white" from the HTML body attribute. On MY system (WinXP SP3), without this setting, it SEEMS that PSM uses the current Windows color setting for dialog box backgrounds.

Please let me know if it does NOT work this way on YOUR system.
Posted by: dgoyette
2011-08-08 19:46:06
8 of 8
#3406
in reply to #3168
Aug 8, 2011 - Version 1.7 ( Bug Fix )

The script was not looking at the ticker symbols in a Tab, which are NOT contained in Folders, before looking in the Folders themselves.

Sorry!
Posted by: dgoyette