Author Topic: Problem with _xmlcfg_open() ?  (Read 6708 times)

Wanderer

  • Senior Community Member
  • Posts: 557
  • Hero Points: 23
Problem with _xmlcfg_open() ?
« on: March 27, 2009, 07:04:22 PM »
It appears that _xmlcfg_open() can't take filenames with spaces.

Code: [Select]
_command void testXCO() name_info(',')
{
   _str s1 = "c:\\temp\\2.vw";
   _str s2 = "c:\\temp\\One Two.vw";

   int status;
   int hndl;

   hndl = _xmlcfg_open(maybe_quote_filename( s1 ), status);
   _message_box("hndl: " :+ hndl);


   hndl = _xmlcfg_open(maybe_quote_filename( s2 ), status);
   _message_box("hndl: " :+ hndl);

}
Both .vw files exist.  2.vw opens; "One Two.vw" does not.

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6866
  • Hero Points: 528
Re: Problem with _xmlcfg_open() ?
« Reply #1 on: March 27, 2009, 07:48:15 PM »
Don't use double quotes.  This is a bit of a gotcha.  As a rule, when a filename is passed as a stand alone argument (i.e no switches or multiple filenames), double quotes are not supported.  Commands like edit, which can be called like a function, requires double quoting because the argument is not just one filename (it's multiple filenames and switches). One less obvious function is file_match() which requires double quotes on the filename because that argument can have options in it.  file_match is not one of the better designed functions. It's best to design functions (not commands) so double quoting is not necessary. There are a few functions which take a single filename argument which do strip double quotes.  However, even I don't remember which ones do and which ones don't.

Wanderer

  • Senior Community Member
  • Posts: 557
  • Hero Points: 23
Re: Problem with _xmlcfg_open() ?
« Reply #2 on: March 27, 2009, 07:56:03 PM »
Thanks for the reply, but when I remove the calls to maybe_quote_filename(), it still doesn't work.

Code: [Select]
_command void testXCO() name_info(',')
{
   _str s1 = "c:\\temp\\2.vw";
   _str s2 = 'c:\\temp\\One Two.vw';

   int status;
   int hndl;

   hndl = _xmlcfg_open( s1 , status);
   _message_box("hndl: " :+ hndl);


   _message_box("fn: " :+ s2);
   hndl = _xmlcfg_open(s2, status);
   _message_box("hndl: " :+ hndl);

}

Or did I misunderstand something?

Wanderer

  • Senior Community Member
  • Posts: 557
  • Hero Points: 23
Re: Problem with _xmlcfg_open() ?
« Reply #3 on: March 27, 2009, 08:02:18 PM »
Strange --
This opens:
"c:\\Documents and Settings\\2.vw"

This does not:
"c:\\temp\\One Two.vw"


Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6866
  • Hero Points: 528
Re: Problem with _xmlcfg_open() ?
« Reply #4 on: March 27, 2009, 08:30:14 PM »
I name an xml file 'c:\temp\One Two.vw' and it opened just fine.

Wanderer

  • Senior Community Member
  • Posts: 557
  • Hero Points: 23
Re: Problem with _xmlcfg_open() ?
« Reply #5 on: March 27, 2009, 08:48:47 PM »
Here are the files I am experimenting with.

Wanderer

  • Senior Community Member
  • Posts: 557
  • Hero Points: 23
Re: Problem with _xmlcfg_open() ?
« Reply #6 on: March 27, 2009, 09:15:42 PM »
It appears it was the content of the XML file.
<One Two> isn't valid.