Working with script arguments

Doubts, help and support about QuickBMS and other game research tools
HenryEx
Posts: 27
Joined: Wed Aug 13, 2014 6:43 pm

Working with script arguments

Post by HenryEx »

Hey, it's me again. I discovered the network functionality of QuickBMS and am using it to write a script to download Monster Hunter quests from Capcom's servers, which is usually only available via PSP. :)

I worked around my network inexperience and issues saving files to disk without using the print method in quickbms.txt. But i'll need the user to pass at least two arguments to the script: the file path to download and the 'game' region.
And apparently i have no clue how to get QuickBMS to accept more than one script argument.

I tried this one:

Code: Select all

quickbms.exe -G -n -a QUEST/m60038.mib MHP2G_EU DownloadScript.bms "" ""
This results in "Error: wrong command-line argument (MHP2G_EU)".

And this one:

Code: Select all

quickbms.exe -G -n -a QUEST/m60038.mib -a MHP2G_EU DownloadScript.bms "" ""
This seems to just overwrite the file in the 1st argument and quickbms_arg1 ends up being MHP2G_EU.


Aside from that: What's a good way to check in-script if an argument was passed? What's the initial value of an argument? This doesn't seem to work:

Code: Select all

if quickbms_arg1 == ""
  Exit
endif




edit: I have a lot of questions, apparently! I mentioned doing this for downloading. Currently working on parsing the response header and reached implementing Chunked transfer coding. So there's a line before the chunks, indicating the size of the following chunk in a hex-number in text.
If i get it via "get SIZE line", how do i transfer the hex size text in SIZE into an actual hex number?
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Working with script arguments

Post by aluigi »

Apparently you must separate the parameters with a space or comma in -a, the function that handles it is the same that reads the arguments of the quickbms commands.
I'm going to fix immediately this behaviour by allowing also to specify two or more -a.
And I'm going also to add some examples or additional information.
I cannot change th original behaviour because there are scripts that use that method (*edit* I checked and some of my scripts use it as -a "arg1 \"arg2\" arg3" so I can't change it).

For checking if an argument has been passed doesn't exist a good way because the content of an uninitialized quickbms_arg1 is "quickbms_arg1", and so it's impossible to make real checks.
There are only work-arounds, for example:

Code: Select all

if quickbms_arg1 & "quickbms_arg"
    cleanexit
endif
HenryEx
Posts: 27
Joined: Wed Aug 13, 2014 6:43 pm

Re: Working with script arguments

Post by HenryEx »

Ah okay, comma-separated arguments work.

But your work-around to check for uninitialized arguments doesn't seem to work. I made a quick test.bms:

Code: Select all

if quickbms_arg1 & "quickbms_arg1"
  print "No argument found: %quickbms_arg1%"
  CleanExit
else
  print "Argument passed: %quickbms_arg1%"
endif

This was the result:
Image

Apparently it triggers even if an argument is actually passed.


Edit:

OKAY, nevermind. I missed a single character, again. That's pretty clever, checking for most of the string but not all, and works like a charm. I'm still kind of puzzled by the behavior above, but at least i can pretty reliably check for arguments now. :)
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Working with script arguments

Post by aluigi »

The behaviour of 'if quickbms_arg1 & "quickbms_arg1"' is caused by how quickbms handles variables and strings, almost everything you write in the commands is considered a variable but they have no content because the content is assigned at runtime.

Take the following command:
set VAR string "hello"

It creates 2 variables without content:
  • VAR
  • hello
Then at runtime "hello" will be the content of VAR.

Yeah this is not smart as python or javascript :)
But it makes the work.