Guidance
指路人
g.yi.org
software / rapidq / Examples / File & Directory / Cut&Paste Files / RQ_Cut&paste_Files.bas

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
' RQ_Cut&Paste_Files.bas for RapidQ
' Coded by Gérald VERDIER - BinoclaR (°-°) software
' november 2003
' email : gerald.verdier@club-internet.fr
' PURPOSE : Cut big files on floppy disks and all paste on HDD

     $INCLUDE "rapidq.inc"

     DIM Nfile AS QFILESTREAM
     DIM MemF AS QMEMORYSTREAM
     DIM SaveF AS QFILESTREAM

     DIM fstring$ AS STRING
     DIM sz AS INTEGER
     DIM f$ AS STRING
     DIM file$ AS STRING
     DIM szcut AS INTEGER

     DIM OpenDialog AS QOPENDIALOG
     DIM font AS QFONT
     font.name = "Arial"
     font.size = 11

     DECLARE SUB openF(sender AS QMENUITEM)
     DECLARE SUB Vide
     DECLARE SUB stockF
     DECLARE SUB quit
     DECLARE SUB pasteF
     DECLARE SUB cutF
     DECLARE SUB delF
     DECLARE SUB othersize
     DECLARE SUB sizeOk
     DECLARE SUB floppySize
     DECLARE SUB About
     DECLARE SUB Help
'°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°

     CREATE helpForm AS QFORM
      CAPTION = "Help"
      COLOR =&hd0d058
      font = font
      Width = 500
      Height = 260
      cursor = crHand
      borderStyle = bsToolWindow
      visible = 0
      Center
     END CREATE

     CREATE sizeForm AS QFORM
      borderStyle = bsNone
      height = 60
      width = 60
      visible = 0
      center
      CREATE okB AS QBUTTON
       CAPTION = "Ok!"
       onClick = sizeOk
       top = 30
       width = 40
       left = 12
      END CREATE
      CREATE editSize AS QEDIT
       left = 0
       width = 60
       top = 0
      END CREATE
     END CREATE

     CREATE form AS QFORM
      CREATE menu AS QMAINMENU
       CREATE menufile AS QMENUITEM
        CAPTION = "&Files"
        CREATE menucut AS QMENUITEM
         CAPTION = "&Cut"
         onclick = openF
        END CREATE
        CREATE menupaste AS QMENUITEM
         CAPTION = "&Paste"
         onclick = openF
         tag = 3
        END CREATE
        CREATE menusdelete AS QMENUITEM
         CAPTION = "&Delete old files"
         onclick = openF
         tag = 4
        END CREATE
        CREATE menuexit AS QMENUITEM
         CAPTION = "Exit"
         onclick = quit
        END CREATE
       END CREATE
       CREATE menusize AS QMENUITEM
        CAPTION = "&Size"
        CREATE menuFloppy AS QMENUITEM
         checked = 1
         CAPTION = "&Floppy = 1457664bytes"
         onclick = floppySize
        END CREATE
        CREATE menumore AS QMENUITEM
         CAPTION = "&Other size"
         onclick = otherSize
        END CREATE
       END CREATE
       CREATE menuhelp AS QMENUITEM
        CAPTION = "&Help"
        CREATE menuAbout AS QMENUITEM
         CAPTION = "&About"
         onclick = About
        END CREATE
        CREATE menuHlp AS QMENUITEM
         CAPTION = "&Help"
         onclick = Help
        END CREATE
       END CREATE
      END CREATE
      CREATE Label1 AS QLABEL
       CAPTION = "Cut files for floppy or cut with an other value (in bytes) __ then paste ..."
       Left = 5
       Top = 180
       Width = 350
       Height = 21
       Transparent = 1
      END CREATE
      CREATE bar AS QGAUGE
       Left = 150
        'Top = 180
       Width = 200
       Height = 15
       ForeColor = clBlue  ' (blue bar)
       visible = 0
      END CREATE
      CAPTION = "Cut and paste files"
      Width = 500
      Height = 260
      Center
     END CREATE
'°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
'------------------------CODE--------------------------
'°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
'------------------------OpenDialog--------------------
     SUB openF(sender AS QMENUITEM)
      bar.visible = 0
      st = sender.tag
      form.repaint
      SELECT CASE st
      CASE 3        '_.cut file (to paste)
       f$=""
       OpenDialog.Filter = "Files to paste (*.cut)|*.cut"
       OpenDialog.FilterIndex = 1
       IF OpenDialog.EXECUTE THEN
        f$ = OpenDialog.FileName
        IF RIGHT$(f$,3)="cut"  THEN
         pasteF
        END IF
       END IF
      CASE 4        '_.cut file (to delete)
       f$=""
       OpenDialog.Filter = "Files to delete (*.cut)|*.cut"
       OpenDialog.FilterIndex = 1
       IF OpenDialog.EXECUTE THEN
        f$ = OpenDialog.FileName
        IF RIGHT$(f$,3)="cut"  THEN
         delF
        END IF
       END IF
      CASE ELSE    'open a file (better under 15mo)
       f$=""
       OpenDialog.Filter = "All files(*.*)|*.*"
       OpenDialog.FilterIndex = 1
       IF OpenDialog.EXECUTE THEN
        ff$=""
        f$ = OpenDialog.FileName
        NFile.OPEN(f$, FmOpenRead)
        FOR i = LEN(f$) TO 1 STEP -1    '\
         a$ = MID$(f$,i,1)           ' \
         IF a$ = "\" THEN EXIT FOR   '  \    => get the name of file
         ff$ = ff$+a$                '  /
        NEXT                            ' /
        file$ = reverse$(ff$)       '/
        Form.CAPTION = file$
       END IF
       sz = NFile.Size
       szX = INT(sz/100)
       IF f$ = "" THEN
        Vide
       END IF
       Label1.CAPTION = f$ + " "+STR$(sz)+" bytes ... Please wait ..."    'size of the file
       stockF
      END SELECT
     END SUB
' ------------------copy file in memory------------------------
     SUB stockF
      form.cursor = crHourGlass
      MemF.CopyFrom(NFile,sz )
      MemF.Position = 0
      NFile.Position = 0
      fstring$ = MemF.ReadStr(sz)
      NFile.CLOSE
      cutF
     END SUB
' ------------------CUT file & create files _.01 _.02 _.03 ... _.cut-----
     SUB cutF
      IF menuFloppy.checked THEN
       szcut=1457664 '163E00
      ELSE
       szcut=VAL(editSize.text)
      END IF
      filext$=file$-RIGHT$(file$,4)
      IF sz <= szcut THEN            'file to small < 1457664
       SHOWMESSAGE "Copy this file on floppy"
       EXIT SUB
      END IF
      form.cursor = crHourGlass
      fcut = INT(sz/szcut)
      sizecut = sz MOD szcut
      FOR i = 1 TO fcut    'save the cutted files and create the _.cut file
       IF i=1 THEN
        Data$=Data$+ filext$+"."+STR$(i)+CHR$(9)
        saveF.OPEN(filext$+"."+STR$(i), fmCreate)
        saveF.write(MID$(fstring$,1,szcut)
        saveF.CLOSE
       ELSE
        Data$=Data$+ filext$+"."+STR$(i)+CHR$(9)
        saveF.OPEN(filext$+"."+STR$(i), fmCreate)
        saveF.write(MID$(fstring$,(i*szcut)-(szcut-1),szcut)
        saveF.CLOSE
       END IF
      NEXT i
      saveF.OPEN(filext$+"."+STR$(fcut+1), fmCreate)
      saveF.write(MID$(fstring$,(i*szcut)-(szcut-1),sizecut)
      saveF.CLOSE
      Data$=Data$+filext$+"."+STR$(fcut+1)+CHR$(9)+filext$+"."+"cut"+CHR$(9)+file$
      NFile.OPEN(filext$+"."+"cut", fmCreate)
      NFile.WriteStr(Data$,LEN(data$))
      NFile.CLOSE
      form.CAPTION = "Cut and paste files"
      form.cursor = crDefault
      form.textOut (5,40,filext$+".1"+" - "+STR$(szcut)+" bytes",&hFF00FF,-1)
      form.textOut (20,70,"_.1 to _."+STR$(i)+" files saved on your HDD",&hFF00FF,-1)
      form.textOut (5,100,filext$+"."+STR$(i)+ " - "+STR$(sizecut)+" bytes",&hFF00FF,-1)
      form.textOut (5,120,filext$+"."+"cut"+" * Open this file to paste",&h0000FF,-1)
      label1.CAPTION = STR$(i)+" files created" + " + "+filext$+"."+"cut"+" - "
      vide
     END SUB
' ------------------Paste the files--------------------------
     SUB pasteF
      DIM PasteF$() AS STRING
      label1.CAPTION = "pasting ..."
      form.cursor = crHourGlass
      c=1
      sz=0
      Form.CAPTION = f$
      NFile.OPEN(f$,fmOpenRead)
      sz=NFile.size
      NFile.Position = 0
      Fcut$=NFile.ReadStr(sz)     'read  _.cut file
      NFile.CLOSE
      FOR i = 1 TO LEN(Fcut$)
       a$=MID$(Fcut$,i,1)
       PasteF$(c)=PasteF$(c)+a$-CHR$(9)
       IF a$ = CHR$(9) THEN
        c=c+1
       END IF
      NEXT i
      form.CAPTION = pasteF$(c)+"/"+STR$(c-2)+ " files pasted"
      bar.visible = 1
      bar.Top = 180
      FOR i = 1 TO c-2     'remake cutted files - addind the files in a string
       NFile.OPEN(pastef$(i), fmOpenRead)
       sz=NFile.size
       fp$=NFile.ReadStr(sz)
       IF f$<>"" THEN
        ffp$=ffp$+LEFT$(fp$,LEN(fp$)-1)
       END IF
       bar.position = (100/(c-2))*i
       NFile.CLOSE
       form.TextOut(5,20*i,pastef$(i),&hff0000,-1)
      NEXT i
      NFile.OPEN(pasteF$(c),fmcreate)
      NFile.write(ffP$)
      NFile.CLOSE
      form.cursor = crDefault
      bar.visible = 0
      SHOWMESSAGE pasteF$(c)+" rebuilt"
      label1.CAPTION ="Ok !"
      vide
     END SUB
' ------------------Delete old files-----------------
     SUB delF
      DIM delF$() AS STRING
      label1.CAPTION = "deleting ..."
      c=1
      Form.CAPTION = f$
      NFile.OPEN(f$,fmOpenRead)
      sz=NFile.size
      NFile.Position = 0
      Fdel$=NFile.ReadStr(sz)
      NFile.CLOSE
      FOR i = 1 TO LEN(Fdel$)
       a$=MID$(Fdel$,i,1)
       delF$(c)=delF$(c)+a$-CHR$(9)
       IF a$ = CHR$(9) THEN
        c=c+1
       END IF
      NEXT i
      FOR i = 1 TO c-1
       KILL delF$(i)
      NEXT i
      form.TextOut(5,40,delF$(1),0,-1)
      form.TextOut(5,60,"to",0,-1)
      form.TextOut(5,80,delF$(c-2),0,-1)
      form.TextOut(5,100,delF$(c-1)+" ... deleted",0,-1)
      label1.CAPTION = "old files deleted ..."
      SHOWMESSAGE "Old files deleted"
      vide
     END SUB
' ------------------Reset some values----------------
     SUB Vide
      f$=""
      MemF.CLOSE
      filext$=""
      file$=""
      fcut=0
      sizecut=0
     END SUB
' ------------------Other Size-------------------------
     SUB otherSize
      sizeForm.visible = 1
      sizeForm.show
     END SUB
' ------------------
     SUB sizeOK
      label1.CAPTION = editSize.text
      szcut=VAL(editSize.text)
      IF szcut<=1457664 THEN
       SHOWMESSAGE "Please cut file > 1457664bytes"
       menuFloppy.checked = 1
       sizeForm.visible = 0
       form.show
       label1.CAPTION = "Cut files for floppy or cut with an other value (in bytes) __ then paste ..."
       EXIT SUB
      END IF
      menuFloppy.checked = 0
      sizeForm.visible = 0
      form.show
     END SUB
' ------------------EXIT-------------------------------
     SUB quit
      form.CLOSE
      application.terminate
     END SUB
' ------------------Disk Size---------------------------
     SUB floppySize
      menuFloppy.checked = 1
      szcut=1457664 '163E00
      label1.CAPTION = STR$(szcut)
     END SUB
' ------------------Menu Help---------------------------
     SUB About
      SHOWMESSAGE "_____By  Gérald VERDIER_____"+CHR$(13)+_
       "______Cut and paste files_____"+CHR$(13)+_
       "_gerald.verdier@club-internet.fr_"+CHR$(13)+_
       "_________________________"
     END SUB
' ------------------
     SUB Help
      helpForm.visible = 1
      helpForm.show

      helpForm.textOut (10,10,"This program can cut and paste all sorts of files (MP3,BMP,EXE,ZIP ...)." , &hff0000,-1)
      helpForm.textOut (10,30,"You can copy big files on floppy disks, or choice an other size of cut ...!?", &hff0000,-1)
      helpForm.textOut (10,50,"Cutted files are saved on HDD : name.01 _.02 _.03 ... name.cut .", &hff0000,-1)
      helpForm.textOut (10,70,"Generaly it's better to group .cut file on floppy with the smallest file. ", &hff0000,-1)
      helpForm.textOut (10,90,"If you cut files over 10mo that begin to be long, and you need many disks.", &hff0000,-1)
      helpForm.textOut (10,110,"This depend on your computer memory because the file is saved in first.", &hff0000,-1)
      helpForm.textOut (10,140,"      - To paste or to delete files open the .cut one.", &hff0000,-1)
      helpForm.textOut (10,160,"      - Copy this program to remake all the files ", &hff0000,-1)

      helpForm.textOut (20,200,"__________Program developped with RapidQ (William Yu)_________ ", &hff00ff,-1)

     END SUB

     Form.SHOWMODAL
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Sat 2024-4-20  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2003-11-22 05:24:31