| View previous topic :: View next topic |
| Author |
Message |
vlcek
Joined: 19 Feb 2007 Posts: 338 Location: Czech Republic
|
Posted: Wed Aug 26, 2009 2:47 pm Post subject: parameters problem |
|
|
Good afternoon.
I want use parameters in my program example open and edit.
This code
| Code: |
if %0% = 0 ; no parameters have been passed (%0% = num of params passed)
currentfilename = Untitled
Gosub CreatePad
if %0% <> 0 ;a file has been dropped on the exe and will be passed as a parameter
{
selectedfilename = %1% ;read the file that was dropped (1st param)
gosub FileRead
}
return
createpad:
gui,show,,%currentfilename%
return
filereaD:
gui,show,,you selected %selectedfilename%
return
|
is good, but problem is when selectedfilename have a space example user want edifile my first text file.txt.
Can you edit this code?
I have some files with spaces and program can't show full file path.
Original code is from ahkpad version 1.6 _________________ Thanks. |
|
| Back to top |
|
 |
aaffe
Joined: 17 May 2007 Posts: 1002 Location: Germany - Deutschland
|
Posted: Wed Aug 26, 2009 2:54 pm Post subject: |
|
|
You could perhaps loop through the parameters:
| Code: |
if %0% = 0 ; no parameters have been passed (%0% = num of params passed)
currentfilename = Untitled
Gosub CreatePad
if %0% <> 0 ;a file has been dropped on the exe and will be passed as a parameter
{
Loop %0%
selectedfilename .=%A_INDEX% ;read the file that was dropped (1st param)
gosub FileRead
}
return
createpad:
gui,show,,%selectedfilename%
return
filereaD:
gui,show,,selected file %selectedfilename%
return
|
|
|
| Back to top |
|
 |
aaffe
Joined: 17 May 2007 Posts: 1002 Location: Germany - Deutschland
|
Posted: Wed Aug 26, 2009 2:57 pm Post subject: |
|
|
Or you run your parameters within "":
Run,yourprogram.exe "my file.txt" |
|
| Back to top |
|
 |
engunneer
Joined: 30 Aug 2005 Posts: 8255 Location: Maywood, IL
|
Posted: Wed Aug 26, 2009 3:14 pm Post subject: |
|
|
it's normal to require the user to put the input file in quotes. _________________
(Common Answers) |
|
| Back to top |
|
 |
vlcek
Joined: 19 Feb 2007 Posts: 338 Location: Czech Republic
|
Posted: Wed Aug 26, 2009 3:39 pm Post subject: |
|
|
Good work your tips are very good.
Can I set my program as default for txt files?
example
menu,options,add,associate with txt files,asociatewithtxt
asociatewithtxt
;Here will function for set an association
Msgbox, 64, info, The txt files will open in this program now.
return
Can I do this? _________________ Thanks. |
|
| Back to top |
|
 |
engunneer
Joined: 30 Aug 2005 Posts: 8255 Location: Maywood, IL
|
Posted: Wed Aug 26, 2009 3:51 pm Post subject: |
|
|
yes, but you need to research which registry key is needed. _________________
(Common Answers) |
|
| Back to top |
|
 |
|