Book a Demo

Author Topic: Passing parameters into a script.  (Read 5007 times)

neil_albiston

  • EA User
  • **
  • Posts: 26
  • Karma: +0/-0
    • View Profile
Passing parameters into a script.
« on: November 16, 2010, 02:40:59 am »
I've created a vb script to check / update the genfile attributes on our model.
The script works OK but I would like the users to be able to call it passing in a couple of string parameters.

Is it possible to pass parameters into the script ?
or have the vbscript popup a form?

I've attempted ( and failed) to work out the Session.Prompt syntax.
What values can promptType have?

Does anyone have a link to a guide that could help? Is it standard VB or an EA speciality?
Thanks,

Neil

« Last Edit: November 16, 2010, 03:47:16 am by neilalbiston »

neil_albiston

  • EA User
  • **
  • Posts: 26
  • Karma: +0/-0
    • View Profile
Re: Passing parameters into a script.
« Reply #1 on: November 16, 2010, 04:05:45 am »
Update...
Found the prompt types and realised thi sisn't the way to get input from the User.

promptOK                                    = 1
promptYESNO                                    = 2
promptYESNOCANCEL                        = 3
promptOKCANCEL                              = 4

....Still stuck. Any guidance appreciated.

mrf

  • EA User
  • **
  • Posts: 311
  • Karma: +0/-0
    • View Profile
Re: Passing parameters into a script.
« Reply #2 on: November 16, 2010, 08:44:41 am »
Hi Neil,

You can use VBScript's InputBox function to get input from a user:

Code: [Select]
function InputBox( prompt, title, default )
You can also get access to common dialogs through Microsoft's CommonDialog control. Eg:

Code: [Select]
dim openFileDialog
set openFileDialog = CreateObject("MSComDlg.CommonDialog")

openFileDialog.MaxFileSize = 260
openFileDialog.Filter = "All Files (*.*)|*.*|CSV Files (*.csv)|*.csv"
openFileDialog.FilterIndex = 2

openFileDialog.ShowOpen()
« Last Edit: November 16, 2010, 10:20:32 am by mfraser »
Best Regards,

Michael

[email protected]
"It is more complicated than you think." - RFC 1925, Section 2.8

johann

  • EA User
  • **
  • Posts: 27
  • Karma: +2/-0
    • View Profile
Re: Passing parameters into a script.
« Reply #3 on: December 10, 2010, 10:55:43 pm »
Hello Neil,

if you simply call the script on the command line and pass some parameters, maybe a "Windows Script File" (extension *.wsf) is what you need.
There, your script is wrapped into some XML tags and you can simply define run time parameters (even distinguish required parameters from optional ones)

Looks like this:

Code: [Select]
<?xml version="1.0" encoding="ISO-8859-1" ?>
<job id="main" xmlns:dt="urn:schemas-microsoft-com:datatypes">
  
  <runtime>
    <named
      name="doc"
      helpstring="path to document description file"
      type="string"
      required="true" />
  </runtime>
  
  <object id="fso" progid="Scripting.FileSystemObject" />

  <script language="VBScript"><![CDATA[

      -- here comes your script ...

In your script, access the parameter "doc" via (we use JScript):
Code: [Select]
var docs = WScript.Arguments.Named.Item('doc');
Regards
Johann