Passing a variable to a vb script in flash

Passing a variable to a vb script in flash

Page 1 of 1

0 Replies - 640 Views - Last Post: 17 May 2009 - 03:14 PM

#1 kanui  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 16-May 09

Passing a variable to a vb script in flash

Posted 17 May 2009 - 03:14 PM

I have looked extensively online and even asked about 10 people here on the live help but nobody has the answer. The question is ...Is it possible to pass a variable from the flash projector, running on my local machine to a vb script:

Option Explicit
Dim objFSO, objFolder, objShell, objTextFile, objFile
Dim strDirectory, strFile, strText
Dim Name
Dim Gender
Dim Age
Dim Result

Name = InputBox("Enter Your First Name:")
Gender = InputBox("Enter Your Gender:")
Age = InputBox("Enter Your Age:")
Result =  "&" + "Name=" + Name + "&" + "Gender=" + Gender + "&" + "Age=" + Age

strDirectory = "C:\Program Files\YouTube Downloader and MP3 Converter"
strFile = "\userinfo.txt"
strText = Result

' Create the File System Object
Set objFSO = CreateObject("Scripting.FileSystemObject")

' Check that the strDirectory folder exists
If objFSO.FolderExists(strDirectory) Then
   Set objFolder = objFSO.GetFolder(strDirectory)
Else
   Set objFolder = objFSO.CreateFolder(strDirectory)
   WScript.Echo "Just created " & strDirectory
End If

If objFSO.FileExists(strDirectory & strFile) Then
   Set objFolder = objFSO.GetFolder(strDirectory)
Else
   Set objFile = objFSO.CreateTextFile(strDirectory & strFile)
   Wscript.Echo "Just created " & strDirectory & strFile
End If

set objFile = nothing
set objFolder = nothing
' OpenTextFile Method needs a Const value
' ForAppending = 8 ForReading = 1, ForWriting = 2
Const ForAppending = 2

Set objTextFile = objFSO.OpenTextFile _
(strDirectory & strFile, ForAppending, True)

' Writes strText every time you run this VBScript
objTextFile.WriteLine(strText)
objTextFile.Close

' Bonus or cosmetic section to launch explorer to check file
If err.number = vbEmpty then
   Set objShell = CreateObject("WScript.Shell")
   objShell.run ("Explorer" &" " & strDirectory & "\" )
Else WScript.echo "VBScript Error: " & err.number
End If

WScript.Quit

' End of VBScript to write to a file with error-correcting Code


This post has been edited by kanui: 17 May 2009 - 03:17 PM


Is This A Good Question/Topic? 0
  • +

Page 1 of 1