[PLUGIN]Command Line

Completed plugins, behaviors and effects.

Post » Sun Sep 11, 2011 5:08 am

[QUOTE=QuaziGNRLnose] you would need to run your program through CMD to get any use from this right? i'm just intrigued as to when exactly you would use this! any clarification would be great.[/QUOTE]

The most common use I see for this is being able to set file type associations with a program you make in Construct. Your program will open with the path to the file you clicked in it's arguments regardless, but without this plugin, you couldn't really make any use of it. Your program would execute without any idea of the file you tried to open.

You could also set a few extra option when running from, yes, a command prompt or from editing the path of a shortcut.
B
3
S
1
G
2
Posts: 57
Reputation: 964

Post » Tue Oct 04, 2011 10:48 am

[QUOTE=linkman2004]
Execute file - Allows you to execute an external program and supply it a set of command line arguments. Arguments are separated using Microsoft Windows standards.
[/QUOTE]
What do I actually use for the separator?

Eg. what do I replace separator with in the following expression:
global('CurrentPath') separator global('CurrentNewPath')

I am executing a batch file and passing the globals as two arguments, as %1 and %2. It works fine using & as a separator if there are no spaces in the path names, but truncates to the first space where they exist.

Thanks for any help.Khalan2011-10-04 10:49:13
B
9
S
2
G
3
Posts: 75
Reputation: 1,964

Post » Tue Oct 04, 2011 4:43 pm

Try to replace the space with - & nbsp; (erase the space after the ampersand)
Just a guess.

edit- what's the code for including a code in a post? I've tried [code][/code] but it still takes it as a space.Noga2011-10-04 16:50:14
ImageImage
B
25
S
6
G
8
Posts: 773
Reputation: 6,643

Post » Tue Oct 04, 2011 9:25 pm

It's been a long time since I made this, so I'm not quite sure, but if you have spaces in an argument, I'm pretty sure you have to enclose it with double quotation marks.

If that doesn't work, send a CAP my way and I'll help you work it out from there.
Moderator
B
98
S
37
G
19
Posts: 1,584
Reputation: 17,817

Post » Wed Oct 05, 2011 12:26 am

Here's the cap:
http://dl.dropbox.com/u/22858108/SteamLink.cap

It also requires the following file in the same directory to run:
http://dl.dropbox.com/u/22858108/SteamLink.bat

I wrote this little program for myself to move my selected steam games to a new location and automatically create a junction link to that location in the steam directory (in order to make more space on my Steam drive). It works fine if there are no spaces in the path names. If there is a space, it cuts everything off after it in the argument that's passed to the bat file.

Eg. These are two arguments that are passed via CommandLine as:
global('CurrentSteamPath') &" "& global('CurrentLinkPath'):
1st path: E:\Steam\steamapps\common\Deus Ex
2nd path: L:\SteamVault\

If I print the two globals they show the full correct path. However when the batch file executes it creates a junctioned link between:
E:\Steam\steamapps\common\Deus and L:\SteamVault\Ex, when it should be between:
E:\Steam\steamapps\common\Deus Ex and L:\SteamVault\Deus Ex.

These are the contents of the bat file:
@ echo off
mklink /J "%1" "%2"
pause

Thanks for the help!Khalan2011-10-05 01:47:06
B
9
S
2
G
3
Posts: 75
Reputation: 1,964

Post » Wed Oct 05, 2011 3:30 am

You need to be enclosing your arguments in quotation marks when they contain spaces. In that case, your command line expression in event 12 should look like this:

"""" & global('CurrentSteamPath') &""" """ & global('CurrentLinkPath') & """"

And this is what your batch file should look like:

@ echo off
mklink /J %1 %2
pause

As a note, to display a quotation mark in a string, you need to use two of them so that Construct knows you just want to display one, rather than end the string(this is an escape character). This is why there are, like, a billion quotation marks in the above expression.

I hope this helps. :)linkman20042011-10-05 03:31:41
Moderator
B
98
S
37
G
19
Posts: 1,584
Reputation: 17,817

Post » Wed Oct 05, 2011 4:57 am

Ah, I had tried something similar but I must have gotten the syntax wrong. Thanks very much for your help, it works great now.
B
9
S
2
G
3
Posts: 75
Reputation: 1,964

Previous

Return to Completed addons

Who is online

Users browsing this forum: No registered users and 0 guests