stumpy
Member in Training
Posts: 66
|
Post by stumpy on Apr 23, 2018 7:21:43 GMT
I would not use LOADBMP and BMPSAVE for copying, since this will try to handle the image in memory. Only copy the image without making it available in JB. open SourceFile$ for input as #original open DestFile$ for output as #copy print #copy, input$(#original, lof(#original)); close #copy close #original
Looks much better and will try to use that instead... Thanks all
|
|
stumpy
Member in Training
Posts: 66
|
Post by stumpy on Apr 23, 2018 7:54:15 GMT
I ran the code, below:
- Selected a jpg in the current folder (desktop, where the BAS was located) - and tried to edit the text in the textbox following statictext "EDIT Path/FileName for Copying:" - by adding 'COPY' to the name... - and got "Runtime Error: OS Error: The system cannot find the path specified"
'FILE COPIER
foregroundColor$ = "black" WindowWidth = DisplayWidth WindowHeight = DisplayHeight
statictext #main.statictext1, "LOADING FILE", 188, 70, 80, 15 statictext #main.statictext2, "============", 188, 82, 80, 20
statictext #main.statictext3, "Press button to Search:", 67, 110, 120, 20 button #main.displayfiles, "Find a FILE on Disc", [findfile], UL, 188, 103, 112, 30
statictext #main.statictext4, "The File, if Loaded:", 85, 146, 117, 20 statictext #main.inputfile, sourcefile$, 188, 146, 1000, 30
'----------------------------------------------------- statictext #main.statictext5, "SAVING FILE", 188, 254, 80, 15 statictext #main.statictext6, "===========", 188, 266, 80, 20
statictext #main.statictext7,"EDIT Path/FileName for Copying:", 18, 292, 165, 20 TEXTBOX #main.outputfile, 188, 289, 1000, 22
statictext #main.statictext8, "Press button to Save:", 73, 331, 110, 20 button #main.savebmp, "SAVE FILE to Disc", [InputOutput], UL 188, 325, 103, 30
'------------------------------------------------------ nomainwin open "JPG COPIER" for window_nf as #main print #main, "trapclose [quit]"
[start]
if sourcefile$ = "" then sourcefile$ = "NO FILE LOADED" end if
if sourcefile$ <> "" then destfile$ = sourcefile$ end if
print #main.inputfile, sourcefile$ print #main.outputfile, destfile$
wait
'-------------------
[findfile]
filedialog "Select File", "*", sourcefile$ goto [start]
'-------------
[InputOutput] print #main.outputfile, "!contents? destfile$" 'sourcefile$ = file already selected in dialog 'destfile$ is the Edited text in the textbox
'Notice "yet to be implemented..." open SourceFile$ for input as #original open DestFile$ for output as #copy print #copy, input$(#original, lof(#original)); close #copy close #original
goto [start]
'notice "copied" + chr$(13) + "The file '" + sourcefile$ + "', has been saved as:- " + chr$(13) + chr$(13) + "'" + destfile$
'goto [start]
'---------------------------
[quit] confirm "Do you want to quit BMP Copier ?"; quit$ if quit$ = "no" then wait
if stored$ <> "" then UNLOADBMP "bmpstored" close #main end
...after EDITING OUTPUT FILENAME to (old filename) + 'COPY'
Error(Exception)>>defaultAction Error(Exception)>>activateHandler: <anUndefinedObject> Error(Exception)>>handle Error(Exception)>>signal Error class(Exception class)>>signal: <'OS Error: The system...'> BasicProgram(Object)>>error: <'OS Error: The system...'> BasicProgram>>terminateRun: <aFileError> [] in BasicProgram>>errorHandlerBlock ExceptionHandler>>evaluateResponseBlock: <aBlockClosure> for: <aFileError> [] in ExceptionHandler>>handle: ProtectedFrameMarker(BlockClosure)>>setUnwind: <aBlockClosure> BlockClosure>>invisibleEnsure: <aBlockClosure> ExceptionHandler>>handle: <aFileError> ExceptionHandler>>findHandler: <aFileError> FileError(Exception)>>activateHandler: <anExceptionHandler> FileError(Exception)>>handle FileError(Exception)>>signal FileError class>>signal: <'OS Error: The system...'> hostErrorCode: <3> HostFileSystemError>>defaultAction ExceptionHandler>>findHandler: <aHostFileSystemError> HostFileSystemError(Exception)>>activateHandler: <anExceptionHandler> HostFileSystemError(Exception)>>handle HostFileSystemError(Exception)>>signal HostFileSystemError class>>signalWith: <3> FileHandle class>>osError: <3> FileHandle class(Object)>>osError [] in FileHandle class>>open:access:share:create:attributes: ExceptionHandler>>evaluateProtectedBlock: <aBlockClosure> [] in ExceptionHandler>>activateDuring: ProtectedFrameMarker(BlockClosure)>>setUnwind: <aBlockClosure> BlockClosure>>invisibleEnsure: <aBlockClosure> ExceptionHandler>>activateDuring: <aBlockClosure> ExceptionHandler class>>handle: <anExceptionSet> with: <aBlockClosure> during: <aBlockClosure> BlockClosure>>on: <anExceptionSet> do: <aBlockClosure> FileHandle class>>open: <'C:\Users\sittingroom...'> access: <2147483648> share: <3> create: <3> attributes: <128> FileHandle class>>open: <''> in: <aDirectory> access: <2147483648> share: <3> create: <3> attributes: <128> FileHandle class>>openReadOnly: <''> in: <aDirectory> File>>openReadOnly File>>readStream File class>>pathNameReadOnly: <''> in: <aDirectory> Directory>>fileReadOnly: <''> BasicFile>>from: <''> mode: <'INPUT'> handle: <'#original'> BasicFile class>>from: <''> mode: <'INPUT'> handle: <'#original'> owner: <aBasicProgram> length: <anUndefinedObject> [] in OpenCommand>>using: [] in BasicProgram>>begin ExceptionHandler>>evaluateProtectedBlock: <aBlockClosure> [] in ExceptionHandler>>activateDuring: ProtectedFrameMarker(BlockClosure)>>setUnwind: <aBlockClosure> BlockClosure>>invisibleEnsure: <aBlockClosure> ExceptionHandler>>activateDuring: <aBlockClosure>
...then, without EDITING OUTPUT FILENAME, i.e. leaving it as (old filename)
Error log timestamp Monday 23/04/18 08:47:49
Runtime error: OS Error: The system cannot find the path specified.
Error(Exception)>>defaultAction Error(Exception)>>activateHandler: <anUndefinedObject> Error(Exception)>>handle Error(Exception)>>signal Error class(Exception class)>>signal: <'OS Error: The system...'> BasicProgram(Object)>>error: <'OS Error: The system...'> BasicProgram>>terminateRun: <aFileError> [] in BasicProgram>>errorHandlerBlock ExceptionHandler>>evaluateResponseBlock: <aBlockClosure> for: <aFileError> [] in ExceptionHandler>>handle: ProtectedFrameMarker(BlockClosure)>>setUnwind: <aBlockClosure> BlockClosure>>invisibleEnsure: <aBlockClosure> ExceptionHandler>>handle: <aFileError> ExceptionHandler>>findHandler: <aFileError> FileError(Exception)>>activateHandler: <anExceptionHandler> FileError(Exception)>>handle FileError(Exception)>>signal FileError class>>signal: <'OS Error: The system...'> hostErrorCode: <3> HostFileSystemError>>defaultAction ExceptionHandler>>findHandler: <aHostFileSystemError> HostFileSystemError(Exception)>>activateHandler: <anExceptionHandler> HostFileSystemError(Exception)>>handle HostFileSystemError(Exception)>>signal HostFileSystemError class>>signalWith: <3> FileHandle class>>osError: <3> FileHandle class(Object)>>osError [] in FileHandle class>>open:access:share:create:attributes: ExceptionHandler>>evaluateProtectedBlock: <aBlockClosure> [] in ExceptionHandler>>activateDuring: ProtectedFrameMarker(BlockClosure)>>setUnwind: <aBlockClosure> BlockClosure>>invisibleEnsure: <aBlockClosure> ExceptionHandler>>activateDuring: <aBlockClosure> ExceptionHandler class>>handle: <anExceptionSet> with: <aBlockClosure> during: <aBlockClosure> BlockClosure>>on: <anExceptionSet> do: <aBlockClosure> FileHandle class>>open: <'C:\Users\sittingroom...'> access: <2147483648> share: <3> create: <3> attributes: <128> FileHandle class>>open: <''> in: <aDirectory> access: <2147483648> share: <3> create: <3> attributes: <128> FileHandle class>>openReadOnly: <''> in: <aDirectory> File>>openReadOnly File>>readStream File class>>pathNameReadOnly: <''> in: <aDirectory> Directory>>fileReadOnly: <''> BasicFile>>from: <''> mode: <'INPUT'> handle: <'#original'> BasicFile class>>from: <''> mode: <'INPUT'> handle: <'#original'> owner: <aBasicProgram> length: <anUndefinedObject> [] in OpenCommand>>using: [] in BasicProgram>>begin ExceptionHandler>>evaluateProtectedBlock: <aBlockClosure> [] in ExceptionHandler>>activateDuring: ProtectedFrameMarker(BlockClosure)>>setUnwind: <aBlockClosure> BlockClosure>>invisibleEnsure: <aBlockClosure> ExceptionHandler>>activateDuring: <aBlockClosure>
|
|
|
Post by tsh73 on Apr 23, 2018 8:07:06 GMT
You open SourceFile$ but filedialog sets sourcefile$
JB is case-sensitive on variable names.
|
|
stumpy
Member in Training
Posts: 66
|
Post by stumpy on Apr 23, 2018 9:11:13 GMT
You open SourceFile$ but filedialog sets sourcefile$ JB is case-sensitive on variable names. tsh73 Thank you, the following code now works! 'FILE COPIER v2
foregroundColor$ = "black" WindowWidth = DisplayWidth WindowHeight = DisplayHeight
statictext #main.statictext1, "LOADING FILE", 188, 70, 80, 15 statictext #main.statictext2, "============", 188, 82, 80, 20
statictext #main.statictext3, "Press button to Search:", 67, 110, 120, 20 button #main.displayfiles, "Find a FILE on Disc", [findfile], UL, 188, 103, 153, 30
statictext #main.statictext4, "The File, if Loaded:", 85, 146, 117, 20 statictext #main.inputfile, sourcefile$, 188, 146, 1000, 30
'----------------------------------------------------- statictext #main.statictext5, "SAVING FILE", 188, 254, 80, 15 statictext #main.statictext6, "===========", 188, 266, 80, 20
statictext #main.statictext7,"EDIT Path/FileName for Copying:", 18, 292, 165, 20 TEXTBOX #main.outputfile, 188, 289, 1000, 22
statictext #main.statictext8, "Press button to Save:", 73, 331, 110, 20 button #main.savebmp, "SAVE Renamed File", [InputOutput], UL 188, 325, 153, 30
'------------------------------------------------------ nomainwin open "File COPIER" for window_nf as #main print #main, "trapclose [quit]"
[start]
if sourcefile$ = "" then sourcefile$ = "NO FILE LOADED" end if
if sourcefile$ <> "" then destfile$ = sourcefile$ end if
print #main.inputfile, sourcefile$ print #main.outputfile, destfile$
wait
'-------------------
[findfile]
filedialog "Select File", "*", sourcefile$ goto [start]
'-------------
[InputOutput] print #main.outputfile, "!contents? destfile$" 'sourcefile$ = file already selected in dialog 'destfile$ is the Edited text in the textbox
if sourcefile$ = "NO FILE LOADED" then notice "Cancelled - No File Name has been Loaded" goto [start] end if
if sourcefile$ = destfile$ then copiedtext$ = chr$(13) + "Cancelled " + chr$(13) + chr$(13) + "- The name of the file to be copied " copiedtext$ = copiedtext$ + chr$(13) + chr$(13) + "must first be edited" notice copiedtext$ goto [start] end if
open sourcefile$ for input as #original open destfile$ for output as #copy print #copy, input$(#original, lof(#original)); close #copy close #original
copiednotice$ = chr$(13) + "' " + destfile$ + " '" + chr$(13) + chr$(13) + " - has been saved" notice copiednotice$
sourcefile$ = ""
goto [start]
'---------------------------
[quit] confirm "Do you want to quit BMP Copier ?"; quit$ if quit$ = "no" then wait
if stored$ <> "" then UNLOADBMP "bmpstored" close #main end
|
|