06-17-2022, 05:11 PM
Just to answer a few questions...
First, I don't pass Temp$ to the subroutine. The CleanPath subroutine is called from many different places in the code, passing various variables such as SourcePath$, DestinationPath$, ImagePath$, etc.
Temp$ is supposed to hold the final "cleaned" path. Since it is a global varaible, when I return from the subroutine I set my original variable to Temp$.
Example: SourcePath$ contains a full path including a filename and extension. It's possible that this path could contain a trailing backslash and / or it may be enclosed in quotes. I call the CleanPath subroutine passing SourcePath$ to it. The subroutine cleans the path and after returning from the subroutine I set to SourcePath$ to Temp$ (Temp$ holds the "cleaned" path).
Next question: How am I getting quotes in the string?
The program allows the user to provide a path by typing it in or pasting it. If a user responds to an INPUT with a path in quotes (often done if there are spaces in the path), the quotes automatically get stripped off. However, also want to allow paths that include commas (commas are valid in a path and in a filename). Since a normal INPUT won't accept a comma, I use LINE INPUT. Another effect of LINE INPUT is that it accepts the quote marks. In order to allow a user to enter a path with or without quotes, I run any path supplied through the cleanpath subroutine so that the end result is always consistent - a path without quotes and no trailing backslash.
As an example, if a user right-clicks a path in File Explorer and chooses "Copy as path", when pasted, this will include double-quote marks.
In any case, I thank you all for the suggestions - it's all working fine now. 15,000 lines of code so I still have a few more areas to test, but so far everything looks good with maybe 75% of my code tested :-).
First, I don't pass Temp$ to the subroutine. The CleanPath subroutine is called from many different places in the code, passing various variables such as SourcePath$, DestinationPath$, ImagePath$, etc.
Temp$ is supposed to hold the final "cleaned" path. Since it is a global varaible, when I return from the subroutine I set my original variable to Temp$.
Example: SourcePath$ contains a full path including a filename and extension. It's possible that this path could contain a trailing backslash and / or it may be enclosed in quotes. I call the CleanPath subroutine passing SourcePath$ to it. The subroutine cleans the path and after returning from the subroutine I set to SourcePath$ to Temp$ (Temp$ holds the "cleaned" path).
Next question: How am I getting quotes in the string?
The program allows the user to provide a path by typing it in or pasting it. If a user responds to an INPUT with a path in quotes (often done if there are spaces in the path), the quotes automatically get stripped off. However, also want to allow paths that include commas (commas are valid in a path and in a filename). Since a normal INPUT won't accept a comma, I use LINE INPUT. Another effect of LINE INPUT is that it accepts the quote marks. In order to allow a user to enter a path with or without quotes, I run any path supplied through the cleanpath subroutine so that the end result is always consistent - a path without quotes and no trailing backslash.
As an example, if a user right-clicks a path in File Explorer and chooses "Copy as path", when pasted, this will include double-quote marks.
In any case, I thank you all for the suggestions - it's all working fine now. 15,000 lines of code so I still have a few more areas to test, but so far everything looks good with maybe 75% of my code tested :-).