Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Another issue: Changing one variable instantly changes the value of another variable
#11
(06-17-2022, 02:08 PM)bplus Wrote: How do you get double quotes in a path or filename? (Just really curious!)

My first guess to this would be to parse a file which has them in it.  Let's say, for example, the following is my text file:  

MyWebsite = "https://www.qb64phoenix.com/"
MyForums = "https://www.qb64phoenix.com/forums/"

Now, all I need to do is parse everything after the equal sign and I have my links..  But, those links need to be cleaned up to remove the quotes around them, before I can use them, which leads to writing the type of code shared in the leading posts.  Wink
Reply
#12
Quote:You'd still end up with the same root issue though when you did a return$ = ClearPath(Temp$).

;-)) Not me, I prefaced what I said with this:
Code: (Select All)
' don't share temp$, temp$ is supposed to be temporary!!!
test$ = "C:\Dir1\Dir2\"
Print CleanPath$(test$)
  724  855  599  923  575  468  400  206  147  564  878  823  652  556 bxor cross forever
Reply
#13
Code: (Select All)
MyWebsite$ = "https://www.qb64phoenix.com/"
MyForums$ = "https://www.qb64phoenix.com/forums/"
Print "Show me the "; Chr$(34); "'s !?  ;-))"
Print MyWebsite$ + Chr$(10) + MyForums$

OK maybe out of a text file, I can see that.
  724  855  599  923  575  468  400  206  147  564  878  823  652  556 bxor cross forever
Reply
#14
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 :-).
Reply
#15
Quote:Another effect of LINE INPUT is that it accepts the quote marks.

Oh, good to know! thanks
  724  855  599  923  575  468  400  206  147  564  878  823  652  556 bxor cross forever
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Linux Lubuntu INKEY$ issue TempodiBasic 7 651 09-09-2025, 02:53 PM
Last Post: hsiangch_ong
  Variable length type declarations dano 5 690 08-06-2025, 09:53 PM
Last Post: dano
  Determining if variable or static string is passed to a Sub dano 9 1,227 06-20-2025, 06:31 PM
Last Post: CookieOscar
  Most efficient way to build a big variable length string? mdijkens 9 1,895 01-17-2025, 11:36 PM
Last Post: ahenry3068
  Huge array of variable length strings mdijkens 9 1,834 10-17-2024, 02:01 PM
Last Post: mdijkens

Forum Jump:


Users browsing this thread: 1 Guest(s)