Init Method
Class: tsifcombo
Expand/Collapse source code of procedure Init Source Code
*-- (c) Microsoft Corporation 1995

LOCAL lcRowSource, ;
      lnPosFrom, ;
      lcAlias, ;
      lcTagName, ;
      lcControlSource

*-- The primary purpose of the code in this event method is
*-- to parse the RowSource property for an alias name and a tag
*-- name.

lcControlSource = THIS.ControlSource
lcRowSource = this.RowSource
lnPosFrom = ATC("FROM", lcRowSource)

*-- Get everything after the "FROM" clause
lcAlias = ALLT(SUBSTR(lcRowSource, lnPosFrom + 4))
*-- Filter out other clauses after "FROM"
lcAlias = TRIM(LEFT(lcAlias, AT(" ", lcAlias)))
IF "," $ lcAlias
  *-- We have more than 1 alias
  lcAlias = LEFT(lcAlias, LEN(lcAlias) - 1)
ENDIF

*-- We'll need the alias again later, so we save it
*-- to a custom property
this.cAlias = lcAlias

*-- Get a tag name
*-- If the cTag property is not empty, then the user has specified
*-- a tag for us to use for the table order.
IF !EMPTY(this.cTag)
  lcTagName = ALLTRIM(this.cTag)
ELSE
  *-- Get everything after the SELECT clause
  lcTagName = ALLT(SUBSTR(lcRowSource, AT(" ", lcRowSource)))
  *-- Filter out all other clauses
  lcTagName = ALLT(LEFT(lcTagName, AT(" ", lcTagName)))
  IF "," $ lcTagName
    *-- We have more than 1 field
    lcTagName = LEFT(lcTagName, LEN(lcTagName) - 1)
  ENDIF
ENDIF

*-- Exclude the table alias, if any
IF "." $ lcTagName
  lcTagName = SUBSTR(lcTagName, AT(".", lcTagName) + 1)
ENDIF

*-- Save the field name for later use in the
*-- KeyPress event method
this.cField = lcAlias + "." + lcTagName

*-- Limit tag name to 10 characters
lcTagName = LEFT(lcTagName, 10)

*-- Save the tag name for later
*-- use in the KeyPress event method
IF EMPTY(this.cTag)
  this.cTag = lcTagName
ENDIF


*-- SET('PROCEDURE') should include Utility.prg
IF !IsTag(lcTagName, lcAlias)
  WAIT WINDOW NOWAIT TAGNOTFOUND_LOC + CHR(13) + lcTagName
ENDIF

*- restore rowsource, to force combo box to be filled.
this.RowSource = lcRowSource
THIS.ControlSource = lcControlSource