Talk:RunBatchScript

From the Oblivion ConstructionSet Wiki
Jump to navigation Jump to search

The Notes section is incorrect as far as I can tell. RunBatchScript creates a temporary script object which knows nothing about the script from which the function was called. With the following batch script in a file:

set myVar to 1
messageBox "Press a button" "zero" "one" "two"

And the following script:

short button
short myVar
short test

if (test == 1)  ; set through console for testing
  runBatchScript "test.txt"
  set test to 2
endif

if (test == 2)
  if (myVar)
    PrintC "MyVar != 0"
  endif
  set button to getButtonPressed
  if (button > -1)
    PrintC "Button pressed"
    set test to 0
  endif
endif

The variable remains zero and button presses are not recognized by the calling script.

Ha, ha! I have tricked you, and now you must fix the page! Ok, a normal response - yeah, I was going off some memories of Jaga's work with it. It was one step better than the "Works exactly like the console function", as there are no notes for the console function either.
Seems that it does make it's own object, then. I guess the last important question - does it run through the lines immediately like a result script, or not until later?
--Haama 00:18, 25 November 2007 (EST)
Yes, everything in the batch script runs before control passes back to the calling script. I'll update the article. Scruggs 09:22, 25 November 2007 (EST)

Robustness?[edit source]

I played around with this function and noticed the following: 1) If the script-file doesn't exist, there aren't any crashes (but no warnings either) 2) If there is an error in the script-file, the file is run, but there is no crash Is this by design or have I just been lucky? If by design, I would suggest that these points are added to the description (under notes). Also, does this function correspond to the console command bat? --Zumbs 13:46, 14 June 2008 (EDT)

When you use the console, Oblivion passes your input to its Script::CompileAndRun function which parses and executes the input. RunBatchScript does essentially the same thing, taking input one line at a time from the text file and passing each line to CompileAndRun(). If there is an error in one line of the batch file, we just continue on to the next line. An error in the script file has the same chance of crashing the game as a typing error in the console (i.e. very little).
I don't see a "bat" function on the console command page, although there are some special console functions (like UseWorkbook) that aren't defined like normal script/console commands. RunBatchScript doesn't call that command but the behavior might be similar. What does that command do? Scruggs 00:06, 21 June 2008 (EDT)

Batch???[edit source]

I'm a bit confused. I tried to use this function but it doesn't work. So my question is: Does RunBatchScript use .bat files or just another Oblivion script? Sebb 19:35, 10 September 2008 (CEST)

From Scruggs: "It doesn't care about the extension, it just expects a plain text file." It runs Oblivion scripts written in external text files, as if you were to type each line into the console.
Dragoon Wraith TALK 15:49, 10 September 2008 (EDT)
So this is not a function to run a .bat script as an external program? (because that's what I want to do) Or is there another possibility to do that?
Sebb 22:38, 10 September 2008 (CEST)
No, that's not what it does.
What's your plan here? There are several options. The best, I would guess (without knowing exactly what you're doing), would be to write an OBSE Plug-In. But that depends on what you want to do.
Dragoon Wraith TALK 16:53, 10 September 2008 (EDT)
I know that this doesn't really belong here but to answer the question: I need to copy a .ini file from the My Games\Oblivion\Pluggy\User Files folder to another folder on my computer and I couldn't find a command or function that can handle this in a Oblivion script. So I thought I could use an external file like a .bat file, but know that I know that it doesn't work like this, I wonder if there is another way to solve the propblem?!
Sebb 23:39, 10 September 2008 (CEST)
I'm going to continue this on your Talk page since it has gotten off-topic. I'm going to leave what's already here for the sake of anyone who ends up here with a similar question.
Dragoon Wraith TALK 19:57, 10 September 2008 (EDT)