MT Count Folders : Source

Name:MT Count Folders
Event Class:XUVJ
Event ID:cntF
Resource:AEVTXUVJcntF

Source

--- This source is written in HyperTalk for CompileIt!

global theAEEvent:R,theReply:R, handerRefCon:LongInt
global myactSize:longInt, myFcre:OSType, myFtype:OStype
global tgModTime:LongInt, mySize:LongInt,myType:OSType
global mybaseTime:longInt, mykwdSize:LongInt, myTgType:OSType
global myCaseFlg:boolType, creListLen:LongInt

codeResource "osax"

pascal function CountFiles:I theAEEvent:R, theReply:R, handerRefCon:L

  put AESizeOfParam(theAEEvent@,keyDirectObject,myType,mySize) into err
  if err <> 0 then
    return err
  end if

  put NewPtrClear(540) into myWorkPtr

  put myWorkPtr into myFssPtr
  put myWorkPtr + 70 into myOSPtr
  put myWorkPtr + 78 into myOSDescPtr
  put myWorkPtr + 86 into myTimePtr
  put myWorkPtr + 102 into myPbPtr
  put myWorkPtr + 210 into kwdPtr
  put myWorkPtr + 280 into digTempPtr
  put myWorkPtr + 284 into myNmPtr


  if myType = "TEXT" then

    if mySize > 255 then
      DisposPtr myWorkPtr
      return -1708
    end if

    put myNmPtr+1 into aPtr
    put AEGetParamPtr(theAEEvent@,keyDirectObject,"TEXT",typeCode,aPtr,mySize,myactSize) into err
    if err <> 0 then
      DisPosPtr myWorkPtr
      return err
    end if

    put NumToChar(mySize) into myNmPtr@.charType
    put myNmPtr@.Str255Type into myFname
    put FSMakeFSSpec(0, 0, myFname, myFssPtr@) into err
    if err <> 0 then
      DisPosPtr myWorkPtr
      return err
    end if

  else

    put AEGetParamPtr(theAEEvent@,keyDirectObject,typeFSS,typeCode,myFssPtr,70,myactSize) into err

    if err <> 0 then
      DisPosPtr myWorkPtr
      return err
    end if

  end if

  -----

  put false into fAttrCkFlg
  put AEGetParamDesc(theAEEvent@,"atbt","reco",myOSDescPtr@) into err
  if err = 0 then
    put true into fAttrCkFlg

    put AEGetKeyDesc(myOSDescPtr@,"pvis","bool",myOSPtr@) into err
    if err = 0 then
      if myOSPtr@.dataHandle@@.booleanType then
        put 1 into pvisFlg
      else
        put -1 into pvisFlg
      end if
      put AEDisposeDesc(myOSPtr@) into err
    else
      put 0 into pvisFlg
    end if
    ----
    put AEGetKeyDesc(myOSDescPtr@,"aslk","bool",myOSPtr@) into err
    if err = 0 then
      if myOSPtr@.dataHandle@@.booleanType then
        put 1 into aslkFlg
      else
        put -1 into aslkFlg
      end if
      put AEDisposeDesc(myOSPtr@) into err
    else
      put 0 into aslkFlg
    end if
    ---
    put AEGetKeyDesc(myOSDescPtr@,"alis","bool",myOSPtr@) into err
    if err = 0 then
      if myOSPtr@.dataHandle@@.booleanType then
        put 1 into alisFlg
      else
        put -1 into alisFlg
      end if
      put AEDisposeDesc(myOSPtr@) into err
    else
      put 0 into alisFlg
    end if
    ---
    put AEGetKeyDesc(myOSDescPtr@,"pspd","bool",myOSPtr@) into err
    if err = 0 then
      if myOSPtr@.dataHandle@@.booleanType then
        put 1 into pspdFlg
      else
        put -1 into pspdFlg
      end if
      put AEDisposeDesc(myOSPtr@) into err
    else
      put 0 into pspdFlg
    end if
    ---
    put AEGetKeyDesc(myOSDescPtr@,"cIcn","bool",myOSPtr@) into err
    if err = 0 then
      if myOSPtr@.dataHandle@@.booleanType then
        put 1 into cIcnFlg
      else
        put -1 into cIcnFlg
      end if
      put AEDisposeDesc(myOSPtr@) into err
    else
      put 0 into cIcnFlg
    end if
    ---
    put AEGetKeyDesc(myOSDescPtr@,"bzyy","bool",myOSPtr@) into err
    if err = 0 then
      if myOSPtr@.dataHandle@@.booleanType then
        put 1 into bzyyFlg
      else
        put -1 into bzyyFlg
      end if
      put AEDisposeDesc(myOSPtr@) into err
    else
      put 0 into bzyyFlg
    end if
    ---
    put AEDisposeDesc(myOSDescPtr@) into err
  end if

  ----

  put 0 into creListLen
  put 0 into crIndex

  put AEGetParamDesc(theAEEvent@,"ctyp","list",myOSDescPtr@) into err
  if err = 0 then

    put AECountItems(myOSDescPtr@,creListLen) into err

    if err = 0 then
      if creListLen > 0 then
        put NewHandle(creListLen*4) into myCreHandle

        repeat with x = 1 to creListLen

          put AEGetNthPtr(myOSDescPtr@,x,typeType,myKey,TypeCode,myOSPtr,4,myactSize) into err
          if err = 0 then
            add 1 to crIndex
            put myOSPtr@.OStype into myCreHandle@@.OStype[crIndex]
          end if

        end repeat

        if crIndex = 0 then
          DisposHandle myCreHandle
        end if

      end if
    end if

    put AEDisposeDesc(myOSDescPtr@) into err

  end if

  ---
  put 0 into creListLen
  put 0 into typIndex

  put AEGetParamDesc(theAEEvent@,"ftyp","list",myOSDescPtr@) into err
  if err = 0 then

    put AECountItems(myOSDescPtr@,creListLen) into err

    if err = 0 then
      if creListLen > 0 then
        put NewHandle(creListLen*4) into myTypHandle

        repeat with x = 1 to creListLen

          put AEGetNthPtr(myOSDescPtr@,x,typeType,myKey,TypeCode,myOSPtr,4,myactSize) into err
          if err = 0 then
            add 1 to typIndex
            put myOSPtr@.OStype into myTypHandle@@.OStype[typIndex]
          end if

        end repeat

        if typIndex = 0 then
          DisposHandle myTypHandle
        end if

      end if
    end if

    put AEDisposeDesc(myOSDescPtr@) into err

  end if


  ---

  put AEGetParamPtr(theAEEvent@,"xday",typeShortInteger,typeCode,myOSPtr,2,myactSize) into err
  if err = 0 then

    put myOSPtr@.Integertype into myDays
    if myDays > 0 then
      put Time - (60*60*24*myDays) into myTimePtr@.longIntType[1]
    end if

  else

    put AEGetParamPtr(theAEEvent@,"aftr","ldt ",typeCode,myOSPtr,8,myactSize) into err
    if err = 0 then
      put myOSPtr@.longIntType[2] into myTimePtr@.longIntType[1]
    end if

    put AEGetParamPtr(theAEEvent@,"bfre","ldt ",typeCode,myOSPtr,8,myactSize) into err
    if err = 0 then
      put myOSPtr@.longIntType[2] into myTimePtr@.longIntType[2]
    end if

  end if
  ----
  put AEGetParamPtr(theAEEvent@,"yday",typeShortInteger,typeCode,myOSPtr,2,myactSize) into err
  if err = 0 then

    put myOSPtr@.Integertype into myDays
    if myDays > 0 then
      put Time - (60*60*24*myDays) into myTimePtr@.longIntType[3]
    end if

  else

    put AEGetParamPtr(theAEEvent@,"cafr","ldt ",typeCode,myOSPtr,8,myactSize) into err
    if err = 0 then
      put myOSPtr@.longIntType[2] into myTimePtr@.longIntType[3]
    end if

    put AEGetParamPtr(theAEEvent@,"cbfr","ldt ",typeCode,myOSPtr,8,myactSize) into err
    if err = 0 then
      put myOSPtr@.longIntType[2] into myTimePtr@.longIntType[4]
    end if

  end if
  ----

  put AEGetParamDesc(theAEEvent@,"fnam",typeChar,myOSPtr@) into err

  if err <> 0 then
    put false into myNameFlg
  else
    put true into myNameFlg
    put myOSPtr@.dataHandle into myNameHandle
    put GetHandleSize(myNameHandle) into tgFnmSize
    if tgFnmSize > 0 then

      if tgFnmSize = 1 and CharToNum(myNameHandle@@.charType[0]) = 58 then
        put false into myNameFlg
      else if tgFnmSize = 2 ¬
      and CharToNum(myNameHandle@@.charType[0]) = 58 ¬
      and CharToNum(myNameHandle@@.charType[1]) = 58 then
        put false into myNameFlg
      else
        put HandToHand(myNameHandle) into err
        if err <> 0 then
          put AEDisposeDesc(myOSPtr@) into xErr
          DisposPtr myWorkPtr
          if crIndex > 0 then DisposHandle myCreHandle
          if typIndex > 0 then DisposHandle myTypHandle
          return err
        end if
      end if
    else
      put false into myNameFlg
    end if

    put AEDisposeDesc(myOSPtr@) into err

  end if
  ----
  put AEGetParamDesc(theAEEvent@,"kwod",typeChar,myOSPtr@) into err
  if err <> 0 then
    put false into myKeyFlg
  else
    put true into myKeyFlg
    put myOSPtr@.dataHandle into myStrHandle
    put GetHandleSize(myStrHandle) into tgSize
    if tgSize > 0 then
      put HandToHand(myStrHandle) into err
      if err <> 0 then
        put AEDisposeDesc(myOSPtr@) into xErr
        DisposPtr myWorkPtr
        if myNameFlg then DisposHandle myNameHandle
        if crIndex > 0 then DisposHandle myCreHandle
        if typIndex > 0 then DisposHandle myTypHandle
        return err
      end if
    else
      put false into myKeyFlg
    end if

    put AEDisposeDesc(myOSPtr@) into err

  end if
  ----
  put AEGetParamDesc(theAEEvent@,"csen","bool",myOSPtr@) into err
  if err = 0 then
    put myOSPtr@.dataHandle@@.booleanType into myCaseFlg
    put AEDisposeDesc(myOSPtr@) into err
  else
    put false into myCaseFlg
  end if
  ----
  put AEGetParamPtr(theAEEvent@,"sizl","long",typeCode,myOSPtr,4,myactSize) into err
  if err = 0 then
    put myOSPtr@.LongIntType into myLimitSize
  else
    put 0 into myLimitSize
  end if
  -----
  put AEGetParamPtr(theAEEvent@,"dig ",typeBoolean,typeCode,myOSPtr,1,myactSize) into err
  if err = 0 then
    put myOSPtr@.booleanType into myDigFlg
  else
    put false into myDigFlg
  end if

  if myDigFlg then put true into myAsFlFlg
  ----

  if crIndex > 0 then MoveHHi myCreHandle
  if typIndex > 0 then MoveHHi myTypHandle
  if myNameFlg then MoveHHi myNameHandle
  if myKeyFlg then MoveHHi myStrHandle




  put myFssPtr@.IntegerType into myPbPtr@.ioVRefNum
  put myFssPtr+2 into aPtr
  put aPtr@.LongIntType into myPbPtr@.ioDrDirID
  put myFssPtr+6 into myPbPtr@.ioNamePtr

  put PBGetCatInfo(myPbPtr) into err

  put myPbPtr + 30 into aPtr
  if not BitTst(aPtr,3) then
    put myPbPtr+40 into aPtr
    if BitTst(aPtr,0) then
      put myResolver(myFssPtr) into myFssPtr
      put myFssPtr@.IntegerType into myPbPtr@.ioVRefNum
      put myFssPtr+2 into aPtr
      put aPtr@.LongIntType into myPbPtr@.ioDrDirID
      put myFssPtr+6 into myPbPtr@.ioNamePtr

      put PBGetCatInfo(myPbPtr) into err
      put myPbPtr + 30 into aPtr
      if not BitTst(aPtr,3) then
        DisposPtr myWorkPtr
        if myNameFlg then DisposHandle myNameHandle
        if myKeyFlg then DisposHandle myStrHandle
        if crIndex > 0 then DisposHandle myCreHandle
        if typIndex > 0 then DisposHandle myTypHandle
        return -1708
      end if
    else
      DisposPtr myWorkPtr
      if myNameFlg then DisposHandle myNameHandle
      if myKeyFlg then DisposHandle myStrHandle
      if crIndex > 0 then DisposHandle myCreHandle
      if typIndex > 0 then DisposHandle myTypHandle
      return -1708
    end if
  end if

  ----


  put 1 into DigIndex

  put NewHandle(4) into digHandle
  put myPbPtr@.ioDrDirID into digHandle@@.longIntType[1]

  put 0 into Merr
  put 0 into myFndCounter

  if myNameFlg then
    put tgFnmSize-1 into NmLstPos
    put charToNum(myNameHandle@@.charType[0]) into tgA
    put (tgA = 58) into stMatchFlg
    put charToNum(myNameHandle@@.charType[NmLstPos]) into tgB
    put (tgB = 58) into edMatchFlg
  end if

  repeat

    put 1 into dirIndex
    put digHandle@@.longIntType[DigIndex] into DirToScan


    repeat
      put "" into myNmPtr@.Str255type
      put myNmPtr into myPbPtr@.ioNamePtr
      put dirIndex into myPbPtr@.ioFDirIndex
      put DirToScan into myPbPtr@.ioDrDirID

      put PBGetCatInfo(myPbPtr) into err
      if err <> 0 then
        exit repeat
      end if

      put myPbPtr + 30 into aPtr

      if BitTst(aPtr,3) then

        if myDigFlg then
          put myPbPtr@.ioDrDirID into digTempPtr@.longIntType
          put PtrAndHand(digTempPtr,digHandle,4) into Merr
          if Merr <> 0 then
            put false into myDigFlg
            exit repeat
          end if
        end if

      else

        if fAttrCkFlg then

          put myPbPtr+40 into aPtr

          --- visible
          if pvisFlg <> 0 then
            if BitTst(aPtr,1) <> (pvisFlg=-1) then
              add 1 to dirIndex
              next repeat
            end if
          end if

          --- alias
          if alisFlg <> 0 then
            if BitTst(aPtr,0) <> (alisFlg=1) then
              add 1 to dirIndex
              next repeat
            end if
          end if

          --- stationary
          if pspdFlg <> 0 then
            if BitTst(aPtr,4) <> (pspdFlg=1) then
              add 1 to dirIndex
              next repeat
            end if
          end if

          --- Custom Icon
          if cIcnFlg <> 0 then
            if BitTst(aPtr,5) <> (cIcnFlg=1) then
              add 1 to dirIndex
              next repeat
            end if
          end if


          put myPbPtr + 30 into aPtr

          --- Busy
          if bzyyFlg <> 0 then
            if BitTst(aPtr,0) <> (bzyyFlg=1) then
              add 1 to dirIndex
              next repeat
            end if
          end if

          --- locked
          if aslkFlg <> 0 then
            if BitTst(aPtr,7) <> (aslkFlg=1) then
              add 1 to dirIndex
              next repeat
            end if
          end if


        end if

        --- Size Check
        if myLimitSize <> 0 then
          if myLimitSize > 0 then
            if myPbPtr@.ioFlLgLen > myLimitSize then
              add 1 to dirIndex
              next repeat
            end if
          else
            if (myPbPtr@.ioFlLgLen + myLimitSize) < 0 then
              add 1 to dirIndex
              next repeat
            end if
          end if
        end if


        put myPbPtr + 32 into aPtr

        --- Type Check
        if typIndex > 0 then
          put aPtr@.fdType.OStype into tgType
          put false into typTestFlg

          repeat with cXX = 1 to typIndex
            if myTypHandle@@.OStype[cXX] = tgType then
              put true into typTestFlg
              exit repeat
            end if
          end repeat

          if not typTestFlg then
            add 1 to dirIndex
            next repeat
          end if
        end if


        --- Creator Check
        if crIndex > 0 then
          put aPtr@.fdCreator.OStype into tgCre
          put false into creTextFlg

          repeat with cXX = 1 to crIndex
            if myCreHandle@@.OStype[cXX] = tgCre then
              put true into creTextFlg
              exit repeat
            end if
          end repeat

          if not creTextFlg then
            add 1 to dirIndex
            next repeat
          end if
        end if



        ---- Modified date Check
        if myTimePtr@.longIntType[1] <> 0 ¬
        or myTimePtr@.longIntType[2] <> 0 then

          put true into daysBfrFlg
          put true into daysAfrFlg

          put myPbPtr + 76 into aPtr
          put aPtr@.LongintType into tgModTime

          if myTimePtr@.longIntType[2] <> 0 then
            put myTimePtr@.longIntType[2] into mybaseTime

            put myTimePtr+4 into myBfreTimePtr

            --- before
            if BitTst(aPtr,0) = BitTst(myBfreTimePtr,0) then
              put (tgModTime <= mybaseTime) into daysBfrFlg
            else
              put BitTst(myBfreTimePtr,0) into daysBfrFlg
            end if

          end if

          if myTimePtr@.longIntType[1] <> 0 then
            put myTimePtr@.longIntType[1] into mybaseTime

            --- after
            if BitTst(aPtr,0) = BitTst(myTimePtr,0) then
              put (tgModTime >= mybaseTime) into daysAfrFlg
            else
              put BitTst(aPtr,0) into daysAfrFlg
            end if

          end if

          if not (daysAfrFlg and daysBfrFlg) then
            add 1 to dirIndex
            next repeat
          end if

        end if

        ---- create date Check
        if myTimePtr@.longIntType[3] <> 0 ¬
        or myTimePtr@.longIntType[4] <> 0 then

          put true into daysBfrFlg
          put true into daysAfrFlg

          put myPbPtr + 72 into aPtr
          put aPtr@.LongintType into tgModTime

          if myTimePtr@.longIntType[4] <> 0 then
            put myTimePtr@.longIntType[4] into mybaseTime

            put myTimePtr+12 into myBfreTimePtr

            --- before
            if BitTst(aPtr,0) = BitTst(myBfreTimePtr,0) then
              put (tgModTime <= mybaseTime) into daysBfrFlg
            else
              put BitTst(myBfreTimePtr,0) into daysBfrFlg
            end if

          end if

          if myTimePtr@.longIntType[3] <> 0 then
            put myTimePtr@.longIntType[3] into mybaseTime
            put myTimePtr+8 into myBfreTimePtr

            --- after
            if BitTst(aPtr,0) = BitTst(myBfreTimePtr,0) then
              put (tgModTime >= mybaseTime) into daysAfrFlg
            else
              put BitTst(aPtr,0) into daysAfrFlg
            end if

          end if

          if not (daysAfrFlg and daysBfrFlg) then
            add 1 to dirIndex
            next repeat
          end if

        end if


        ---- Contains Name

        if myNameFlg then

          put false into fnamMatchFlg
          put CharToNum(myNmPtr@.charType) into tgLen

          if (not stMatchFlg) and (not edMatchFlg) then
            -- normal search

            if tgFnmSize > tgLen then
              add 1 to dirIndex
              next repeat
            end if

            put tgLen-NmLstPos into kCkLen

            repeat with y = 1 to kCkLen

              put charToNum(myNmPtr@.charType[y]) into tgB

              if EqualCase(tgA,tgB) then

                put 0 into checkSum

                repeat with z = 1 to NmLstPos
                  put charToNum(myNmPtr@.charType[y+z]) into tgZ1
                  put charToNum(myNameHandle@@.charType[z]) into tgZ2
                  if not EqualCase(tgZ1,tgZ2) then
                    put 1 into checkSum
                    exit repeat
                  end if
                end repeat

                put (checkSum=0) into fnamMatchFlg

              end if

              if fnamMatchFlg then exit repeat

            end repeat

          else if stMatchFlg and (not edMatchFlg) then
            -- start with

            if NmLstPos > tgLen then
              add 1 to dirIndex
              next repeat
            end if

            put 0 into checkSum
            repeat with z = 1 to NmLstPos
              put charToNum(myNmPtr@.charType[z]) into tgZ1
              put charToNum(myNameHandle@@.charType[z]) into tgZ2
              if not EqualCase(tgZ1,tgZ2) then
                put 1 into checkSum
                exit repeat
              end if
            end repeat

            put (checkSum=0) into fnamMatchFlg

          else if (not stMatchFlg) and edMatchFlg then
            --- end with


            if NmLstPos > tgLen then
              add 1 to dirIndex
              next repeat
            end if

            put tgFnmSize-2 into scLen
            put (tgLen-scLen) into kCkLen
            put 0 into checkSum

            repeat with z = 0 to scLen
              put charToNum(myNmPtr@.charType[kCkLen+z]) into tgZ1
              put charToNum(myNameHandle@@.charType[z]) into tgZ2
              if not EqualCase(tgZ1,tgZ2) then
                put 1 into checkSum
                exit repeat
              end if
            end repeat

            put (checkSum=0) into fnamMatchFlg


          else if stMatchFlg and edMatchFlg then
            -- complete match

            put tgFnmSize-2 into scLen

            if scLen <> tgLen then
              add 1 to dirIndex
              next repeat
            end if

            put 0 into checkSum
            repeat with z = 1 to scLen
              put charToNum(myNmPtr@.charType[z]) into tgZ1
              put charToNum(myNameHandle@@.charType[z]) into tgZ2
              if not EqualCase(tgZ1,tgZ2) then
                put 1 into checkSum
                exit repeat
              end if
            end repeat

            put (checkSum=0) into fnamMatchFlg

          end if

          if not fnamMatchFlg then
            add 1 to dirIndex
            next repeat
          end if

        end if


        put false into doneFSS

        --- Keyword check

        if myKeyFlg then

          put myPbPtr@.ioVRefNum into tgVref
          put myNmPtr@.Str255Type into myFname
          put FSMakeFSSpec(tgVref,DirToScan,myFname,kwdPtr@) into Merr
          if Merr <> 0 then
            put false into myDigFlg
            exit repeat
          end if
          put true into doneFSS

          if not keywordChecker(kwdPtr,myStrHandle) then
            add 1 to dirIndex
            next repeat
          end if

        end if

        add 1 to myFndCounter

      end if

      add 1 to dirIndex

    end repeat

    if not myDigFlg then exit repeat

    if GetHandleSize(digHandle) = DigIndex*4 then exit repeat

    add 1 to DigIndex

  end repeat

  DisposHandle digHandle


  if crIndex > 0 then DisposHandle myCreHandle
  if typIndex > 0 then DisposHandle myTypHandle
  if myNameFlg then DisposHandle myNameHandle
  if myKeyFlg then DisposHandle myStrHandle

  if Merr <> 0 then
    put Merr into err
  else
    if theReply@.descriptorType <> typeNull then
      put AEPutParamPtr(theReply@, keyDirectObject,"long",@myFndCounter,4) into err
    end if
  end if

  DisposPtr myWorkPtr

  return err

end CountFiles


function myResolver myFssptr
  put FSpOpenResFile(myFssPtr@,fsCurPerm) into myRefNum
  if myRefNum < 0 then
    return myFssptr
  end if

  put Get1IndResource("alis",1) into myAliasHandle
  if myAliasHandle = nil then
    CloseResFile myRefNum
    return myFssptr
  end if

  put ResolveAlias(nil,myAliasHandle,myFssPtr@,wasChanged) into err
  CloseResFile myRefNum

  return myFssptr
end myResolver



function keywordChecker kwdPtr,myStrHandle

  put GetHandleSize(myStrHandle) into mykwdSize

  put FSpOpenDF(kwdPtr@,fsCurPerm,myRefNum) into err
  if err <> 0 then
    return false
  end if

  put GetEOF(myRefNum,myBufSize) into err
  put MaxMem(dum) into myMemSize
  put (myMemSize-32768) into readBufSize

  if myBufSize < readBufSize then
    put myBufSize into readBufSize
    put false into continueFlg
  else
    put readBufSize into myBufSize
    put true into continueFlg
  end if

  put NewHandle(readBufSize) into myTemHandle
  put MemError() into err
  if err <> 0 then
    put FSClose(myRefNum) into ferr
    return false
  end if


  put 0 into baseOff
  put false into myFlg
  put mykwdSize-1 into kwdScLen
  put charToNum(myStrHandle@@.charType[0]) into tgA

  repeat

    put SetFPos(myRefNum,1,baseOff) into ferr

    HLock myTemHandle
    put FSRead(myRefNum,myBufSize,myTemHandle@) into err
    Hunlock myTemHandle

    if err = -39 then
      put false into continueFlg
    end if

    put myBufSize-mykwdSize into scLen

    repeat with x = 0 to scLen

      put charToNum(myTemHandle@@.charType[x]) into tgB


      if EqualCase(tgA,tgB) then

        put 0 into checkSum

        repeat with y = kwdScLen down to 1

          put CharToNum(myTemHandle@@.charType[x+y]) into tgZ1
          put CharToNum(myStrHandle@@.charType[y]) into tgZ2

          if EqualCase(tgZ1,tgZ2) then next repeat

          put 1 into checkSum
          exit repeat

        end repeat

        put (checksum=0) into myFlg

        if myFlg then exit repeat

      end if


    end repeat

    if myFlg then exit repeat

    if not continueFlg then exit repeat

    put baseOff+myBufSize-mykwdSize+1 into baseOff

  end repeat


  put FSClose(myRefNum) into err

  DisposHandle myTemHandle

  return myFlg

end keywordChecker


function EqualCase tgA, tgB
  if not myCaseFlg then
    if tgA >= 65 and tgA <= 90 then put tgA+32 into tgA
    if tgB >= 65 and tgB <= 90 then put tgB+32 into tgB
  end if

  return (tgA = tgB)
end EqualCase

Tanaka's osax : Source
Tanaka's osax