You are here: PSPad forum > English discussion forum > Re: load new file - not working consistently

Re: load new file - not working consistently

Goto Page: Previous1 2

#11 Re: load new file - not working consistently

Posted by: pspad | Date: 2014-11-12 18:12 | IP: IP Logged

Sorry. I knew I forgot to fix something sad smiley
I will do it.

Options: Reply | Quote | Up ^


#12 Re: load new file - not working consistently

Posted by: Gorlash | Date: 2014-11-12 22:44 | IP: IP Logged

Thank You Excellent Sir!!

Options: Reply | Quote | Up ^


#13 Re: load new file - not working consistently

Posted by: Gorlash | Date: 2014-11-20 16:30 | IP: IP Logged

BTW, if you're having problems with reading cwd during start, the _wgetcwd() function works fine in Unicode builds. I wrote the following utility to test it, building with MinGW; I tested it with executable in different directory than my working directory, and spaces in the path; it worked great!

Gorlash


//**********************************************************************
// Copyright (c) 2014 Daniel D Miller
// wcmdline.cpp - experimenting with Unicode command-line handling
//
// Written by: Daniel D. Miller
// build: g++ -Wall -O2 -DUNICODE -D_UNICODE -mwindows wcmdline.cpp -o wcmdline.exe
//**********************************************************************

#include <windows.h>
#include <stdio.h>
#include <tchar.h>
#include <limits.h>

//********************************************************************
int syslog(const TCHAR *fmt, ...)
{
TCHAR consoleBuffer[3000] ;
va_list al; //lint !e522

va_start(al, fmt); //lint !e1055 !e530
// vsprintf(consoleBuffer, fmt, al); //lint !e64
_vstprintf(consoleBuffer, fmt, al); //lint !e64
OutputDebugString(consoleBuffer) ;
va_end(al);
return 1;
}

//*********************************************************************
static TCHAR **GetArgvCommandLine(int *argc)
{
#ifdef UNICODE
LPTSTR argstr = GetCommandLineW();
return CommandLineToArgvW(argstr, argc) ;
#else
*argc = __argc;
return __argv;
#endif
}

//***********************************************************************
static void parse_command_line(void)
{
// obtain command-line arguments in argv[] style array
TCHAR **argv;
int argc;
argv = GetArgvCommandLine(&argc);

// home=C:\home\Anacom\Reference Docs\Supervisor 10
TCHAR home[PATH_MAX+1];
_wgetcwd(home, PATH_MAX);
syslog(L"home=%s\n", home);

// argc=2
// arg 1: *.iss
syslog(L"argc=%d\n", argc) ;
int idx ;
for (idx=1; idx<argc; idx++) {
syslog(L"arg %d: %s\n", idx, argv[idx]) ;
}

} //lint !e550

//*********************************************************************
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpszArgument, int nFunsterStil)
{
parse_command_line();

return (int) 0 ;
} //lint !e715

Options: Reply | Quote | Up ^


#14 Re: load new file - not working consistently

Posted by: pspad | Date: 2014-11-20 19:31 | IP: IP Logged

Hello Gorlash.

There is no problem to read parameter or command line. There is another problem.
User runs something like: PSPad file.txt
Without quotas, without path.
In this case windows starts new PSPad. I need to get running instance and resend command to running instance. Because running instance has different working directory, I need to parse command and add filepath there.

There are worse cases:
pspad c:\some folder with spaces\file with spaces.txt -R
or
pspad filename with spaces.txt

I can't use windows parse command, cause it splits it for each space. I agree, I can refuse it, cause in this case user should use quotes:
pspad "c:\some folder with spaces\file with spaces.txt" -R

Options: Reply | Quote | Up ^


#15 Re: load new file - not working consistently

Posted by: pspad | Date: 2014-11-20 19:36 | IP: IP Logged

Now another case. If you have application associated with registry, you select several files in Windows explorer and open it in PSPad using context menu. Windows start new PSPad instance for each file!
I need to let first PSpad instance start fully and the others instances must wait for it and send their commands to the first instance.

Options: Reply | Quote | Up ^


#16 Re: load new file - not working consistently

Posted by: Gorlash | Date: 2014-11-21 15:49 | IP: IP Logged

Well, I agree (at a minimum) that it is reasonable to require that a command-line user put paths in quotes if they contain spaces; that is a standard requirement that any command-line user will be familiar with.

I was just trying to help with this, since the procedure that I used in the example will definitely work in all command-line cases. I guess that other situations, such as starting pspad from context menu, would require different handling.

Options: Reply | Quote | Up ^


#17 Re: load new file - not working consistently

Posted by: Gorlash | Date: 2014-11-27 15:23 | IP: IP Logged

Okay, this issue is resolved in build 2519.

Options: Reply | Quote | Up ^


Goto Page: Previous1 2





Editor PSPad - freeware editor, © 2001 - 2024 Jan Fiala, Hosted by Webhosting TOJEONO.CZ, design by WebDesign PAY & SOFT, code Petr Dvořák, Privacy policy and GDPR