Backslash versus foreslash - Printable Version +- QB64 Phoenix Edition (https://staging.qb64phoenix.com) +-- Forum: Chatting and Socializing (https://staging.qb64phoenix.com/forumdisplay.php?fid=11) +--- Forum: General Discussion (https://staging.qb64phoenix.com/forumdisplay.php?fid=2) +--- Thread: Backslash versus foreslash (/showthread.php?tid=1389) Pages:
1
2
|
Backslash versus foreslash - TerryRitchie - 01-10-2023 I was under the impression that at some point QB64 had the ability added to change the backslash character in path strings to foreslashes if it detected it was running within Linux. For example, this line of code: MySprite& = _LOADIMAGE(".\assets\sprite.png", 32) would be seen as MySprite& = _LOADIMAGE("./assets/sprite.png", 32) when running in Linux. Was or is this still the case or is my age showing again? I really need to get another Linux box up and running so I can test these things out. RE: Backslash versus foreslash - SpriggsySpriggs - 01-10-2023 That sounds right but I can't be 100% for certain RE: Backslash versus foreslash - SMcNeill - 01-10-2023 It won't change it inside your code automatically, but most of the file commands will work with it either way for you. Where you'd have to be careful is with SHELL and such. SHELL "./foo \e /a" <-- is \e a path? or /a? Or both params of foo? Who knows!! So, QB64 won't mess with those for you, so you'll have to have your slashes right then, for your programs. As for _LOADIMAGE though? I *think* it doesn't really matter, as QB64 will swap those slashes to what's proper, before loading the file for you. (I say I *think*, because QB64 has a dozen different load routines inside it for files, includes, fonts, sounds, ect, ect. There's always an off chance that some of those missed out on the internal swapping of slashes.) If you can test it, and it works, all is fine. If you can't test it for yourself, and are in doubt of the behavior, swap them out manually. Better to play it safe than sorry, in my opinion. RE: Backslash versus foreslash - SpriggsySpriggs - 01-10-2023 Something as simple as $IF LINUX THEN LOADIMAGE("./a/directory/with/forward/slashes") $ELSE IF WINDOWS THEN LOADIMAGE(".\a\directory\with\backslashes") $END IF RE: Backslash versus foreslash - mnrvovrfc - 01-10-2023 To extend that theme, and to exaggerate a little bit to be clear as possible: Code: (Select All) DIM slosh AS STRING, pichan AS LONG Could also write a simple search-and-replace routine that uses "MID$()" LHS for one character: Code: (Select All) DIM slosh AS STRING, mypath AS STRING Pipe symbol is special to shell so cannot be used in a filename neither in Linux nor Windows. On MacOS, who knows? Maybe Fifi could tell us. Note: I didn't include the subprogram because I don't have it with me at the moment. I have another one which works differently, ie. for search and replace strings of different lengths and therefore it doesn't use "MID$()" command. RE: Backslash versus foreslash - SMcNeill - 01-10-2023 I was thinking more along the lines of something simple such as: Code: (Select All) foo$ = "./mydir/foo.txt" RE: Backslash versus foreslash - TerryRitchie - 01-10-2023 Thanks for the replies guys. I knew the code itself would not change but underneath the correct interpretation of the slash would be used given the OS involved. The reason I asked is that a tutorial user stated he had to change all of the backslashes to foreslashes to get the example listings to work in Linux. But like I said I could have swore QB64 would handle this behind the scenes. It could be that he is using a version of QB64 before this was implemented. I haven't gotten a reply back from him yet to find out. I was hoping to avoid having to add directives to detect Windows and Linux in all of the source code I posted on the tutorial. I'll probably add a section in the tutorial detailing this and other differences between OS' when using QB64. I'm going to set up another Linux box in the mean time. Those of you that use QB64 with Linux which distribution would you recommend? In the past I usually went with Mint. Any downside to using Mint? RE: Backslash versus foreslash - SMcNeill - 01-10-2023 Mint is what I last used for my VM with Linux. Was a 1 click download and install, with no problems, so I'd have to recommend it for use with QB64. If you find out that _LOADIMAGE doesn't swap those slashes automatically, toss us a note or make an issue at github. Something like that should be easy enough to make a quick fix for. RE: Backslash versus foreslash - TerryRitchie - 01-10-2023 (01-10-2023, 06:54 PM)SMcNeill Wrote: Mint is what I last used for my VM with Linux. Was a 1 click download and install, with no problems, so I'd have to recommend it for use with QB64. Will do, thanks. RE: Backslash versus foreslash - Fifi - 01-11-2023 (01-10-2023, 06:34 PM)mnrvovrfc Wrote: Pipe symbol is special to shell so cannot be used in a filename neither in Linux nor Windows. On MacOS, who knows? Maybe Fifi could tell us. Hi all, As far as I know, the use of pipe symbols on macOS is the same as with Linux and can't be used in a filename on a hfs+ formatted drive. However, I never tried the apfs format but I guess the use of the pipe symbols is the same since it's used with bash. About Linux on a VM, I recommend both Linuxmint and LMDE (Linus Mint Debian Edition). However, whatever your main OS is (macOS, Linux or the crippled M$ Windows), the VM tool I definitely recommend is VMware for its real performances and efficient memory management Vs VirtualBox or Parallels Desktop. Just my 2 cents. Cheers. Fifi |