Author Topic: Passing command line arguments within a layout [SOLVED]  (Read 8583 times)

BOXXMAN

  • Full Member
  • ***
  • Posts: 38
    • View Profile
Passing command line arguments within a layout [SOLVED]
« on: May 25, 2017, 04:15:08 PM »
How would you go about passing system and rom information as variables to a command line? For example, I am trying to use Rocketlauncher in a layout to bring up the pause menu for the current game in the display by using

fe.plugin_command("/Rocketlauncher/Rocketlauncher.exe", -s [system] -r [name] -p AttractMode -m pause");

However, if I try to pass arguments as magic tokens (which I'm assuming is wrong) in [brackets] it doesn't work. I have also tried enclosing in quotes ["name"], and "[name]", plus just about every way i can think of with or without brackets and quotes. Everything either shows up as a literal string, or crashes the layout. What is the correct way to get these parameters and pass them as arguments? The frontend itself seems to have no problem doing it when inputting the arguments to set up the emulator. Also, it would be appreciated if you could point me in the right direction how to add this of some sort of function that can be called on when one of the "custom" buttons is pressed. Thanks for any help with this. :-[
« Last Edit: July 19, 2017, 11:21:21 AM by BOXXMAN »

qqplayer

  • Sr. Member
  • ****
  • Posts: 301
    • View Profile
Re: Passing command line arguments within a layout
« Reply #1 on: June 09, 2017, 03:07:59 AM »
I´m looking for the same thing.
Sorry to say this but I think that this is a great f.e. with tons of posibilities but sometimes I feel totally lost.
Users need more "officiall" support.
The main developer doesnt answer on github...
I can´t find an updated wiki with all the f.e. options...
I know people in this forum helps a lot but you know... maybe the main developer could help us in the right way with most of our problems.

 


BOXXMAN

  • Full Member
  • ***
  • Posts: 38
    • View Profile
Re: Passing command line arguments within a layout
« Reply #2 on: June 09, 2017, 10:42:13 PM »
Yeah, I mean I like the idea of how open it is, but it's kind of a steep learning curve on some things. I could do a lot with Hyperspin using AHK scripts to run other programs that you could pass the variables of rom and system from it easily. However, I like the flexibility and to customize this fe in any way you like. I can do pretty much anything visually I want with it, but figuring out how to pass variables to any external application is aggravating. I could just figure out how to do that, it would be easy to add a manual reader, a secondary marquee display, or any other number of things into a layout that require a variable. I'm still trying to figure it out, I'll let you know if I manage to.

keilmillerjr

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1167
    • View Profile
Re: Passing command line arguments within a layout
« Reply #3 on: June 10, 2017, 03:25:51 AM »
Hyper Shlt was a pain in the @ss to try and set up. Thats why I initially switched to attract mode. Anyways…

Code: [Select]
fe.plugin_command( executable, arg_string )
The plugin command takes an argument string. Have you tried returning a function inside the string?

Not tested, but try something along these lines and let me know how you make out.

Code: [Select]
fe.plugin_command("/Rocketlauncher/Rocketlauncher.exe", "-s „ + fe.game_info(Info.System) + " -r „ + fe.game_info(Info.Name) + " -p AttractMode -m pause");

BOXXMAN

  • Full Member
  • ***
  • Posts: 38
    • View Profile
Re: Passing command line arguments within a layout
« Reply #4 on: June 10, 2017, 08:58:27 AM »
That gets me a bit closer  to results. I'm not sure how you are making those lower style closing ", and maybe that's why i'ts not working. As it is, I used "" to enclose everything, and it does partially pass the name now, but still with problems. For example, I tried it with Sony Playstation 2 as the system, and it outputs -sSony as the system. So, it is sending the -s as a string as well as the command line switch, and the system name is getting cut off as well. Any ideas?

keilmillerjr

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1167
    • View Profile
Re: Passing command line arguments within a layout
« Reply #5 on: June 11, 2017, 06:01:52 AM »
That gets me a bit closer  to results. I'm not sure how you are making those lower style closing ", and maybe that's why i'ts not working. As it is, I used "" to enclose everything, and it does partially pass the name now, but still with problems. For example, I tried it with Sony Playstation 2 as the system, and it outputs -sSony as the system. So, it is sending the -s as a string as well as the command line switch, and the system name is getting cut off as well. Any ideas?

Typing in safari on my Mac automatically reverses ending quotes. That's why I said to do something like that. I just moved this week and haven't even fully unpacked. Make sure you include a space after and before your param flags. As far as the system name being short, try printing it to terminal and see if it yields the same or different result.

BOXXMAN

  • Full Member
  • ***
  • Posts: 38
    • View Profile
Re: Passing command line arguments within a layout
« Reply #6 on: June 11, 2017, 11:53:22 AM »
That gets me a bit closer  to results. I'm not sure how you are making those lower style closing ", and maybe that's why i'ts not working. As it is, I used "" to enclose everything, and it does partially pass the name now, but still with problems. For example, I tried it with Sony Playstation 2 as the system, and it outputs -sSony as the system. So, it is sending the -s as a string as well as the command line switch, and the system name is getting cut off as well. Any ideas?

Typing in safari on my Mac automatically reverses ending quotes. That's why I said to do something like that. I just moved this week and haven't even fully unpacked. Make sure you include a space after and before your param flags. As far as the system name being short, try printing it to terminal and see if it yields the same or different result.

So, adding the spaces before and after the param flags did the trick as far as it passing. However, the problem is that it seems to cut off the system if it is more than one word, eg. Sony Playstation only sends Sony. I confirmed this, because it will work with mame, or other one name systems. There still seems to be a problem with the rom parameter though, as it doesn't seem to be sending anything. Would I need to wrap the (Info.System) command in quotes to stop it from cutting it off? Wait, I did get system and rom to pass properly now with one word names. It worked with "Colecovision" and "Evolution", as system and rom. So, the only problem now is figuring out how to get it to send names with spaces without cutting them off.
« Last Edit: June 11, 2017, 12:08:35 PM by BOXXMAN »

BOXXMAN

  • Full Member
  • ***
  • Posts: 38
    • View Profile
Re: Passing command line arguments within a layout
« Reply #7 on: June 18, 2017, 09:01:32 AM »
I'll ask again if there's anyone who can help me figure this out. All I need to know is how to pass the full string without it cutting it off at the space. Thanks in advance for any help.

BOXXMAN

  • Full Member
  • ***
  • Posts: 38
    • View Profile
Re: Passing command line arguments within a layout [SOLVED]
« Reply #8 on: July 19, 2017, 11:47:17 AM »
Hyper Shlt was a pain in the @ss to try and set up. Thats why I initially switched to attract mode. Anyways…

Code: [Select]
fe.plugin_command( executable, arg_string )
The plugin command takes an argument string. Have you tried returning a function inside the string?

Not tested, but try something along these lines and let me know how you make out.

Code: [Select]
fe.plugin_command("/Rocketlauncher/Rocketlauncher.exe", "-s „ + fe.game_info(Info.System) + " -r „ + fe.game_info(Info.Name) + " -p AttractMode -m pause");

Ok, for what it's worth and if anyone else has struggled with this and cares, here's how I finally got this working on Windows. You have to use "\"" to enclose arguments with spaces and send the quotes as well. For example,
Code: [Select]
"\"" + fe.game_info(Info.System) + "\"" This will send system name with spaces wrapped in quotes to your command line. However, if using a literal string, it has to be wrapped in quotes inside of that, such as
Code: [Select]
"\"" + "Sega Genesis" + "\""This will output literal with space and wrap it in quotes.
Each argument can be sent as a single terminated argument like this, and switches that are a single letter or word can be enclosed in single quotes such as "-s" for example
Forward slashes must also be used for escaping the quotes, as back slashes are interpreted as path delineators and won't work properly.
« Last Edit: July 19, 2017, 11:50:51 AM by BOXXMAN »

keilmillerjr

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1167
    • View Profile
Re: Passing command line arguments within a layout [SOLVED]
« Reply #9 on: July 19, 2017, 05:09:09 PM »
Ahhhh... I didn't know that you were trying to include quotes in the Params. Glad it's up and working! :)

qqplayer

  • Sr. Member
  • ****
  • Posts: 301
    • View Profile
Re: Passing command line arguments within a layout [SOLVED]
« Reply #10 on: August 23, 2017, 02:56:18 PM »
Please BOXXMAN paste the  complete working code an explain it a bit.
I´m looking for this and cant make it work.