User Tools

Site Tools


filenames_20containing_20spaces

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

filenames_20containing_20spaces [2018/03/31 13:19]
127.0.0.1 external edit
filenames_20containing_20spaces [2018/04/17 16:07]
tbest3112 Added syntax highlighting
Line 2: Line 2:
  
 //by Richard Russell, May 2006//\\ \\  You don't need to take any special precautions when using **OPENIN**, **OPENOUT** or **OPENUP** to access files whose names (or paths) contain one or more spaces:\\ \\  //by Richard Russell, May 2006//\\ \\  You don't need to take any special precautions when using **OPENIN**, **OPENOUT** or **OPENUP** to access files whose names (or paths) contain one or more spaces:\\ \\ 
 +<code bb4w>
         filename$ = "​Filename containing spaces"​         filename$ = "​Filename containing spaces"​
         file% = OPENIN(filename$)         file% = OPENIN(filename$)
         file% = OPENUP(filename$)         file% = OPENUP(filename$)
         file% = OPENOUT(filename$)         file% = OPENOUT(filename$)
 +</​code>​
 However if you need to access such a file with a //​**star**//​ command (or with **OSCLI**) then you should enclose the filename in quotes:\\ \\  However if you need to access such a file with a //​**star**//​ command (or with **OSCLI**) then you should enclose the filename in quotes:\\ \\ 
 +<code bb4w>
         *DISPLAY "​Filename containing spaces"​         *DISPLAY "​Filename containing spaces"​
         *COPY "​Source file" "​Destination file"         *COPY "​Source file" "​Destination file"
 +</​code>​
 When using **OSCLI** (typically because the filename is a variable rather than a constant) then you must add quotes around the filename(s) in the command string. There are two main ways of doing this, firstly by using the **CHR$34** character:​\\ \\  When using **OSCLI** (typically because the filename is a variable rather than a constant) then you must add quotes around the filename(s) in the command string. There are two main ways of doing this, firstly by using the **CHR$34** character:​\\ \\ 
 +<code bb4w>
         filename$ = "​Filename containing spaces"​         filename$ = "​Filename containing spaces"​
         OSCLI "​DISPLAY "​+CHR$34+filename$+CHR$34         OSCLI "​DISPLAY "​+CHR$34+filename$+CHR$34
Line 15: Line 20:
         dstfile$ = "​Destination file"         dstfile$ = "​Destination file"
         OSCLI "COPY "​+CHR$34+srcfile$+CHR$34+"​ "​+CHR$34+dstfile$+CHR$34         OSCLI "COPY "​+CHR$34+srcfile$+CHR$34+"​ "​+CHR$34+dstfile$+CHR$34
 +</​code>​
 and secondly by using the **""​** sequence:\\ \\  and secondly by using the **""​** sequence:\\ \\ 
 +<code bb4w>
         filename$ = "​Filename containing spaces"​         filename$ = "​Filename containing spaces"​
         OSCLI "​DISPLAY """​+filename$+""""​         OSCLI "​DISPLAY """​+filename$+""""​
Line 21: Line 28:
         dstfile$ = "​Destination file"         dstfile$ = "​Destination file"
         OSCLI "COPY """​+srcfile$+"""​ """​+dstfile$+""""​         OSCLI "COPY """​+srcfile$+"""​ """​+dstfile$+""""​
 +</​code>​
 Forgetting to include the quotes can result in confusing (at first sight) symptoms. Some people find that the method using CHR$34 tends to produce clearer code and is easier to debug. Others prefer the compactness of the ""​ method. Use whichever you feel happier with. Forgetting to include the quotes can result in confusing (at first sight) symptoms. Some people find that the method using CHR$34 tends to produce clearer code and is easier to debug. Others prefer the compactness of the ""​ method. Use whichever you feel happier with.
filenames_20containing_20spaces.txt ยท Last modified: 2018/04/17 16:07 by tbest3112