(include "sci.sh")
(use "DIcon")
(script 944)



(procedure (localproc_0151 param1 param2)
    (var temp0, temp1, temp2[13], temp15, temp16, temp17)
    (asm
        lsp     param2
        ldi     1
        sub     
        sat     temp0
code_015a:lst     temp0
        ldi     0
        gt?     
        bnt     code_01ba
        ldi     0
        sat     temp15
        ldi     0
        sat     temp1
code_0169:lst     temp1
        lat     temp0
        lt?     
        bnt     code_01b1
        lsp     param1
        lst     temp1
        ldi     13
        mul     
        add     
        sat     temp16
        push    
        ldi     13
        add     
        sat     temp17
        pushi   2
        push    
        lst     temp16
        callk   StrCmp, 4
        push    
        ldi     0
        lt?     
        bnt     code_01ad
        pushi   2
        lea     @temp2
        push    
        lst     temp16
        callk   StrCpy, 4
        pushi   2
        lst     temp16
        lst     temp17
        callk   StrCpy, 4
        pushi   2
        lst     temp17
        lea     @temp2
        push    
        callk   StrCpy, 4
        ldi     1
        sat     temp15
code_01ad:+at     temp1
        jmp     code_0169
code_01b1:lat     temp15
        not     
        bt      code_01ba
        -at     temp0
        jmp     code_015a
code_01ba:ret     
    )
)


(class FileSelector of DSelector
    (properties
        type 6
        state 0
        nsTop 0
        nsLeft 0
        nsBottom 0
        nsRight 0
        key 0
        said 0
        value 0
        font 0
        x 13
        y 6
        text 0
        cursor 0
        topString 0
        mark 0
        mask 0
        nFiles 0
        sort 1
    )

    (method (dispose)
        (if (text)
            Memory(3 text)
            = text 0
        )
        (super:dispose())
    )


    (method (setSize)
        (var temp0[4])
        (super:setSize())
        TextSize(@temp0[0] "M" font)
        = nsRight (+ nsLeft (* temp0[3] x))
    )


    (method (readFiles theMask)
        (var temp0[7], temp7, theText, temp9)
        (if (> paramTotal 0)
            = mask theMask
        )
        (if (not mask)
            = mask "*.*"
        )
        (if (text)
            Memory(3 text)
            = text 0
        )
        = nFiles 0
        = temp9 FileIO(8 mask @temp0 0)
        (while (temp9)
            ++nFiles
            = temp9 FileIO(9 @temp0)
        )
        (if (not = text Memory(2 (+ (* nFiles 13) 1)))
            return 0
        )
        = temp7 0
        = theText text
        = temp9 FileIO(8 mask @temp0 0)
        (while (temp9 and (< temp7 nFiles))
            StrCpy(theText @temp0)
            ++temp7
            = theText (+ theText 13)
            = temp9 FileIO(9 @temp0)
        )
        StrAt(text * nFiles 13 0)
        (if (sort)
            localproc_0151(text nFiles)
        )
        return 1
    )

)
