1 Reply Latest reply on Oct 7, 2009 8:33 AM by philmodjunk

    Script needed to only use a portion of a field

    Ringger

      Title

      Script needed to only use a portion of a field

      Post

      I need help with a script to look in a field for different types of info. Example; Product codes with hyphen “-1” only, Product codes with no hyphen, Product codes with no hyphen and if more than 1 record per product code, only show the 1st record. All of this information is coming from the same field and there is no set # of characters/digits.

        • 1. Re: Script needed to only use a portion of a field
          philmodjunk
            

          Let's say you store your search pattern in a global text field: gText.

           

          In a script

          # find all records with text pattern stored in gText

          Enter Find Mode[]

          Set FIeld [YourTable::YourTextField; "*" & YourTable::gText & "*"]

          Set error capture [on]

          Perform find[]

          Set error capture [off]

          If [ get ( foundcount ) > 0 /* at least one record found */]

            Go to record[First]

            # Isolate just the first record

            Show all records

            Omit record

            Show only omitted

          Else

            show custome dialog ["No records found..."]

          End if

           

          If the "first" such record is not the first record listed when the records are unsorted, then you'll need to include a sort step just before Go To Record, in order to make the desired record the first record in the found set.