' Copyright 2002-2007.  Adobe Systems, Incorporated.  All rights reserved.
' This script executes a JavaScript. The script MosaicTiles.js is located 
' in the JavaScript folder.

Option Explicit
On Error Resume Next

Dim appRef
Dim javaScriptFile

Dim strScriptingGuide
Dim strSampleScripts
Dim strLocString
Dim strArg

Set appRef = CreateObject( "Photoshop.Application" )

appRef.BringToFront

strScriptingGuide = "$$$/ALF/Filename/ScriptingGuide=Scripting Guide"
strArg = Array(strScriptingGuide)
Call getLocString(strScriptingGuide)

strSampleScripts = "$$$/ALF/Filename/ScriptingGuide/SampleScripts=Sample Scripts"
strArg = Array(strSampleScripts)
Call getLocString(strSampleScripts)

javaScriptFile = appRef.Path & strScriptingGuide & "\" & strSampleScripts & "\JavaScript\MosaicTiles.jsx"

appRef.DoJavaScriptFile( javaScriptFile )

MsgBox "Execute JavaScript complete"

' ===============================================
' getLocString functions
' ===============================================
' on localized builds we pull the $$$/Strings from a .dat file, see documentation for more details
Function getLocString(strLocString)

	Dim objWshShell
	Dim myScriptPath
	Dim myFSO
	Dim strJSXFile

	Set objWshShell = WScript.CreateObject("WScript.Shell")
	myScriptPath = objWshShell.CurrentDirectory
	Set myFSO = CreateObject("Scripting.FileSystemObject")
	strJSXFile = myScriptPath + "\localize.jsx"

	strLocString =  appRef.DoJavaScriptFile(strJSXFile,Array(strLocString),1)

End Function
