daved
New Member
Posts: 24
|
Post by daved on Jan 29, 2022 14:35:08 GMT -5
Here is the actual full program as I am running it. Run instructions follow: 1. Start the program and deselect the .PDF, RTF, and Photo check boxes to eliminate them from the search. Only the .TXT check box is set. (You set them to any combination you like, but limiting it to .TXT makes the listbox list shorter for this test) 2. Select the Browse button and navigate to a directory that contains a file with a space in the filename. The .txt files are listed in the list box. 3. Select a file in the listbox that has a space in the filename. The full pathname appears in the Search Path: text box. 4. Click the Rename File button. A text box labeled New File Name containing the selected file appears under the Search Path text box. 5. Remove the space in the file name (Do not edit the path). Ensure that the path in the Search Path: text box matches the path in the New File Name text box. Only the file names should differ. 6. Click the Rename File button and the error appears.
Restart the program and repeat using a filename that has no spaces in the original name. The rename works.
Restart the program and repeat using a filename that has no spaces in the original name, but put a spce in the new filename. The rename works.
program follows:
nomainwin [Start] WindowWidth = 945 WindowHeight = 740 UpperLeftX=int((DisplayWidth-WindowWidth)/2) UpperLeftY=int((DisplayHeight-WindowHeight)/2)
ListboxColor$ = "white" TextboxColor$ = "white"
statictext #main.txt, "Search Path:", 30, 20, 76, 20 textbox #main.path, 115, 20, 655, 25
listbox #main.listbox, picarray$(, [selList], 30, 90, 745, 570
groupbox #main.group, "", 785, 5, 140, 410
button #main.browse,"Browse . . .",[browse], UL, 795, 20, 120, 25
Statictext #main.viewer, "Media Type:", 795, 50, 100, 25 checkbox #main.pdf, "PDF",[pdfset],[pdfreset], 795, 70, 50, 25 checkbox #main.rtf, "RTF",[rtfset],[rtfreset], 850, 70, 50, 25 checkbox #main.txt, "TXT",[txtset],[txtreset], 795,100, 50, 25 checkbox #main.photo, "Photo",[photoset],[photoreset], 850,100, 60, 25
button #main.open,"Open File",[openFile], UL, 795, 130, 120, 25 Statictext #main.viewer, "Open Using:", 795, 160, 100, 25 radiobutton #main.photoviewer, "Photo",[photoviewset],[photoviewreset], 795, 180, 60, 25 radiobutton #main.paintviewer, "Paint",[paintset],[paintreset], 870, 180, 60, 25
button #main.explor, "Open Explorer", [explor], UL, 795, 320, 120, 25
statictext #main.rentxt, "New File Name:", 30, 60, 100, 20 button #main.renbut, "Rename File", [ren], UL, 795, 220, 120, 25 textbox #main.renbox, 130, 60, 400, 25 button #main.renbut2, "Rename File", [RenameFile], UL, 655, 60, 100, 25
button #main.del,"Delete File",[delFile], UL, 795, 270, 120, 25 button #main.quit,"Quit",[quit], UL, 795, 370, 120, 25
menu #main, "Commands", "Browse . . .",[browse], "Open File",[openFile],"Open Explorer", [explor], "Rename File", [RenameFile], "Delete File",[delFile],"Quit",[quit]
'-----End GUI objects
open "File Finder" for window_nf as #main print #main, "font ms_sans_serif 10" print #main, "trapclose [quit]";
' **************************************************** Browse, Open, Delete Buttons 'print #main.browse, "!disable" print #main.open, "!disable" print #main.del, "!disable"
' **************************************************** Rename Buttons print #main.rentxt, "!disable" 'text print #main.rentxt, "!hide" 'text print #main.renbut, "!disable" 'button print #main.renbox, "!disable" 'textbox print #main.renbox, "!hide" 'textbox
#main.renbut2, "!disable" 'button #main.renbut2, "!hide" 'button
' **************************************************** PDF, RTF, TXT. Phot Checkboxes print #main.pdf, "set" print #main.rtf, "set" print #main.txt, "set" print #main.photo, "set" pdffiles = 1: rtffiles = 1: txtfiles= 1: photofiles= 1
' **************************************************** Photo View and radio buttons Buttons print #main.viewer, "!disable" print #main.photoviewer, "disable" print #main.paintviewer, "disable"
print #main.photoviewer, "set" print #main.paintviewer, "reset"
print #main.listbox, "singleclickselect"
dim info$(10,10) dim picarray$(100000)
'*************************************************** Wait [waitloop] wait
'*************************************************** Browse [browse] ' Verify that some checkbox is set if pdffiles = 0 and rtffiles = 0 and txtfiles = 0 and photofiles = 0 then notice, "Please check a File Type check box" goto [waitloop] end if
print #main.open, "!disable" print #main.del, "!disable" print #main.viewer, "!disable" print #main.photoviewer, "disable" print #main.paintviewer, "disable"
sPath$ = " "
BIF.RETURNONLYFSDIRS = 1 BIF.USENEWUI = 64 MAX.PATH = 260 crlf$=chr$(13)+chr$(10)
STRUCT BrowseInfo,_ hWndOwner As Long,_ pIDLRoot As Long,_ pszDisplayName As Long,_ lpszTitle$ As ptr,_ ulFlags As Long,_ lpfnCallback As Long,_ lParam As Long,_ iImage As Long 'Set the owner window, optional 'BrowseInfo.hWndOwner.struct = 0
txt1$ = "************************" + crlf$ txt1$=txt1$+"Please Choose A Folder!"
BrowseInfo.lpszTitle$.struct = txt1$ 'Return only if the user selected a directory BrowseInfo.ulFlags.struct = BIF.RETURNONLYFSDIRS' or BIF.USENEWUI this is Make New Dir button on form
[chooseFolder] 'Show the 'Browse for folder' dialog calldll #shell32, "SHBrowseForFolder",_ BrowseInfo as struct,_ lpIDList as long If lpIDList>0 Then sPath$ = space$(MAX.PATH) + chr$(0) 'Get the path from the IDList calldll #shell32, "SHGetPathFromIDList",_ lpIDList as long,_ sPath$ as ptr,_ r as long
open "ole32" for dll as #ole 'free the block of memory calldll #ole, "CoTaskMemFree",_ lpIDList as long,_ r as long close #ole
iNull = InStr(sPath$, chr$(0)) If iNull Then sPath$ = Left$(sPath$, iNull - 1) End If End If
Folder$ = sPath$ if Folder$ = "C:\" then Folder$ = "c: " if Folder$ = "D:\" then Folder$ = "d: " if Folder$ = "E:\" then Folder$ = "e: " if Folder$ = "F:\" then Folder$ = "f: " if Folder$ = "G:\" then Folder$ = "g: " if Folder$ = "H:\" then Folder$ = "h: " if Folder$ = "A:\" then Folder$ = "a: " if Folder$ = "B:\" then Folder$ = "b: "
print #main.path, Folder$
if sPath$ = " " then goto [waitloop]
'*************************************************** Search [search] folderPath$ = Folder$ print #main.path, Folder$ redim picarray$(100000) dim info$(10,10)
global z: global pdffiles: global rtffiles: global txtfiles: global photofiles: global y cursor hourglass
print folderAction(folderPath$)
cursor normal print #main.listbox, "reload" print #main.open, "!disable" goto[waitloop]
Function folderAction(path$)
dim folderActionInfo$(1, 1) files path$, folderActionInfo$()
numFiles = val(folderActionInfo$(0, 0)) numFolders = val(folderActionInfo$(0, 1))
if instr(path$, "Recycle") or instr(path$, "Program Files") > 1 then goto [end] if instr(path$, "ProgramData") or instr(path$, "Users") > 1 then goto [end] if instr(path$, "Windows") > 1 then goto [end]
redim info$(10,10)
'Remove space from "c:\ "+path lenPath = len(path$) left = instr(path$," ") first$=left$(path$,left-1) second$=right$(path$,lenPath-left) path$=first$+second$
files path$, info$() totfiles = val(info$(0,0))
for w = 1 to totfiles file$ = info$(w,0) if pdffiles = 1 then if instr(file$, ".PDF") or instr(file$, ".pdf") then y = y + 1 picarray$(y)=path$+"\"+file$ end if end if
if rtffiles = 1 then if instr(file$, ".RFT") or instr(file$, ".rtf") then y = y + 1 picarray$(y)=path$+"\"+file$ end if end if
if txtfiles = 1 then if instr(file$, ".TXT") or instr(file$, ".txt") then y = y + 1 picarray$(y)=path$+"\"+file$ end if end if
if photofiles = 1 then if instr(file$, ".jpg") _ or instr(file$, ".JPG") _ or instr(file$, ".jpeg") _ or instr(file$, ".JPEG") _ or instr(file$, ".png") _ or instr(file$, ".PNG") _ or instr(file$, ".gif") _ or instr(file$, ".GIF") _ or instr(file$, ".bmp") _ or instr(file$, ".BMP") then y = y + 1 picarray$(y)=path$+"\"+file$ end if end if next w
if numFolders > 0 then do if folderList$ <> "" then folderList$ = folderList$ + "|" x = x + 1 folderList$ = folderList$ + folderActionInfo$(x, 1) loop while (x - numFiles) < numFolders
'For each folder, call folderAction() again For x = 1 to numFolders folder$ = word$(folderList$, x, "|") a = folderAction(path$ + "\" + folder$) if a then ERRFLAG = a exit for end if Next x End If [end] End Function
'*************************************************** List Box Selection [selList] #main.listbox "selection? sel$" print #main.path, sel$
if instr(sel$, ".jpg") _ or instr(sel$, ".JPG") _ or instr(sel$, ".jpeg") _ or instr(sel$, ".JPEG") _ or instr(sel$, ".png") _ or instr(sel$, ".PNG") _ or instr(sel$, ".bmp") _ or instr(sel$, ".BMP") _ or instr(sel$, ".gif") _ or instr(sel$, ".GIF") then print #main.open, "!enable" print #main.renbut, "!enable" print #main.del, "!enable" end if
if instr(sel$, ".PDF") _ or instr(sel$, ".pdf") then print #main.open, "!enable" print #main.renbut, "!enable" print #main.del, "!enable" end if
if instr(sel$, ".RTF") _ or instr(sel$, ".rtf") then print #main.open, "!enable" print #main.renbut, "!enable" print #main.del, "!enable" end if
if instr(sel$, ".TXT") _ or instr(sel$, ".txt") then print #main.open, "!enable" print #main.renbut, "!enable" print #main.del, "!enable" end if
print #main.viewer, "!disable" print #main.photoviewer, "disable" print #main.paintviewer, "disable"
if instr(sel$, ".jpg") _ or instr(sel$, ".JPG") _ or instr(sel$, ".jpeg") _ or instr(sel$, ".JPEG") _ or instr(sel$, ".png") _ or instr(sel$, ".PNG") _ or instr(sel$, ".bmp") _ or instr(sel$, ".BMP") _ or instr(sel$, ".gif") _ or instr(sel$, ".GIF") then if photofiles = 1 then print #main.viewer, "!enable" print #main.photoviewer, "enable" print #main.paintviewer, "enable" end if end if
if instr(sel$, " ") then sel$ = chr$(34)+sel$+chr$(34)
goto [waitloop]
'*************************************************** Open [openFile] if instr(sel$, ".jpg") _ or instr(sel$, ".JPG") _ or instr(sel$, ".jpeg") _ or instr(sel$, ".JPEG") _ or instr(sel$, ".png") _ or instr(sel$, ".PNG") _ or instr(sel$, ".bmp") _ or instr(sel$, ".BMP") _ or instr(sel$, ".gif") _ or instr(sel$, ".GIF") then if paintviewer = 1 then run "mspaint "+sel$ else run "explorer.exe "+sel$ end if goto [waitloop] end if
print #main.viewer, "!disable" print #main.photoviewer, "disable" print #main.paintviewer, "disable"
run "explorer.exe "+sel$
goto [waitloop]
'*************************************************** Del File [delFile]
if sel$ <> "" then run "explorer.exe "+sel$ else goto [waitloop] end if
confirm "You are about to delete this file"+chr$(13)+"Are you sure?"; answer$ if answer$ = "no" then goto [waitloop] else rensel$ = sel$ length = len(sel$) [spaceloop] space = instr(sel$,chr$(34)) if instr(sel$,chr$(34)) > 0 then newpath$ = left$(sel$,space-1) sel$=newpath$+mid$(sel$,space+1,length) goto [spaceloop] end if kill sel$ sel$ = "" end if
print #main.open, "!disable" print #main.renbut, "!disable" print #main.del, "!disable"
goto [search]
'*************************************************** Radio PhotoViewer [photoviewset] photoviewer = 1 paintviewer = 0 print #main.paintviewer, "reset" goto [waitloop]
[photoviewreset] photoviewer = 0 paintviewer = 0 print #main.paintviewer, "set" goto [waitloop]
'*************************************************** Radio Paint [paintset] paintviewer = 1 photoviewer = 0 print #main.photoviewer, "reset" goto [waitloop]
[paintreset] paintviewer = 0 photoviewer = 1 print #main.photoviewer, "set" goto [waitloop]
'*************************************************** Checkbox PDF [pdfset] pdffiles = 1 print #main.browse, "!enable" goto [waitloop]
[pdfreset] pdffiles = 0 goto [waitloop]
'*************************************************** Checkbox RTF [rtfset] rtffiles = 1 print #main.browse, "!enable" goto [waitloop]
[rtfreset] rtffiles = 0 goto [waitloop]
'*************************************************** Checkbox TXT [txtset] txtfiles = 1 print #main.browse, "!enable" goto [waitloop]
[txtreset] txtfiles = 0 goto [waitloop]
'*************************************************** Checkbox Photo [photoset] photofiles = 1 print #main.browse, "!enable" goto [waitloop]
[photoreset] photofiles = 0 goto [waitloop]
'*************************************************** Explorer [explor] run "explorer" goto [waitloop]
'*************************************************** Rename GUI [ren] print #main.rentxt, "!enable" 'text print #main.rentxt, "!show" 'text
print #main.renbox, "!enable" 'textbox print #main.renbox, "!show" 'textbox
print #main.renbut, "!disable" 'button print #main.renbut, "!hide" 'button
print #main.renbut2, "!enable" 'button print #main.renbut2, "!show" 'button
print #main.renbox, sel$
renameFileSet = 1 goto [waitloop]
'*************************************************** Rename File [RenameFile] if renameFileSet = 0 then goto [waitloop]
print #main.renbox, "!contents? newname$" NAME sel$ as newname$
print #main.rentxt, "!hide" 'text print #main.renbox, "!hide" 'textbox print #main.renbut2, "!hide" 'button print #main.renbut, "!show" 'button
renameFileSet = 0
print #main.open, "!disable" print #main.renbut, "!disable" print #main.del, "!disable"
goto [search]
'*************************************************** Quit [quit] close #main end
|
|