File Finder

Originele schrijvers mogen hier hun eigen code Public Domain maken.

File Finder

Berichtdoor anthonio » ma mei 21, 2007 1:00 am

Code: Selecteer alles
'A program to quickly find all your files
'Written by Anthonio
'Copyright Andy Software

'Draw the main window
'---------------------------------------------------------------------------------
global doExit, begintime, totalfiles, filecounter, foldercounter, c

nomainwin

WindowWidth = 740
WindowHeight = 440

UpperLeftX=int((DisplayWidth-WindowWidth)/2)
UpperLeftY=int((DisplayHeight-WindowHeight)/2)

ForegroundColor$ = "white"
TextboxColor$ = "blue"
ListboxColor$ = "blue"

dim info$(1, 1)
dim info2$(1, 1)
dim files$(10000)

loadbmp "searchfile", "searchfile.bmp"
loadbmp "help", "help.bmp"

textbox #main.input, 30, 140, 165, 20
graphicbox #main.g, 0, 0, 740, 440
listbox #main.listbox, files$(), [Listbox], 220, 25, 500, 377

open "File Finder" for window_nf as #main
print #main, "trapclose Quit"

#main.input, "!setfocus"
#main.g, "when leftButtonDown [Input]"

#main.g, "down"
#main.g, "fill 0 0 140"

#main.g, "drawbmp searchfile 30 15"
#main.g, "drawbmp help 130 13"

#main.g, "up; goto 42 92; down"
#main.g, "backcolor 0 0 140"
#main.g, "size 3"
#main.g, "color white"
#main.g, "\search"
#main.g, "up; goto 145 92; down"
#main.g, "\Help"

#main.g, "up; goto 15 100; down"
#main.g, "box 205 170"

#main.g, "up; goto 30 125; down"
#main.g, "\Search string:"

#main.g, "up; goto 15 180; down"
#main.g, "box 205 330"

#main.g, "up; goto 30 205; down"
#main.g, "\Folders:"

#main.g, "up; goto 30 230; down"
#main.g, "\Files:"

#main.g, "up; goto 30 255; down"
#main.g, "\Speed (files/sec):"

#main.g, "up; goto 30 280; down"
#main.g, "\Files found:"

#main.g, "up; goto 30 305; down"
#main.g, "\Elapsed time:"

#main.g, "up; goto 15 340; down"
#main.g, "box 205 400"
#main.g, "up; goto 30 365; down"
#main.g, "\File Finder V2.0"
#main.g, "up; goto 30 385; down"
#main.g, "\Copyright ©Andy Software"

#main.g, "flush"

wait

'Sub for quiting the program without an error
'---------------------------------------------------------------------------------
SUB Quit h$
    CLOSE #main
    END
END SUB

'Check if the user pressed a button
'---------------------------------------------------------------------------------
[Input]

if MouseX <= 96 AND MouseX >= 30 then
    if MouseY <= 77  AND MouseY >= 15 then
        goto [Search]
    end if
end if

if MouseX <= 189 AND MouseX >= 130 then
    if MouseY <= 75 AND MouseY >= 13 then
        goto [Help]
    end if
end if

wait

'Scan the computer for the given file
'---------------------------------------------------------------------------------
[Search]

#main.g, "disable"
#main.input, "!disable"
#main.listbox, "disable"
searching = 1
#main.g, "up; goto 147 205; down"
#main.g, "\0         "
#main.g, "up; goto 147 230; down"
#main.g, "\0         "
#main.g, "up; goto 147 255; down"
#main.g, "\0         "
#main.g, "up; goto 147 280; down"
#main.g, "\0         "
#main.g, "up; goto 147 305; down"
#main.g, "\00:00"

    doExit=0
    c = 1
    totalfiles = 0
    filecounter = 0
    foldercounter = 0
    begintime = TIME$("seconds")
    #main.input, "!contents? b$"
    for reset = 1 to 1000
        files$(reset) = ""
    next reset
    print #main.listbox, "reload"
IF b$ = "" THEN
notice "No file given" + chr$(13) + "No search string was given!"
#main.input, "!setfocus"
#main.g, "enable"
#main.input, "!enable"
#main.listbox, "enable"
ELSE
    print #main.listbox, "reload"
    print #main.input, "!contents?"
    path$ = find$("\", b$) 'directory, file name

if doExit=1 then wait
IF path$ = "" THEN
        print #main.input, ""
        notice "Scan done" + chr$(13) + "Search completed."
        #main.input, "!setfocus"
        #main.g, "enable"
        #main.input, "!enable"
        #main.listbox, "enable"
    END IF
END IF
WAIT

FUNCTION find$(a$, b$)

    if doExit=1 then exit function
    scan
    FILES a$, b$ + ".*", info$(
    FILES a$, info2$(
    v$ = info$(0, 2) + info$(0, 3) 'current directory
    'this part to display directory up to 3 levels deep
    a = 0

    IF VAL(info$(0, 0)) > 0 THEN
        find$ = info$(0, 2) + info$(0, 3) 'if file found return path
        totalfiles = totalfiles + 1
        #main.g, "up; goto 147 280; down"
        #main.g, "\"; totalfiles
        c = c + 1
    ELSE
        folders = VAL(info$(0,1)) 'get number of folders
        FOR i = 1 TO folders 'check each subfolder
            foldercounter = foldercounter + VAL(info$(0,1))
            #main.g, "up; goto 147 205; down"
            #main.g, "\"; foldercounter
            filecounter = filecounter + VAL(info2$(0, 0))
            #main.g, "up; goto 147 230; down"
            #main.g, "\"; filecounter
            FILES a$, b$, info$( 'get folder names, needed because arrays are global
            find$ = find$(info$(i, 0), b$) 'get result from subfolder
            IF find$ <> "" THEN
                extension$ = find$ + info$(1, 0)
                files$(c)= extension$
                print #main.listbox, "reload"
            END IF
        NEXT i 'check next subfolder
    END IF
endtime = TIME$("seconds")
totaltime = endtime - begintime
minutes = int(totaltime/60)
seconds = ((totaltime/60) - int(totaltime/60)) * 60
elapsedtime$ = RIGHT$("00" + STR$(minutes), 2) + ":" + RIGHT$("00" + STR$(seconds), 2)
#main.g, "up; goto 147 305; down"
#main.g, "\"; elapsedtime$
if totaltime = 0 then
    lol = lol + 1
else
    speed = int(filecounter / totaltime)
    #main.g, "up; goto 147 255; down"
    #main.g, "\"; speed
end if
END FUNCTION

'Open the selected file
'---------------------------------------------------------------------------------
[Listbox]
#main.listbox, "selection? selected$"
select case right$(selected$, 3)
    case "txt"
        run "notepad "; chr$(34); selected$; chr$(34)
        wait
    case "exe"
        run selected$
        wait
    case else
        RUN "explorer.exe "; chr$(34); selected$; chr$(34)
        wait
end select

'Display a help window
'---------------------------------------------------------------------------------
[Help]

notice "Help" + chr$(13) + "Typ in the file that you want to search" + chr$(13) +_
        "in the search box and press search." + chr$(13) +_
        "To open a file simple dubble click on the found file." + chr$(13) +_
        "Please note that you cannot stop the scan when searching." + chr$(13) +_
        "This is done for security reasons." + chr$(13) +_
        "-------------------------------------------------------------" + chr$(13) +_
        "        Copyright ©Andy Software - All rights reserved"
wait


de 2 pictures zitten in het zip archief, gewoon uitpakken op dezelfde plaats waar je file finder gaat runnen.
Source code mag gebruikt worden voor je eigen programma, natuurlijk mag je jezelf niet uitgeven als de maker van dit programma.
De bedoeling is het aantonen hoe je een harde schijf doorzoekt op bestanden.
Bijlagen
pictures.zip
die 2 foto's die noodzakelijk zijn voor dit programma
(12.52 KiB) 274 keer gedownload
Dual boot: Ubuntu 8.04 - WIndows XP SP2 (via VMware) - Windows Vista 32bit - Toshiba L40 - Dual Core @ 1,76GHz - 1GB RAM - 120GB HDD - VDSL Connection
Avatar gebruiker
anthonio
 
Berichten: 281
Geregistreerd: zo mei 20, 2007 9:58 pm

Berichtdoor Gordon » wo mei 23, 2007 9:37 pm

Ja!!! Hier geniet ik van.

en alles gewoon in native commando's.....

Gordon.
Avatar gebruiker
Gordon
Site Admin
 
Berichten: 684
Geregistreerd: zo mei 22, 2005 12:50 am

Berichtdoor anthonio » wo mei 23, 2007 10:17 pm

leuk om dit te horen :D
waarom moeilijk doen als makkelijk ook gaat.
Dual boot: Ubuntu 8.04 - WIndows XP SP2 (via VMware) - Windows Vista 32bit - Toshiba L40 - Dual Core @ 1,76GHz - 1GB RAM - 120GB HDD - VDSL Connection
Avatar gebruiker
anthonio
 
Berichten: 281
Geregistreerd: zo mei 20, 2007 9:58 pm


Keer terug naar Public Domain stukjes

Wie is er online

Gebruikers op dit forum: Geen geregistreerde gebruikers. en 1 gast

cron