1 Reply Latest reply on Mar 23, 2015 8:55 AM by nicolaik

    "Translate" VBScript to AppleScript

    Vamitul Level 4

      Hi all.

      I am trying to convert the vbs that i am using in my sublimeText to Indesign plugin to work with AppleScript, but since i never used AppleScript before i'm having a bit of a hard time.

      The vb script is:

      myScript = Wscript.Arguments.Item(0)
      myPort = WScript.Arguments.Item(1)
      myVer = WScript.Arguments.Item(2)
      Set myInDesign = CreateObject("InDesign.Application"&myVer)
      Set myFileSystemObject = CreateObject("Scripting.FileSystemObject")
      Set myFile = myFileSystemObject.GetFile(myScript) 
      Set objShell = CreateObject("Wscript.Shell")
      strPath = Wscript.ScriptFullName
      Set objFile = myFileSystemObject.GetFile(strPath)
      strFolder = myFileSystemObject.GetParentFolderName(objFile) 
      runFile = myFileSystemObject.GetFile(strFolder & "/jsRunner.jsx")
      On Error Resume Next
      Dim r
      r = myInDesign.DoScript(runFile, 1246973031, Array(myFile,myPort))
      If Err.Number<>0 Then
        WScript.Echo "___"
        WScript.Echo  Err.Description
        WScript.Echo  Err.Number
      End IF
      

       

      It takes three comand line arguments: Script to run, Port on withc to communicate back to Sublime and the version of indesign to run

      How can i pass command line parameters to AS?

        • 1. Re: "Translate" VBScript to AppleScript
          nicolaik Level 1

          try to add on run clause at the beginning of your script:

           

            on run mPparameter
                set myScript to item 1 of mPparameter
                set myPort to item 2 of mPparameter
                set myVer to item 3 of mPparameter
            end run
          

          call the script from command line:

           

          osascript myscript.scpt param1 param2 param3