$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
Width = 200
Height = 15
ForeColor = clBlue
visible = 0
END CREATE
CAPTION = "Cut and paste files"
Width = 500
Height = 260
Center
END CREATE
SUB openF(sender AS QMENUITEM)
bar.visible = 0
st = sender.tag
form.repaint
SELECT CASE st
CASE 3
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
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
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
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 ..."
stockF
END SELECT
END SUB
SUB stockF
form.cursor = crHourGlass
MemF.CopyFrom(NFile,sz )
MemF.Position = 0
NFile.Position = 0
fstring$ = MemF.ReadStr(sz)
NFile.CLOSE
cutF
END SUB
SUB cutF
IF menuFloppy.checked THEN
szcut=1457664
ELSE
szcut=VAL(editSize.text)
END IF
filext$=file$-RIGHT$(file$,4)
IF sz <= szcut THEN
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
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
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)
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
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
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
SUB Vide
f$=""
MemF.CLOSE
filext$=""
file$=""
fcut=0
sizecut=0
END SUB
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
SUB quit
form.CLOSE
application.terminate
END SUB
SUB floppySize
menuFloppy.checked = 1
szcut=1457664
label1.CAPTION = STR$(szcut)
END SUB
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
|
|