1. system() and quotes



Is this a discrepancy?:

 
  junk = "ipconfig > \""&current_dir()&"\\ipconfig.txt\"" 
  system(junk,0) 
 
  junk = "\""&current_dir()&"\\ipconfig.txt\"" 
  object ipreadfile = open(junk,"rb") 
 



ipreadfile is always -1 with the quotes, even tho the quotes are required in the system call.

useless

new topic     » topic index » view message » categorize

2. Re: system() and quotes

Kat said...

Is this a discrepancy?:

No, it is not a discrepancy.

Kat said...
 
  junk = "ipconfig > \""&current_dir()&"\\ipconfig.txt\"" 
  system(junk,0) 
 
  junk = "\""&current_dir()&"\\ipconfig.txt\"" 
  object ipreadfile = open(junk,"rb") 
 

ipreadfile is always -1 with the quotes, even tho the quotes are required in the system call.

The system() call passes its argument to a command processor's command line, just as if you had typed them into the console. The command processor uses spaces to delimit parameters, so that's why one needs the quotes around file paths that contain spaces.

But when it comes to calling the open() function, you have already delimited the parameters so everything in the first argument is treated by the system as a file path - the system does no further examination of it to split it into separate parameters.

The correct coding would be more like ...

  path = current_dir() & SLASH & `ipconfig.txt` 
  junk = `ipconfig > "` & path & `"` 
  system(junk,0) 
 
  object ipreadfile = open(path,"rb") 
 
new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu