VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form ScriptMaker 
   Caption         =   "Script Maker - Untitled"
   ClientHeight    =   6135
   ClientLeft      =   3945
   ClientTop       =   3780
   ClientWidth     =   8535
   Icon            =   "scriptmaker.frx":0000
   LinkTopic       =   "Form1"
   ScaleHeight     =   6135
   ScaleWidth      =   8535
   Begin VB.TextBox Script 
      Height          =   6135
      Left            =   0
      MultiLine       =   -1  'True
      ScrollBars      =   3  'Both
      TabIndex        =   0
      Top             =   0
      Width           =   8535
   End
   Begin VB.Timer Timer1 
      Interval        =   100
      Left            =   0
      Top             =   0
   End
   Begin MSComDlg.CommonDialog CommonDialog1 
      Left            =   8520
      Top             =   4560
      _ExtentX        =   847
      _ExtentY        =   847
      _Version        =   393216
   End
   Begin MSComDlg.CommonDialog CommonDialog2 
      Left            =   0
      Top             =   600
      _ExtentX        =   847
      _ExtentY        =   847
      _Version        =   393216
   End
   Begin VB.Menu mnuFile 
      Caption         =   "&File"
      Begin VB.Menu mnuFileNew 
         Caption         =   "&New Script"
         Shortcut        =   ^N
      End
      Begin VB.Menu mnuFileLoad 
         Caption         =   "&Load Script"
         Shortcut        =   ^L
      End
      Begin VB.Menu mnuFileSave 
         Caption         =   "&Save Script"
         Shortcut        =   ^S
      End
      Begin VB.Menu mnuFileSaveAs 
         Caption         =   "Save Script &As..."
      End
      Begin VB.Menu mnuFileSaveEncrypted 
         Caption         =   "Save &Encrypted Script..."
         Shortcut        =   ^E
      End
      Begin VB.Menu mnuFileSpace1 
         Caption         =   "-"
      End
      Begin VB.Menu mnuFileConvert 
         Caption         =   "Convert text to script..."
      End
      Begin VB.Menu mnuFileSpace2 
         Caption         =   "-"
      End
      Begin VB.Menu mnuFileExit 
         Caption         =   "E&xit"
      End
   End
   Begin VB.Menu mnuEdit 
      Caption         =   "&Edit"
      Begin VB.Menu mnuEditCut 
         Caption         =   "Cu&t"
         Shortcut        =   ^X
      End
      Begin VB.Menu mnuEditCopy 
         Caption         =   "&Copy"
         Shortcut        =   ^C
      End
      Begin VB.Menu mnuEditPaste 
         Caption         =   "&Paste"
         Shortcut        =   ^V
      End
      Begin VB.Menu mnuEditDel 
         Caption         =   "&Delete"
      End
      Begin VB.Menu mnuEditSpace1 
         Caption         =   "-"
      End
      Begin VB.Menu mnuEditFind 
         Caption         =   "&Find and Replace..."
         Shortcut        =   ^F
      End
      Begin VB.Menu mnuEditFindNext 
         Caption         =   "Find &Next"
         Enabled         =   0   'False
         Shortcut        =   {F3}
      End
      Begin VB.Menu mnuEditSpace2 
         Caption         =   "-"
      End
      Begin VB.Menu mnuEditSelectAll 
         Caption         =   "&Select All"
         Shortcut        =   ^A
      End
   End
   Begin VB.Menu mnuInsert 
      Caption         =   "&Insert"
      Begin VB.Menu mnuInsertCmd 
         Caption         =   "&Command"
         Begin VB.Menu mnuCommandAudio 
            Caption         =   "Audio..."
            Begin VB.Menu cmdBackBal 
               Caption         =   "BackBal"
            End
            Begin VB.Menu cmdBackRate 
               Caption         =   "BackRate"
            End
            Begin VB.Menu cmdBackFile 
               Caption         =   "BackFile"
            End
            Begin VB.Menu cmdBackVol 
               Caption         =   "BackVol"
            End
            Begin VB.Menu cmdBeep 
               Caption         =   "Beep"
            End
            Begin VB.Menu cmdCustBal 
               Caption         =   "CustBal"
            End
            Begin VB.Menu cmdCustFile 
               Caption         =   "CustFile"
            End
            Begin VB.Menu cmdCustRate 
               Caption         =   "CustRate"
            End
            Begin VB.Menu cmdCustVol 
               Caption         =   "CustVol"
            End
            Begin VB.Menu cmdMaskVol 
               Caption         =   "MaskVol"
            End
            Begin VB.Menu cmdSound 
               Caption         =   "Sound"
            End
            Begin VB.Menu cmdToneFreq 
               Caption         =   "ToneFreq"
            End
            Begin VB.Menu cmdToneVol 
               Caption         =   "ToneVol"
            End
         End
         Begin VB.Menu mnuCommandGraphics 
            Caption         =   "Graphics..."
            Begin VB.Menu cmdAnim 
               Caption         =   "Anim"
            End
            Begin VB.Menu cmdCharCenter 
               Caption         =   "CharCenter"
            End
            Begin VB.Menu cmdCharH 
               Caption         =   "CharH"
            End
            Begin VB.Menu cmdCharV 
               Caption         =   "CharV"
            End
            Begin VB.Menu cmdCharZoom 
               Caption         =   "CharZoom"
            End
            Begin VB.Menu cmdFlasherS 
               Caption         =   "Flashers"
               Begin VB.Menu cmdFlashersSize 
                  Caption         =   "Change Size"
               End
               Begin VB.Menu cmdFlashersOn 
                  Caption         =   "On"
               End
               Begin VB.Menu cmdFlashersOff 
                  Caption         =   "Off"
               End
               Begin VB.Menu cmdFlashersStop 
                  Caption         =   "Stop"
               End
            End
            Begin VB.Menu cmdFlasherShape 
               Caption         =   "FlasherShape"
            End
            Begin VB.Menu cmdShowImage 
               Caption         =   "ShowImage"
            End
            Begin VB.Menu cmdSubCycleTime 
               Caption         =   "SubCycleTime"
            End
            Begin VB.Menu cmdSubCycles 
               Caption         =   "SubCycles"
            End
            Begin VB.Menu cmdSubDuration 
               Caption         =   "SubDuration"
            End
            Begin VB.Menu cmdVidBal 
               Caption         =   "VidBal"
            End
            Begin VB.Menu cmdVidFile 
               Caption         =   "VidFile"
            End
            Begin VB.Menu cmdVidRate 
               Caption         =   "VidRate"
            End
            Begin VB.Menu cmdVidVol 
               Caption         =   "VidVol"
            End
            Begin VB.Menu cmdVidZoom 
               Caption         =   "VidZoom"
            End
            Begin VB.Menu cmdVisZoom 
               Caption         =   "VisZoom"
            End
         End
         Begin VB.Menu mnuCommandGeneral 
            Caption         =   "General..."
            Begin VB.Menu cmdEnd 
               Caption         =   "End"
            End
            Begin VB.Menu cmdExit 
               Caption         =   "Exit"
            End
            Begin VB.Menu cmdGoto 
               Caption         =   "Goto"
            End
            Begin VB.Menu cmdGotoLabel 
               Caption         =   "GotoLabel"
            End
            Begin VB.Menu cmdPause 
               Caption         =   "Pause"
            End
            Begin VB.Menu cmdSpeak 
               Caption         =   "Speak"
            End
            Begin VB.Menu cmdStop 
               Caption         =   "Stop"
            End
         End
         Begin VB.Menu mnuCommandInput 
            Caption         =   "Input..."
            Begin VB.Menu cmdGetKey 
               Caption         =   "GetKey"
            End
            Begin VB.Menu cmdGetText 
               Caption         =   "GetText"
            End
            Begin VB.Menu cmdGetVoice 
               Caption         =   "GetVoice"
            End
            Begin VB.Menu cmdKeyBuffer 
               Caption         =   "KeyBuffer"
            End
            Begin VB.Menu cmdVoiceBuffer 
               Caption         =   "VoiceBuffer"
            End
            Begin VB.Menu cmdYesNo 
               Caption         =   "YesNo"
            End
            Begin VB.Menu cmdWatchKey 
               Caption         =   "WatchKey"
            End
         End
         Begin VB.Menu mnuCommandScripts 
            Caption         =   "Scripts..."
            Begin VB.Menu cmdCall 
               Caption         =   "Call"
            End
            Begin VB.Menu cmdLoad 
               Caption         =   "Load"
            End
            Begin VB.Menu cmdLoadCall 
               Caption         =   "LoadCall"
            End
            Begin VB.Menu cmdLoadRun 
               Caption         =   "LoadRun"
            End
            Begin VB.Menu cmdRun 
               Caption         =   "Run"
            End
         End
         Begin VB.Menu mnuCommandVariables 
            Caption         =   "Data..."
            Begin VB.Menu cmdAbs 
               Caption         =   "Abs"
            End
            Begin VB.Menu cmdChangeAge 
               Caption         =   "Change Age"
            End
            Begin VB.Menu cmdChangeName 
               Caption         =   "Change Name"
            End
            Begin VB.Menu cmdChangeGender 
               Caption         =   "Change Gender"
            End
            Begin VB.Menu cmdChangeTrigger 
               Caption         =   "Change Trigger"
            End
            Begin VB.Menu cmdFormat 
               Caption         =   "Format"
            End
            Begin VB.Menu cmdIf 
               Caption         =   "If"
            End
            Begin VB.Menu cmdLoadVars 
               Caption         =   "LoadVars"
               Begin VB.Menu cmdLoadVarsAll 
                  Caption         =   "All"
               End
               Begin VB.Menu cmdLoadVarsSelected 
                  Caption         =   "Selected"
               End
            End
            Begin VB.Menu cmdPrint 
               Caption         =   "Print"
            End
            Begin VB.Menu cmdSaveVars 
               Caption         =   "SaveVars"
               Begin VB.Menu cmdSaveVarsAll 
                  Caption         =   "All"
               End
               Begin VB.Menu cmdSaveVarsSelected 
                  Caption         =   "Selected"
               End
            End
            Begin VB.Menu cmdSet 
               Caption         =   "Set"
            End
         End
         Begin VB.Menu mnuCommandStatus 
            Caption         =   "Status..."
            Begin VB.Menu cmdBackStat 
               Caption         =   "BackStat"
               Begin VB.Menu cmdBackLoop 
                  Caption         =   "Loop"
               End
               Begin VB.Menu cmdBackPause 
                  Caption         =   "Pause"
               End
               Begin VB.Menu cmdBackPlay 
                  Caption         =   "Play"
               End
            End
            Begin VB.Menu cmdCustStat 
               Caption         =   "CustStat"
               Begin VB.Menu cmdCustLoop 
                  Caption         =   "Loop"
               End
               Begin VB.Menu cmdCustPause 
                  Caption         =   "Pause"
               End
               Begin VB.Menu cmdCustPlay 
                  Caption         =   "Play"
               End
            End
            Begin VB.Menu cmdVidStat 
               Caption         =   "VidStat"
               Begin VB.Menu cmdVidLoop 
                  Caption         =   "Loop"
               End
               Begin VB.Menu cmdVidPause 
                  Caption         =   "Pause"
               End
               Begin VB.Menu cmdVidShow 
                  Caption         =   "Show"
               End
               Begin VB.Menu cmdVidHide 
                  Caption         =   "Hide"
               End
               Begin VB.Menu cmdVidPlay 
                  Caption         =   "Play"
               End
            End
            Begin VB.Menu cmdSubOn 
               Caption         =   "SubOn"
               Begin VB.Menu cmdSubOn1 
                  Caption         =   "Popup Subliminals"
               End
               Begin VB.Menu cmdSubOn2 
                  Caption         =   "Phrase Flashers"
               End
            End
            Begin VB.Menu cmdSubOff 
               Caption         =   "SubOff"
               Begin VB.Menu cmdSubOff1 
                  Caption         =   "Popup Subliminals"
               End
               Begin VB.Menu cmdSubOff2 
                  Caption         =   "Phrase Flashers"
               End
            End
         End
      End
      Begin VB.Menu mnuInsertSpeech 
         Caption         =   "&Speech Modifier"
         Begin VB.Menu cmdSpeechContext 
            Caption         =   "Context"
            Begin VB.Menu cmdSpeechAddress 
               Caption         =   "Address"
            End
            Begin VB.Menu cmdSpeechEmail 
               Caption         =   "Email"
            End
            Begin VB.Menu cmdSpeechUnknown 
               Caption         =   "Unknown (default)"
            End
         End
         Begin VB.Menu cmdSpeechEmp 
            Caption         =   "Emphasis"
         End
         Begin VB.Menu cmdSpeechPau 
            Caption         =   "Pause"
         End
         Begin VB.Menu cmdSpeechPit 
            Caption         =   "Pitch"
         End
         Begin VB.Menu cmdSpeechRepeat 
            Caption         =   "Repeat Last"
         End
         Begin VB.Menu cmdSpeechReset 
            Caption         =   "Reset"
         End
         Begin VB.Menu cmdSpeechSpeed 
            Caption         =   "Speed"
         End
         Begin VB.Menu cmdSpeechType 
            Caption         =   "Type"
            Begin VB.Menu cmdSpeechNormal 
               Caption         =   "Normal"
            End
            Begin VB.Menu cmdSpeechMonotone 
               Caption         =   "Monotone"
            End
            Begin VB.Menu cmdSpeechWhisper 
               Caption         =   "Whisper"
            End
         End
         Begin VB.Menu cmdSpeechVol 
            Caption         =   "Volume"
         End
      End
      Begin VB.Menu mnuInsertSpeechTone 
         Caption         =   "Speech Tone (SAPI4)"
         Enabled         =   0   'False
         Visible         =   0   'False
      End
      Begin VB.Menu mnuInsertVariable 
         Caption         =   "&Variable"
         Begin VB.Menu mnuVarInsert 
            Caption         =   "User variable"
         End
         Begin VB.Menu mnuInsertName 
            Caption         =   "Name variable"
         End
         Begin VB.Menu mnuInsertAge 
            Caption         =   "Age variable"
         End
         Begin VB.Menu mnuInsertGender 
            Caption         =   "Gender variable"
         End
         Begin VB.Menu mnuInsertTrigger 
            Caption         =   "Trigger variable"
         End
         Begin VB.Menu mnuInsertKeyVar 
            Caption         =   "Key variable"
         End
         Begin VB.Menu mnuInsertYesNo 
            Caption         =   "YesNo variable"
         End
         Begin VB.Menu mnuInsertTextVar 
            Caption         =   "Text variable"
         End
         Begin VB.Menu mnuInsertVoiceVar 
            Caption         =   "Voice variable"
         End
         Begin VB.Menu mnuInsertKeyPressedVar 
            Caption         =   "KeyPressed variable"
         End
         Begin VB.Menu mnuInsertSpeechVar 
            Caption         =   "Speech variable"
         End
         Begin VB.Menu mnuInsertSpeechRecVar 
            Caption         =   "SpeechRec variable"
         End
         Begin VB.Menu mnuInsertBackAudioVar 
            Caption         =   "Background Audio..."
            Begin VB.Menu mnuInsertBackDuration 
               Caption         =   "BackDuration variable"
            End
            Begin VB.Menu mnuInsertBackPosition 
               Caption         =   "BackPosition variable"
            End
            Begin VB.Menu mnuInsertBackVol 
               Caption         =   "BackVol variable"
            End
            Begin VB.Menu mnuInsertBackBal 
               Caption         =   "BackBal variable"
            End
            Begin VB.Menu mnuInsertBackRate 
               Caption         =   "BackRate variable"
            End
            Begin VB.Menu mnuInsertBackFile 
               Caption         =   "BackFile variable"
            End
         End
         Begin VB.Menu mnuInsertCustomAudioVar 
            Caption         =   "Custom Audio..."
            Begin VB.Menu mnuInsertCustDuration 
               Caption         =   "CustDuration variable"
            End
            Begin VB.Menu mnuInsertCustPosition 
               Caption         =   "CustPosition variable"
            End
            Begin VB.Menu mnuInsertCustVol 
               Caption         =   "CustVol variable"
            End
            Begin VB.Menu mnuInsertCustBal 
               Caption         =   "CustBal variable"
            End
            Begin VB.Menu mnuInsertCustRate 
               Caption         =   "CustRate variable"
            End
            Begin VB.Menu mnuInsertCustFile 
               Caption         =   "CustFile variable"
            End
         End
         Begin VB.Menu mnuInsertVideoVar 
            Caption         =   "Video..."
            Begin VB.Menu mnuInsertVidDuration 
               Caption         =   "VidDuration variable"
            End
            Begin VB.Menu mnuInsertVidPosition 
               Caption         =   "VidPosition variable"
            End
            Begin VB.Menu mnuInsertVidVol 
               Caption         =   "VidVol variable"
            End
            Begin VB.Menu mnuInsertVidBal 
               Caption         =   "VidBal variable"
            End
            Begin VB.Menu mnuInsertVidRate 
               Caption         =   "VidRate variable"
            End
            Begin VB.Menu mnuInsertVidFile 
               Caption         =   "VidFile variable"
            End
         End
         Begin VB.Menu mnuInsertBinauralsVar 
            Caption         =   "Binaurals..."
            Begin VB.Menu mnuInsertToneVol 
               Caption         =   "ToneVol variable"
            End
            Begin VB.Menu mnuInsertMaskVol 
               Caption         =   "MaskVol variable"
            End
            Begin VB.Menu mnuInsertToneFreq1 
               Caption         =   "ToneFreq1 variable"
            End
            Begin VB.Menu mnuInsertToneFreq2 
               Caption         =   "ToneFreq2 variable"
            End
         End
         Begin VB.Menu mnuInsertDate 
            Caption         =   "Date variable"
         End
         Begin VB.Menu mnuInsertTime 
            Caption         =   "Time variable"
         End
         Begin VB.Menu mnuInsertElapsedTime 
            Caption         =   "ElapsedTime variable"
         End
         Begin VB.Menu mnuInsertLineNum 
            Caption         =   "LineNum variable"
         End
         Begin VB.Menu mnuInsertCharName 
            Caption         =   "CharName variable"
         End
      End
      Begin VB.Menu mnuInsertMath 
         Caption         =   "Math &Operation"
      End
      Begin VB.Menu mnuCommentMark 
         Caption         =   "Comment &Marker"
      End
      Begin VB.Menu mnuGotoLabel 
         Caption         =   "Label"
      End
   End
   Begin VB.Menu mnuPreview 
      Caption         =   "&Preview"
      Begin VB.Menu mnuPreviewFull 
         Caption         =   "&Entire script"
         Shortcut        =   {F5}
      End
      Begin VB.Menu mnuPreviewSelect 
         Caption         =   "&Selected text"
         Shortcut        =   {F6}
      End
      Begin VB.Menu mnuPreviewLine 
         Caption         =   "&Current line"
         Enabled         =   0   'False
         Shortcut        =   {F7}
      End
      Begin VB.Menu mnuPreviewConsole 
         Caption         =   "Show Co&nsole"
         Shortcut        =   {F8}
      End
      Begin VB.Menu mnuPreviewSyntax 
         Caption         =   "Chec&k Syntax"
         Shortcut        =   {F9}
      End
   End
   Begin VB.Menu mnuOptions 
      Caption         =   "&Options"
      Begin VB.Menu mnuOptionsShow 
         Caption         =   "Show &Message Boxes"
         Checked         =   -1  'True
      End
      Begin VB.Menu mnuOptionsFont 
         Caption         =   "Change &Font"
      End
      Begin VB.Menu mnuOptionsBackground 
         Caption         =   "Change &Background Color"
      End
      Begin VB.Menu mnuOptionsMode 
         Caption         =   "&Preview Mode"
         Begin VB.Menu mnuPreviewConsoleMode 
            Caption         =   "&Console"
            Checked         =   -1  'True
         End
         Begin VB.Menu mnuPreviewFullMode 
            Caption         =   "&Full"
         End
      End
      Begin VB.Menu mnuOptionsOnTop 
         Caption         =   "Console on &top during session"
      End
      Begin VB.Menu mnuOptionsWav 
         Caption         =   "Output speech to &WAV file (SAPI5 only)"
      End
   End
   Begin VB.Menu mnuHelp 
      Caption         =   "&Help"
      Begin VB.Menu mnuHelpHelp 
         Caption         =   "Script Maker &Help"
         Shortcut        =   {F1}
      End
      Begin VB.Menu mnuHelpScripts 
         Caption         =   "Scripting &Guide"
         Shortcut        =   {F2}
      End
      Begin VB.Menu mnuHelpAbout 
         Caption         =   "&About Virtual Hypnotist"
      End
   End
End
Attribute VB_Name = "ScriptMaker"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'Virtual Hypnotist
'©2003-2008 FollowTheWatch Software
'http://vhypno.sourceforge.net
'http://sourceforge.net/projects/vhypno
'Contact - followthewatch55@yahoo.com

'This program is free software; you can redistribute it and/or
'modify it under the terms of the GNU General Public License
'as published by the Free Software Foundation; either version 2
'of the License, or (at your option) any later version.

'This program is distributed in the hope that it will be useful,
'but WITHOUT ANY WARRANTY; without even the implied warranty of
'MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
'GNU General Public License for more details.

'You should have received a copy of the GNU General Public License
'along with this program; if not, write to the Free Software
'Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

Option Explicit

Public TextAdd As String
Private Temp As String
Private ScriptChanged As Boolean
Private OrigScript As String
Private FileLoading As Boolean
Public txtClient As TextBox
Public Cnt As Long
Public txtSearchTerm As String
Public txtReplaceWithString As String
Public chkCaseSense As Integer
Public ShowWindow As Boolean
Public RemoteSend As Boolean
Public AppendOnly As Boolean
Private Secondfrm As Form
Public DestObject As TextBox

Private Sub addtext()
Dim SelTemp As Long
If ExceptionHandlers = True Then On Error GoTo ErrorHandler

If Cancel = True Then Cancel = False: Exit Sub

If AppendOnly = True Then
    SelTemp = DestObject.SelStart
    Call SendMessage(DestObject.hwnd, EM_REPLACESEL, 0, TextAdd)
    DestObject.SelStart = SelTemp + Len(TextAdd)
    AppendOnly = False
    Exit Sub
End If

If RemoteSend = False Then
    'Insert text at cursor position
    SelTemp = Script.SelStart
    Call SendMessage(Script.hwnd, EM_REPLACESEL, 0, TextAdd)
    Script.SetFocus
    Script.SelStart = SelTemp + Len(TextAdd)
Else
    'Send command to remote machine
    SendCommand Mid$(TextAdd, 1, InStr(1, TextAdd, vbCrLf, vbTextCompare) - 1), ClientSN
    RemoteSend = False
    cmdEnd.Enabled = True
    cmdGoto.Enabled = True
    cmdGotoLabel.Enabled = True
    cmdLoadVars.Enabled = True
    cmdSaveVars.Enabled = True
    cmdIf.Enabled = True
End If

Exit Sub
ErrorHandler:
err.Source = "Script Maker - AddText"
   Call ErrorReport("An error occurred while processing the insertion text.", vbExclamation)
End Sub

Private Sub cmdAbs_Click()
If ExceptionHandlers = True Then On Error GoTo ErrorHandler
If mnuOptionsShow.Checked = True Or RemoteSend = True Then
    Temp = Message.VHMessage(2, 1, 0, 0, 0, 0, 0, 0, 0, 0, True, False, "Enter the number or variable to calculate the absolute value, then choose a variable for the result", 0, 255)
    TextAdd = "<abs " + LTrim$(Str$(Message.MessageNumber)) + "> " + Message.MessageText + vbCrLf
End If
If mnuOptionsShow.Checked = False Then TextAdd = "<abs "
Call addtext
Exit Sub
ErrorHandler:
err.Source = "Script Maker - cmdAbs"
Call MenuErrorHandler
End Sub

Private Sub cmdAnim_Click()
If mnuOptionsShow.Checked = True Then
    frmCharAnim.InsertCmd = True
    frmCharAnim.Show
    Do While frmCharAnim.Visible = True
        DoEvents
    Loop
    frmCharAnim.InsertCmd = False
End If
If mnuOptionsShow.Checked = False Then TextAdd = "<anim> "
If TextAdd <> "" Then Call addtext
End Sub

Private Sub cmdBackRate_Click()
If ExceptionHandlers = True Then On Error GoTo ErrorHandler
If mnuOptionsShow.Checked = True Or RemoteSend = True Then TextAdd = "<backrate> " + LTrim$(Message.VHMessage(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, False, False, "Select a background audio rate by percentage of original", 1, 226)) + vbCrLf
If mnuOptionsShow.Checked = False Then TextAdd = "<backrate> "
Call addtext
Exit Sub
ErrorHandler:
err.Source = "Script Maker - cmdBackRate"
Call MenuErrorHandler
End Sub

Private Sub cmdBackBal_Click()
If ExceptionHandlers = True Then On Error GoTo ErrorHandler
If mnuOptionsShow.Checked = True Or RemoteSend = True Then TextAdd = "<backbal> " + LTrim$(Message.VHMessage(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, False, False, "Select a background audio balance value", -100, 100)) + vbCrLf
If mnuOptionsShow.Checked = False Then TextAdd = "<backbal> "
Call addtext
Exit Sub
ErrorHandler:
err.Source = "Script Maker - cmdBackBal"
Call MenuErrorHandler
End Sub

Private Sub cmdBackFile_Click()
If ExceptionHandlers = True Then On Error GoTo ErrorHandler
If mnuOptionsShow.Checked = True Or RemoteSend = True Then
    Message.RelativePath = True
    Message.FilePath = App.path + "\audio"
    Message.FileType = "Audio file (*.wav;*.snd;*.au;*.aif;*.aifc;*.aiff;*.wma;*.mp3)|*.wav;*.snd;*.au;*.aif;*.aifc;*.aiff;*.wma;*.mp3|"
    Temp = Message.VHMessage(0, 0, 0, 0, 0, 0, 0, 1, 0, 0, False, False, "Choose a background audio file or URL to load", 0, 0)
    TextAdd = "<backfile> " + Message.MessageFile + vbCrLf
End If
If mnuOptionsShow.Checked = False Then TextAdd = "<backfile> "
Call addtext
Exit Sub
ErrorHandler:
err.Source = "Script Maker - cmdBackFile"
Call MenuErrorHandler
End Sub

Private Sub cmdBackLoop_Click()
TextAdd = "<backstat> loop" + vbCrLf
Call addtext
End Sub

Private Sub cmdBackPause_Click()
TextAdd = "<backstat> pause" + vbCrLf
Call addtext
End Sub

Private Sub cmdBackPlay_Click()
TextAdd = "<backstat> play" + vbCrLf
Call addtext
End Sub

Private Sub cmdBackVol_Click()
If ExceptionHandlers = True Then On Error GoTo ErrorHandler
If mnuOptionsShow.Checked = True Or RemoteSend = True Then TextAdd = "<backvol> " + LTrim$(Message.VHMessage(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, False, False, "Select a background audio volume value", -5000, 0)) + vbCrLf
If mnuOptionsShow.Checked = False Then TextAdd = "<backvol> "
Call addtext
Exit Sub
ErrorHandler:
err.Source = "Script Maker - cmdBackVol"
Call MenuErrorHandler
End Sub

Private Sub cmdBeep_Click()
If ExceptionHandlers = True Then On Error GoTo ErrorHandler
If mnuOptionsShow.Checked = True Or RemoteSend = True Then
    Temp = Message.VHMessage(0, 1, 0, 2, 0, 0, 0, 0, 0, 0, True, False, "Enter a frequency number, then enter the duration for the tone in milliseconds", 0, 0)
    TextAdd = "<beep> " + LTrim$(Message.MessageText) + ", " + LTrim$(Message.MessageText2) + vbCrLf
End If
If mnuOptionsShow.Checked = False Then TextAdd = "<beep> "
Call addtext
Exit Sub
ErrorHandler:
err.Source = "Script Maker - cmdBeep"
Call MenuErrorHandler
End Sub

Private Sub cmdChangeAge_Click()
If ExceptionHandlers = True Then On Error GoTo ErrorHandler
If mnuOptionsShow.Checked = True Or RemoteSend = True Then
    Temp = Message.VHMessage(0, 1, 0, 0, 0, 0, 0, 0, 0, 0, True, False, "Enter the new age value", 0, 0)
    TextAdd = "<change age> " + LTrim$(Message.MessageText) + vbCrLf
End If
If mnuOptionsShow.Checked = False Then TextAdd = "<change age> "
Call addtext
Exit Sub
ErrorHandler:
err.Source = "Script Maker - cmdChangeAge"
Call MenuErrorHandler
End Sub

Private Sub cmdChangeGender_Click()
If ExceptionHandlers = True Then On Error GoTo ErrorHandler
If mnuOptionsShow.Checked = True Or RemoteSend = True Then
    Temp = Message.VHMessage(0, 1, 0, 0, 0, 0, 0, 0, 0, 0, True, False, "Enter the new gender value", 0, 0)
    TextAdd = "<change gender> " + LTrim$(Message.MessageText) + vbCrLf
End If
If mnuOptionsShow.Checked = False Then TextAdd = "<change gender> "
Call addtext
Exit Sub
ErrorHandler:
err.Source = "Script Maker - cmdChangeGender"
Call MenuErrorHandler
End Sub

Private Sub cmdChangeName_Click()
If ExceptionHandlers = True Then On Error GoTo ErrorHandler
If mnuOptionsShow.Checked = True Or RemoteSend = True Then
    Temp = Message.VHMessage(0, 1, 0, 0, 0, 0, 0, 0, 0, 0, True, False, "Enter the new name value", 0, 0)
    TextAdd = "<change name> " + LTrim$(Message.MessageText) + vbCrLf
End If
If mnuOptionsShow.Checked = False Then TextAdd = "<change name> "
Call addtext
Exit Sub
ErrorHandler:
err.Source = "Script Maker - cmdChangeName"
Call MenuErrorHandler
End Sub

Private Sub cmdChangeTrigger_Click()
If ExceptionHandlers = True Then On Error GoTo ErrorHandler
If mnuOptionsShow.Checked = True Or RemoteSend = True Then
    Temp = Message.VHMessage(0, 1, 0, 0, 0, 0, 0, 0, 0, 0, True, False, "Enter the new trigger value", 0, 0)
    TextAdd = "<change trigger> " + LTrim$(Message.MessageText) + vbCrLf
End If
If mnuOptionsShow.Checked = False Then TextAdd = "<change trigger> "
Call addtext
Exit Sub
ErrorHandler:
err.Source = "Script Maker - cmdChangeTrigger"
Call MenuErrorHandler
End Sub

Private Sub cmdCustBal_Click()
If ExceptionHandlers = True Then On Error GoTo ErrorHandler
If mnuOptionsShow.Checked = True Or RemoteSend = True Then TextAdd = "<custbal> " + LTrim$(Message.VHMessage(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, False, False, "Select a custom audio balance value", -100, 100)) + vbCrLf
If mnuOptionsShow.Checked = False Then TextAdd = "<custbal> "
Call addtext
Exit Sub
ErrorHandler:
err.Source = "Script Maker - cmdCustBal"
Call MenuErrorHandler
End Sub

Private Sub cmdCustFile_Click()
If ExceptionHandlers = True Then On Error GoTo ErrorHandler
If mnuOptionsShow.Checked = True Or RemoteSend = True Then
    Message.RelativePath = True
    Message.FilePath = App.path + "\audio"
    Message.FileType = "Audio file (*.wav;*.snd;*.au;*.aif;*.aifc;*.aiff;*.wma;*.mp3)|*.wav;*.snd;*.au;*.aif;*.aifc;*.aiff;*.wma;*.mp3|"
    Temp = Message.VHMessage(0, 0, 0, 0, 0, 0, 0, 1, 0, 0, False, False, "Choose a custom audio file or URL to load", 0, 0)
    TextAdd = "<custfile> " + Message.MessageFile + vbCrLf
End If
If mnuOptionsShow.Checked = False Then TextAdd = "<custfile> "
Call addtext
Exit Sub
ErrorHandler:
err.Source = "Script Maker - cmdCustFile"
Call MenuErrorHandler
End Sub

Private Sub cmdCustLoop_Click()
TextAdd = "<custstat> loop" + vbCrLf
Call addtext
End Sub

Private Sub cmdCustPause_Click()
TextAdd = "<custstat> pause" + vbCrLf
Call addtext
End Sub

Private Sub cmdCustPlay_Click()
TextAdd = "<custstat> play" + vbCrLf
Call addtext
End Sub

Private Sub cmdEnd_Click()
TextAdd = "<end>" + vbCrLf
Call addtext
End Sub

Private Sub cmdExit_Click()
TextAdd = "<exit>" + vbCrLf
Call addtext
End Sub

Private Sub cmdFlasherShape_Click()
If ExceptionHandlers = True Then On Error GoTo ErrorHandler
If mnuOptionsShow.Checked = True Or RemoteSend = True Then
    Temp = Message.VHMessage(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, False, False, "Select a flasher shape number", 0, 5)
    TextAdd = "<flashershape> " + LTrim$(Str$(Abs(Message.MessageNumber))) + vbCrLf
End If
If mnuOptionsShow.Checked = False Then TextAdd = "<flashershape> "
Call addtext
Exit Sub
ErrorHandler:
err.Source = "Script Maker - cmdFlasherShape"
Call MenuErrorHandler
End Sub

Private Sub cmdFlashersOff_Click()
TextAdd = "<flashers> off" + vbCrLf
Call addtext
End Sub

Private Sub cmdFlashersOn_Click()
TextAdd = "<flashers> on" + vbCrLf
Call addtext
End Sub

Private Sub cmdFlashersSize_Click()
If ExceptionHandlers = True Then On Error GoTo ErrorHandler
If mnuOptionsShow.Checked = True Or RemoteSend = True Then
    Temp = Message.VHMessage(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, False, False, "Select a relative percentage", -100, 100)
    If Message.MessageNumber < 0 Then TextAdd = "<flashers> -" + LTrim$(Str$(Abs(Message.MessageNumber))) + vbCrLf
    If Message.MessageNumber > 0 Then TextAdd = "<flashers> +" + LTrim$(Str$(Abs(Message.MessageNumber))) + vbCrLf
End If
If mnuOptionsShow.Checked = False Then TextAdd = "<flashers> "
Call addtext
Exit Sub
ErrorHandler:
err.Source = "Script Maker - cmdFlashersSize"
Call MenuErrorHandler
End Sub

Private Sub cmdFlashersStop_Click()
TextAdd = "<flashers> stop" + vbCrLf
Call addtext
End Sub

Private Sub cmdFormat_Click()
If ExceptionHandlers = True Then On Error GoTo ErrorHandler
If mnuOptionsShow.Checked = True Or RemoteSend = True Then
    Temp = Message.VHMessage(1, 2, 0, 0, 0, 0, 0, 0, 0, 0, True, False, "Choose a variable, then enter the format string", 0, 255)
    TextAdd = "<format> " + LTrim$(Str$(Message.MessageNumber)) + ", " + Message.MessageText + vbCrLf
End If
If mnuOptionsShow.Checked = False Then TextAdd = "<format> "
Call addtext
Exit Sub
ErrorHandler:
err.Source = "Script Maker - cmdFormat"
Call MenuErrorHandler
End Sub

Private Sub cmdLoadCall_Click()
If ExceptionHandlers = True Then On Error GoTo ErrorHandler
If mnuOptionsShow.Checked = True Or RemoteSend = True Then
    Message.RelativePath = True
    Message.FilePath = App.path
    Message.FileType = "Script Files (*.txt)|*.txt|"
    Temp = Message.VHMessage(0, 2, 0, 0, 0, 0, 0, 1, 0, 0, True, False, "Choose a file or URL to dynamically call, and enter a line number to go to (optional)", 0, 0)
    Message.RelativePath = False
    If Message.MessageText = "" Then TextAdd = "<loadcall> " + Message.MessageFile + vbCrLf
    If Message.MessageText <> "" Then TextAdd = "<loadcall> " + Message.MessageFile + ", " + Message.MessageText + vbCrLf
End If
If mnuOptionsShow.Checked = False Then TextAdd = "<loadcall>"
Call addtext
Exit Sub
ErrorHandler:
err.Source = "Script Maker - cmdLoadCall"
Call MenuErrorHandler
End Sub

Private Sub cmdLoadVarsAll_Click()
If ExceptionHandlers = True Then On Error GoTo ErrorHandler
If mnuOptionsShow.Checked = True Or RemoteSend = True Then
    Temp = Message.VHMessage(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, False, False, "Set to 1 if you want to overwrite all other loaded variables", 0, 1)
    If Message.MessageNumber = 0 Then
        TextAdd = "<loadvars>" + vbCrLf
    Else
        TextAdd = "<loadvars> true" + vbCrLf
    End If
End If
If mnuOptionsShow.Checked = False Then TextAdd = "<loadvars> "
Call addtext
Exit Sub
ErrorHandler:
err.Source = "Script Maker - cmdLoadVarsAll"
Call MenuErrorHandler
End Sub

Private Sub cmdLoadVarsSelected_Click()
If ExceptionHandlers = True Then On Error GoTo ErrorHandler
If mnuOptionsShow.Checked = True Or RemoteSend = True Then TextAdd = "<loadvars> " + LTrim$(Message.VHMessage(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, False, False, "Choose which variable to load", 0, 255))
If mnuOptionsShow.Checked = False Then TextAdd = "<loadvars> "
Call addtext
Exit Sub
ErrorHandler:
err.Source = "Script Maker - cmdLoadVarsSelected"
Call MenuErrorHandler
End Sub

Private Sub cmdPrint_Click()
If ExceptionHandlers = True Then On Error GoTo ErrorHandler
If mnuOptionsShow.Checked = True Or RemoteSend = True Then TextAdd = "<print> " + Message.VHMessage(0, 1, 0, 0, 0, 0, 0, 0, 0, 0, True, False, "Enter text to print to the debug console:", 0, 0) + vbCrLf
If mnuOptionsShow.Checked = False Then TextAdd = "<print> "
Call addtext
Exit Sub
ErrorHandler:
err.Source = "Script Maker - cmdPrint"
Call MenuErrorHandler
End Sub

Private Sub cmdSaveVarsAll_Click()
TextAdd = "<savevars>" + vbCrLf
Call addtext
End Sub

Private Sub cmdSaveVarsSelected_Click()
If ExceptionHandlers = True Then On Error GoTo ErrorHandler
If mnuOptionsShow.Checked = True Or RemoteSend = True Then TextAdd = "<savevars> " + LTrim$(Message.VHMessage(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, False, False, "Choose which variable to save", 0, 255))
If mnuOptionsShow.Checked = False Then TextAdd = "<savevars> "
Call addtext
Exit Sub
ErrorHandler:
err.Source = "Script Maker - cmdSaveVarsSelected"
Call MenuErrorHandler
End Sub

Private Sub cmdShowImage_Click()
If ExceptionHandlers = True Then On Error GoTo ErrorHandler
If mnuOptionsShow.Checked = True Or RemoteSend = True Then
    Message.RelativePath = True
    Message.FilePath = App.path + "\images"
    Message.FileType = "Image file (*.jpg;*.gif;*.bmp;*.wmf;*.emf;*.rle;*.ico)|*.jpg;*.gif;*.bmp;*.wmf;*.emf;*.rle;*.ico"
    Temp = Message.VHMessage(2, 0, 0, 0, 0, 0, 0, 1, 0, 0, False, False, "Choose an image file or URL to load and choose the duration (in milliseconds)", 1, 10000)
    TextAdd = "<showimage> " + Message.MessageFile + ", " + Trim2(Str$(Message.MessageNumber)) + ", 50, 50" + vbCrLf
End If
If mnuOptionsShow.Checked = False Then TextAdd = "<showimage> "
Call addtext
Exit Sub
ErrorHandler:
err.Source = "Script Maker - cmdShowImage"
Call MenuErrorHandler
End Sub

Private Sub cmdSpeechAddress_Click()
If ExceptionHandlers = True Then On Error GoTo ErrorHandler
If mnuOptionsShow.Checked = True Or RemoteSend = True Then TextAdd = "\Ctx=""Address""\" + Secondfrm.VHMessage(0, 1, 0, 0, 0, 0, 0, 0, 0, 0, False, False, "Enter an address or phone number to say", 0, 0)
If mnuOptionsShow.Checked = False Then TextAdd = "\Ctx=""Address""\"
Call addtext
Exit Sub
ErrorHandler:
err.Source = "Script Maker - cmdSpeechAddress"
Call MenuErrorHandler
End Sub

Private Sub cmdSpeechEmail_Click()
If ExceptionHandlers = True Then On Error GoTo ErrorHandler
If mnuOptionsShow.Checked = True Or RemoteSend = True Then TextAdd = "\Ctx=""Email""\" + Secondfrm.VHMessage(0, 1, 0, 0, 0, 0, 0, 0, 0, 0, False, False, "Enter an email address to say", 0, 0)
If mnuOptionsShow.Checked = False Then TextAdd = "\Ctx=""Email""\"
Call addtext
Exit Sub
ErrorHandler:
err.Source = "Script Maker - cmdSpeechEmail"
Call MenuErrorHandler
End Sub

Private Sub cmdSpeechMonotone_Click()
TextAdd = "\Chr=""Monotone""\"
Call addtext
End Sub

Private Sub cmdSpeechNormal_Click()
TextAdd = "\Chr=""Normal""\"
Call addtext
End Sub

Private Sub cmdSpeechRepeat_Click()
TextAdd = "\Lst\"
Call addtext
End Sub

Private Sub cmdSpeechReset_Click()
TextAdd = "\Rst\"
Call addtext
End Sub

Private Sub cmdSpeechUnknown_Click()
TextAdd = "\Ctx=""Unknown""\"
Call addtext
End Sub

Private Sub cmdSpeechWhisper_Click()
TextAdd = "\Chr=""Whisper""\"
Call addtext
End Sub

Private Sub cmdSubCycles_Click()
If ExceptionHandlers = True Then On Error GoTo ErrorHandler
If mnuOptionsShow.Checked = True Or RemoteSend = True Then
    Temp = Message.VHMessage(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, False, False, "Select the amount of cycles per message", 1, 100)
    TextAdd = "<subcycles> " + LTrim$(Str$(Abs(Message.MessageNumber))) + vbCrLf
End If
If mnuOptionsShow.Checked = False Then TextAdd = "<subcycles> "
Call addtext
Exit Sub
ErrorHandler:
err.Source = "Script Maker - cmdSubCycles"
Call MenuErrorHandler
End Sub

Private Sub cmdSubCycleTime_Click()
If ExceptionHandlers = True Then On Error GoTo ErrorHandler
If mnuOptionsShow.Checked = True Or RemoteSend = True Then
    Temp = Message.VHMessage(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, False, False, "Select a subliminal cycle time", 1, 2000)
    TextAdd = "<subcycletime> " + LTrim$(Str$(Abs(Message.MessageNumber))) + vbCrLf
End If
If mnuOptionsShow.Checked = False Then TextAdd = "<subcycletime> "
Call addtext
Exit Sub
ErrorHandler:
err.Source = "Script Maker - cmdSubCycleTime"
Call MenuErrorHandler
End Sub

Private Sub cmdSubDuration_Click()
If ExceptionHandlers = True Then On Error GoTo ErrorHandler
If mnuOptionsShow.Checked = True Or RemoteSend = True Then
    Temp = Message.VHMessage(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, False, False, "Select a subliminal message duration", 1, 500)
    TextAdd = "<subduration> " + LTrim$(Str$(Abs(Message.MessageNumber))) + vbCrLf
End If
If mnuOptionsShow.Checked = False Then TextAdd = "<subduration> "
Call addtext
Exit Sub
ErrorHandler:
err.Source = "Script Maker - cmdSubDuration"
Call MenuErrorHandler
End Sub

Private Sub cmdSubOff1_Click()
TextAdd = "<suboff> 1" + vbCrLf
Call addtext
End Sub

Private Sub cmdSubOff2_Click()
TextAdd = "<suboff> 2" + vbCrLf
Call addtext
End Sub

Private Sub cmdSubOn1_Click()
TextAdd = "<subon> 1" + vbCrLf
Call addtext
End Sub

Private Sub cmdSubOn2_Click()
TextAdd = "<subon> 2" + vbCrLf
Call addtext
End Sub

Private Sub cmdToneFreq_Click()
If ExceptionHandlers = True Then On Error GoTo ErrorHandler
If mnuOptionsShow.Checked = True Or RemoteSend = True Then
    Temp = Message.VHMessage(1, 2, 0, 0, 0, 0, 0, 0, 0, 0, True, False, "Choose a tone number, then enter the new frequency number for it", 1, 2)
    TextAdd = "<tonefreq " + LTrim$(Str$(Message.MessageNumber)) + "> " + Message.MessageText + vbCrLf
End If
If mnuOptionsShow.Checked = False Then TextAdd = "<tonefreq "
Call addtext
Exit Sub
ErrorHandler:
err.Source = "Script Maker - cmdToneFreq"
Call MenuErrorHandler
End Sub

Private Sub cmdCall_Click()
If ExceptionHandlers = True Then On Error GoTo ErrorHandler
If mnuOptionsShow.Checked = True Or RemoteSend = True Then
    Temp = Message.VHMessage(0, 2, 0, 0, 0, 0, 1, 0, 0, 0, True, False, "Choose a section to call, and enter a line number to go to (optional)", 0, 0)
    If Message.MessageText = "" Then TextAdd = "<call> " + LTrim$(Str$(Message.MessageSection)) + vbCrLf
    If Message.MessageText <> "" Then TextAdd = "<call> " + LTrim$(Str$(Message.MessageSection)) + ", " + LTrim$(Str$(Message.MessageText)) + vbCrLf
End If
If mnuOptionsShow.Checked = False Then TextAdd = "<call> "
Call addtext
Exit Sub
ErrorHandler:
err.Source = "Script Maker - cmdCall"
Call MenuErrorHandler
End Sub

Private Sub cmdCharCenter_Click()
TextAdd = "<charcenter>" + vbCrLf
Call addtext
End Sub

Private Sub cmdCharH_Click()
If ExceptionHandlers = True Then On Error GoTo ErrorHandler
If mnuOptionsShow.Checked = True Or RemoteSend = True Then
    Temp = Message.VHMessage(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, False, False, "Select a relative horizontal character percentage", -100, 200)
    If Message.MessageNumber < 0 Then TextAdd = "<charh> -" + LTrim$(Str$(Abs(Message.MessageNumber))) + vbCrLf
    If Message.MessageNumber > 0 Then TextAdd = "<charh> +" + LTrim$(Str$(Abs(Message.MessageNumber))) + vbCrLf
End If
If mnuOptionsShow.Checked = False Then TextAdd = "<charh> "
Call addtext
Exit Sub
ErrorHandler:
err.Source = "Script Maker - cmdCharH"
Call MenuErrorHandler
End Sub

Private Sub cmdCharV_Click()
If ExceptionHandlers = True Then On Error GoTo ErrorHandler
If mnuOptionsShow.Checked = True Or RemoteSend = True Then
    Temp = Message.VHMessage(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, False, False, "Select a relative vertical character percentage", -100, 200)
    If Message.MessageNumber < 0 Then TextAdd = "<charv> -" + LTrim$(Str$(Abs(Message.MessageNumber))) + vbCrLf
    If Message.MessageNumber > 0 Then TextAdd = "<charv> +" + LTrim$(Str$(Abs(Message.MessageNumber))) + vbCrLf
End If
If mnuOptionsShow.Checked = False Then TextAdd = "<charv> "
Call addtext
Exit Sub
ErrorHandler:
err.Source = "Script Maker - cmdCharV"
Call MenuErrorHandler
End Sub

Private Sub cmdCharZoom_Click()
If ExceptionHandlers = True Then On Error GoTo ErrorHandler
If mnuOptionsShow.Checked = True Or RemoteSend = True Then TextAdd = "<charzoom> " + LTrim$(Message.VHMessage(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, False, False, "Select a character zoom value by percentage of original", 10, 1000)) + vbCrLf
If mnuOptionsShow.Checked = False Then TextAdd = "<charzoom> "
Call addtext
Exit Sub
ErrorHandler:
err.Source = "Script Maker - cmdCharZoom"
Call MenuErrorHandler
End Sub

Private Sub cmdCustRate_Click()
If ExceptionHandlers = True Then On Error GoTo ErrorHandler
If mnuOptionsShow.Checked = True Or RemoteSend = True Then TextAdd = "<custrate> " + LTrim$(Message.VHMessage(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, False, False, "Select a custom audio rate by percentage of original", 1, 226)) + vbCrLf
If mnuOptionsShow.Checked = False Then TextAdd = "<custrate> "
Call addtext
Exit Sub
ErrorHandler:
err.Source = "Script Maker - cmdCustRate"
Call MenuErrorHandler
End Sub

Private Sub cmdCustVol_Click()
If ExceptionHandlers = True Then On Error GoTo ErrorHandler
If mnuOptionsShow.Checked = True Or RemoteSend = True Then TextAdd = "<custvol> " + LTrim$(Message.VHMessage(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, False, False, "Select a custom audio volume value", -5000, 0)) + vbCrLf
If mnuOptionsShow.Checked = False Then TextAdd = "<custvol> "
Call addtext
Exit Sub
ErrorHandler:
err.Source = "Script Maker - cmdCustVol"
Call MenuErrorHandler
End Sub

Private Sub cmdGetKey_Click()
TextAdd = "<getkey>" + vbCrLf
Call addtext
End Sub

Private Sub cmdGetText_Click()
TextAdd = "<gettext>" + vbCrLf
Call addtext
End Sub

Private Sub cmdGetVoice_Click()
TextAdd = "<getvoice>" + vbCrLf
Call addtext
End Sub

Private Sub cmdGoto_Click()
If ExceptionHandlers = True Then On Error GoTo ErrorHandler
If mnuOptionsShow.Checked = True Or RemoteSend = True Then TextAdd = "<goto> " + LTrim$(Message.VHMessage(0, 1, 0, 0, 0, 0, 0, 0, 0, 0, True, False, "Enter line number to go to", 0, 0)) + vbCrLf
If mnuOptionsShow.Checked = False Then TextAdd = "<goto> "
Call addtext
Exit Sub
ErrorHandler:
err.Source = "Script Maker - cmdGoto"
Call MenuErrorHandler
End Sub

Private Sub cmdGotoLabel_Click()
If ExceptionHandlers = True Then On Error GoTo ErrorHandler
If mnuOptionsShow.Checked = True Or RemoteSend = True Then TextAdd = "<gotolabel> " + LTrim$(Message.VHMessage(0, 1, 0, 0, 0, 0, 0, 0, 0, 0, True, False, "Enter label name to go to", 0, 0)) + vbCrLf
If mnuOptionsShow.Checked = False Then TextAdd = "<gotolabel> "
Call addtext
Exit Sub
ErrorHandler:
err.Source = "Script Maker - cmdGotoLabel"
Call MenuErrorHandler
End Sub

Private Sub cmdIf_Click()
If ExceptionHandlers = True Then On Error GoTo ErrorHandler
If mnuOptionsShow.Checked = True Or RemoteSend = True Then
    Temp = Message.VHMessage(0, 1, 2, 3, 0, 0, 0, 0, 0, 0, True, False, "Enter the value to use, choose the comparison, and enter a second value to compare with", 0, 0)
    TextAdd = "<if> " + Trim2(Message.MessageText) + " " + Message.MessageLogic + " " + Trim2(Message.MessageText2) + vbCrLf
End If
If mnuOptionsShow.Checked = False Then TextAdd = "<if> "
Call addtext
Exit Sub
ErrorHandler:
err.Source = "Script Maker - cmdIf"
Call MenuErrorHandler
End Sub

Private Sub cmdKeyBuffer_Click()
TextAdd = "<keybuffer>" + vbCrLf
Call addtext
End Sub

Private Sub cmdLoad_Click()
If ExceptionHandlers = True Then On Error GoTo ErrorHandler
If mnuOptionsShow.Checked = True Or RemoteSend = True Then
    Message.FilePath = ""
    Message.RelativePath = False
    Message.FileType = "Script Files (*.txt)|*.txt|"
    Temp = Message.VHMessage(0, 0, 0, 0, 0, 0, 1, 2, 0, 0, False, False, "Choose a section and a file or URL to load into the section", 0, 0)
    TextAdd = "<load " + LTrim$(Str$(Message.MessageSection)) + "> " + Message.MessageFile + vbCrLf
End If
If mnuOptionsShow.Checked = False Then TextAdd = "<load "
Call addtext
Exit Sub
ErrorHandler:
err.Source = "Script Maker - cmdLoad"
Call MenuErrorHandler
End Sub

Private Sub cmdLoadRun_Click()
If ExceptionHandlers = True Then On Error GoTo ErrorHandler
If mnuOptionsShow.Checked = True Or RemoteSend = True Then
    Message.FilePath = ""
    Message.RelativePath = False
    Message.FileType = "Script Files (*.txt)|*.txt|"
    Temp = Message.VHMessage(0, 3, 0, 0, 0, 0, 1, 2, 0, 0, True, False, "Choose a section to run, a file or URL to load, and enter a line number to go to (optional)", 0, 0)
    If Message.MessageText = "" Then TextAdd = "<loadrun " + LTrim$(Str$(Message.MessageSection)) + "> " + Message.MessageFile + vbCrLf
    If Message.MessageText <> "" Then TextAdd = "<loadrun " + LTrim$(Str$(Message.MessageSection)) + "> " + Message.MessageFile + ", " + Message.MessageText + vbCrLf
End If
If mnuOptionsShow.Checked = False Then TextAdd = "<loadrun "
Call addtext
Exit Sub
ErrorHandler:
err.Source = "Script Maker - cmdLoadRun"
Call MenuErrorHandler
End Sub

Private Sub cmdMaskVol_Click()
If ExceptionHandlers = True Then On Error GoTo ErrorHandler
If mnuOptionsShow.Checked = True Or RemoteSend = True Then TextAdd = "<maskvol> " + LTrim$(Message.VHMessage(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, False, False, "Select a mask volume value", -6000, 0)) + vbCrLf
If mnuOptionsShow.Checked = False Then TextAdd = "<maskvol> "
Call addtext
Exit Sub
ErrorHandler:
err.Source = "Script Maker - cmdMaskVol"
Call MenuErrorHandler
End Sub

Private Sub cmdPause_Click()
If ExceptionHandlers = True Then On Error GoTo ErrorHandler
If mnuOptionsShow.Checked = True Or RemoteSend = True Then TextAdd = "<pause> " + LTrim$(Message.VHMessage(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, False, False, "Select the amount of milliseconds to pause for", 1, 10000)) + vbCrLf
If mnuOptionsShow.Checked = False Then TextAdd = "<pause> "
Call addtext
Exit Sub
ErrorHandler:
err.Source = "Script Maker - cmdPause"
Call MenuErrorHandler
End Sub

Private Sub cmdRun_Click()
If ExceptionHandlers = True Then On Error GoTo ErrorHandler
If mnuOptionsShow.Checked = True Or RemoteSend = True Then
    Temp = Message.VHMessage(0, 2, 0, 0, 0, 0, 1, 0, 0, 0, True, False, "Choose a section to run, and enter a line number to go to (optional)", 0, 0)
    If Message.MessageText = "" Then TextAdd = "<run> " + LTrim$(Str$(Message.MessageSection)) + vbCrLf
    If Message.MessageText <> "" Then TextAdd = "<run> " + LTrim$(Str$(Message.MessageSection)) + ", " + Message.MessageText + vbCrLf
End If
If mnuOptionsShow.Checked = False Then TextAdd = "<run> "
Call addtext
Exit Sub
ErrorHandler:
err.Source = "Script Maker - cmdRun"
Call MenuErrorHandler
End Sub

Private Sub cmdSet_Click()
If ExceptionHandlers = True Then On Error GoTo ErrorHandler
If mnuOptionsShow.Checked = True Or RemoteSend = True Then
    Temp = Message.VHMessage(1, 2, 0, 0, 0, 0, 0, 0, 0, 0, True, False, "Choose a variable, then enter data to store into it", 0, 255)
    TextAdd = "<set " + LTrim$(Str$(Message.MessageNumber)) + "> " + Message.MessageText + vbCrLf
End If
If mnuOptionsShow.Checked = False Then TextAdd = "<set "
Call addtext
Exit Sub
ErrorHandler:
err.Source = "Script Maker - cmdSet"
Call MenuErrorHandler
End Sub

Private Sub cmdSound_Click()
If ExceptionHandlers = True Then On Error GoTo ErrorHandler
CommonDialog1.InitDir = App.path + "\sounds"
CommonDialog1.CancelError = True
'CommonDialog1.DefaultExt = ".mp3"
CommonDialog1.Filter = "Audio Files (*.mp3;*.wav;*.wma;*.ogg;*.mp2;*.mp1)|*.mp3;*.wav;*.wma;*.ogg;*.mp2;*.mp1|"
CommonDialog1.DialogTitle = "Choose Audio File"
CommonDialog1.action = 1
Dim SoundF As String
If InStr(1, CommonDialog1.Filename, App.path + "\sounds", vbTextCompare) > 0 Then
    SoundF = Mid$(CommonDialog1.Filename, Len(App.path + "\sounds\") + 1)
End If

TextAdd = "<sound> " + SoundF + vbCrLf
Call addtext

Exit Sub
ErrorHandler:
err.Source = "Script Maker - cmdSound"
Call MenuErrorHandler
End Sub

Private Sub cmdSpeak_Click()
If ExceptionHandlers = True Then On Error GoTo ErrorHandler
If mnuOptionsShow.Checked = True Or RemoteSend = True Then TextAdd = "<speak> " + Message.VHMessage(0, 1, 0, 0, 0, 0, 0, 0, 0, 0, True, True, "Enter text for the script to speak:", 0, 0) + vbCrLf
If mnuOptionsShow.Checked = False Then TextAdd = "<speak> "
Call addtext
Exit Sub
ErrorHandler:
err.Source = "Script Maker - cmdSpeak"
Call MenuErrorHandler
End Sub

Private Sub cmdSpeechEmp_Click()
If ExceptionHandlers = True Then On Error GoTo ErrorHandler
If mnuOptionsShow.Checked = True Or RemoteSend = True Then TextAdd = "\emp\" + Secondfrm.VHMessage(0, 1, 0, 0, 0, 0, 0, 0, 0, 0, True, False, "Enter a word to say with emphasis", 0, 0)
If mnuOptionsShow.Checked = False Then TextAdd = "\emp\"
Call addtext
Exit Sub
ErrorHandler:
err.Source = "Script Maker - cmdSpeechEmp"
Call MenuErrorHandler
End Sub

Private Sub cmdSpeechPau_Click()
If ExceptionHandlers = True Then On Error GoTo ErrorHandler
If mnuOptionsShow.Checked = True Or RemoteSend = True Then TextAdd = "\pau=" + LTrim$(Secondfrm.VHMessage(0, 1, 0, 0, 0, 0, 0, 0, 0, 0, True, False, "Enter the amount of milliseconds to pause for", 0, 0)) + "\"
If mnuOptionsShow.Checked = False Then TextAdd = "\pau="
Call addtext
Exit Sub
ErrorHandler:
err.Source = "Script Maker - cmdSpeechPau"
Call MenuErrorHandler
End Sub

Private Sub cmdSpeechPit_Click()
If ExceptionHandlers = True Then On Error GoTo ErrorHandler
If mnuOptionsShow.Checked = True Or RemoteSend = True Then TextAdd = "\pit=" + LTrim$(Secondfrm.VHMessage(0, 1, 0, 0, 0, 0, 0, 0, 0, 0, True, False, "Enter the new pitch value", 0, 0)) + "\"
If mnuOptionsShow.Checked = False Then TextAdd = "\pit="
Call addtext
Exit Sub
ErrorHandler:
err.Source = "Script Maker - cmdSpeechPit"
Call MenuErrorHandler
End Sub

Private Sub cmdSpeechSpeed_Click()
If ExceptionHandlers = True Then On Error GoTo ErrorHandler
If mnuOptionsShow.Checked = True Or RemoteSend = True Then TextAdd = "\spd=" + LTrim$(Secondfrm.VHMessage(0, 1, 0, 0, 0, 0, 0, 0, 0, 0, True, False, "Enter the new speed value", 0, 0)) + "\"
If mnuOptionsShow.Checked = False Then TextAdd = "\spd="
Call addtext
Exit Sub
ErrorHandler:
err.Source = "Script Maker - cmdSpeechSpeed"
Call MenuErrorHandler
End Sub

Private Sub cmdSpeechVol_Click()
If ExceptionHandlers = True Then On Error GoTo ErrorHandler
If mnuOptionsShow.Checked = True Or RemoteSend = True Then TextAdd = "\vol=" + LTrim$(Secondfrm.VHMessage(0, 1, 0, 0, 0, 0, 0, 0, 0, 0, True, False, "Enter the new volume value", 0, 0)) + "\"
If mnuOptionsShow.Checked = False Then TextAdd = "\vol="
Call addtext
Exit Sub
ErrorHandler:
err.Source = "Script Maker - cmdSpeechVol"
Call MenuErrorHandler
End Sub

Private Sub cmdStop_Click()
TextAdd = "<stop>" + vbCrLf
Call addtext
End Sub

Private Sub cmdToneVol_Click()
If ExceptionHandlers = True Then On Error GoTo ErrorHandler
If mnuOptionsShow.Checked = True Or RemoteSend = True Then TextAdd = "<tonevol> " + LTrim$(Message.VHMessage(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, False, False, "Select a tone volume value", -5000, 0)) + vbCrLf
If mnuOptionsShow.Checked = False Then TextAdd = "<tonevol> "
Call addtext
Exit Sub
ErrorHandler:
err.Source = "Script Maker - cmdToneVol"
Call MenuErrorHandler
End Sub

Private Sub cmdVidBal_Click()
If ExceptionHandlers = True Then On Error GoTo ErrorHandler
If mnuOptionsShow.Checked = True Or RemoteSend = True Then TextAdd = "<vidbal> " + LTrim$(Message.VHMessage(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, False, False, "Select a video balance value", -100, 100)) + vbCrLf
If mnuOptionsShow.Checked = False Then TextAdd = "<vidbal> "
Call addtext
Exit Sub
ErrorHandler:
err.Source = "Script Maker - cmdVidBal"
Call MenuErrorHandler
End Sub

Private Sub cmdVidFile_Click()
If ExceptionHandlers = True Then On Error GoTo ErrorHandler
If mnuOptionsShow.Checked = True Or RemoteSend = True Then
    Message.RelativePath = True
    Message.FilePath = App.path + "\videos"
    Message.FileType = "Video file (*.avi;*.wmv;*.mpeg;*.mpg;*.m1v;*.ogg;*.ogm;*.swf)|*.avi;*.wmv;*.mpeg;*.mpg;*.m1v;*.ogg;*.ogm;*.swf"
    Temp = Message.VHMessage(0, 0, 0, 0, 0, 0, 0, 1, 0, 0, False, False, "Choose a video file or URL to load", 0, 0)
    TextAdd = "<vidfile> " + Message.MessageFile + vbCrLf
End If
If mnuOptionsShow.Checked = False Then TextAdd = "<vidfile> "
Call addtext
Exit Sub
ErrorHandler:
err.Source = "Script Maker - cmdVidFile"
Call MenuErrorHandler
End Sub

Private Sub cmdVidHide_Click()
TextAdd = "<vidstat> hide" + vbCrLf
Call addtext
End Sub

Private Sub cmdVidLoop_Click()
TextAdd = "<vidstat> loop" + vbCrLf
Call addtext
End Sub

Private Sub cmdVidPause_Click()
TextAdd = "<vidstat> pause" + vbCrLf
Call addtext
End Sub

Private Sub cmdVidPlay_Click()
TextAdd = "<vidstat> play" + vbCrLf
Call addtext
End Sub

Private Sub cmdVidRate_Click()
If ExceptionHandlers = True Then On Error GoTo ErrorHandler
If mnuOptionsShow.Checked = True Or RemoteSend = True Then TextAdd = "<vidrate> " + LTrim$(Message.VHMessage(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, False, False, "Select a vidio rate value by percentage of original", 51, 1000)) + vbCrLf
If mnuOptionsShow.Checked = False Then TextAdd = "<vidrate> "
Call addtext
Exit Sub
ErrorHandler:
err.Source = "Script Maker - cmdVidRate"
Call MenuErrorHandler
End Sub

Private Sub cmdVidShow_Click()
TextAdd = "<vidstat> show" + vbCrLf
Call addtext
End Sub

Private Sub cmdVidVol_Click()
If ExceptionHandlers = True Then On Error GoTo ErrorHandler
If mnuOptionsShow.Checked = True Or RemoteSend = True Then TextAdd = "<vidvol> " + LTrim$(Message.VHMessage(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, False, False, "Select a video volume value", -5000, 0)) + vbCrLf
If mnuOptionsShow.Checked = False Then TextAdd = "<vidvol> "
Call addtext
Exit Sub
ErrorHandler:
err.Source = "Script Maker - cmdVidVol"
Call MenuErrorHandler
End Sub

Private Sub cmdVidZoom_Click()
If ExceptionHandlers = True Then On Error GoTo ErrorHandler
If mnuOptionsShow.Checked = True Or RemoteSend = True Then TextAdd = "<vidzoom> " + LTrim$(Message.VHMessage(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, False, False, "Select a video zoom value by percentage of original", 0, 200)) + vbCrLf
If mnuOptionsShow.Checked = False Then TextAdd = "<vidzoom> "
Call addtext
Exit Sub
ErrorHandler:
err.Source = "Script Maker - cmdVidZoom"
Call MenuErrorHandler
End Sub

Private Sub cmdVisZoom_Click()
If ExceptionHandlers = True Then On Error GoTo ErrorHandler
If mnuOptionsShow.Checked = True Or RemoteSend = True Then TextAdd = "<viszoom> " + LTrim$(Message.VHMessage(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, False, False, "Select a custom visual zoom value by percentage of original", 1, 200)) + vbCrLf
If mnuOptionsShow.Checked = False Then TextAdd = "<viszoom> "
Call addtext
Exit Sub
ErrorHandler:
err.Source = "Script Maker - cmdVisZoom"
Call MenuErrorHandler
End Sub

Private Sub cmdVoiceBuffer_Click()
TextAdd = "<voicebuffer>" + vbCrLf
Call addtext
End Sub

Private Sub cmdWatchKey_Click()
If ExceptionHandlers = True Then On Error GoTo ErrorHandler
If mnuOptionsShow.Checked = True Or RemoteSend = True Then
    Temp = Message.VHMessage(0, 0, 0, 0, 0, 0, 0, 0, 1, 0, False, False, "Choose a key from the list to watch for", 0, 0)
    TextAdd = "<watchkey> " + Message.MessageKey + vbCrLf
End If
If mnuOptionsShow.Checked = False Then TextAdd = "<watchkey> "
Call addtext
Exit Sub
ErrorHandler:
err.Source = "Script Maker - cmdWatchKey"
Call MenuErrorHandler
End Sub

Private Sub cmdYesNo_Click()
If ExceptionHandlers = True Then On Error GoTo ErrorHandler
If mnuOptionsShow.Checked = True Or RemoteSend = True Then TextAdd = "<yesno> " + Message.VHMessage(0, 1, 0, 0, 0, 0, 0, 0, 0, 0, True, False, "Enter text for the Yes/No dialog to say", 0, 0) + vbCrLf
If mnuOptionsShow.Checked = False Then TextAdd = "<yesno> "
Call addtext
Exit Sub
ErrorHandler:
err.Source = "Script Maker - cmdYesNo"
Call MenuErrorHandler
End Sub

Private Sub Form_Activate()
If UseSAPI5 = True Then
    mnuOptionsWav.Enabled = True
Else
    mnuOptionsWav.Checked = False
    mnuOptionsWav.Enabled = False
End If
End Sub

Private Sub Form_Load()
Me.Left = (ScreenX / 2) - (Me.Width / 2)
Me.Top = (ScreenY / 2) - (Me.Height / 2)

Dim Temp As String

OrigScript = ""
ScriptChanged = False

Set Secondfrm = New Message

'Load settings from INI file

Temp = GetINIString(1, "script maker", "fontname", "")
If Temp = "" Then Exit Sub
Script.FontName = Temp
CommonDialog1.FontName = Temp

Temp = GetINIString(1, "script maker", "fontsize")
Script.FontSize = Val(Temp)
CommonDialog1.FontSize = Val(Temp)

Temp = GetINIString(1, "script maker", "fontbold", "0")
If Temp = "1" Then Script.FontBold = True Else Script.FontBold = False
If Temp = "1" Then CommonDialog1.FontBold = True Else CommonDialog1.FontBold = False

Temp = GetINIString(1, "script maker", "fontitalic", "0")
If Temp = "1" Then Script.FontItalic = True Else Script.FontItalic = False
If Temp = "1" Then CommonDialog1.FontItalic = True Else CommonDialog1.FontItalic = False

Temp = GetINIString(1, "script maker", "fontunderline", "0")
If Temp = "1" Then Script.FontUnderline = True Else Script.FontUnderline = False
If Temp = "1" Then CommonDialog1.FontUnderline = True Else CommonDialog1.FontUnderline = False

Temp = GetINIString(1, "script maker", "fontstrike", "0")
If Temp = "1" Then Script.FontStrikethru = True Else Script.FontStrikethru = False
If Temp = "1" Then CommonDialog1.FontStrikethru = True Else CommonDialog1.FontStrikethru = False

Temp = GetINIString(1, "script maker", "textcolor", Str$(vbBlack))
Script.ForeColor = Val(Temp)

Temp = GetINIString(1, "script maker", "backcolor", Str$(vbWhite))
Script.BackColor = Val(Temp)

Temp = GetINIString(1, "script maker", "messageboxes", "1")
If Val(Temp) = 1 Then mnuOptionsShow.Checked = True
If Val(Temp) = 0 Then mnuOptionsShow.Checked = False

Temp = GetINIString(1, "script maker", "previewmode", "console")
If Temp = "full" Then mnuPreviewFullMode.Checked = True: mnuPreviewConsoleMode.Checked = False
If Temp = "console" Then mnuPreviewConsoleMode.Checked = True: mnuPreviewFullMode.Checked = False

Temp = GetINIString(1, "script maker", "optionsontop", "0")
If Temp = "0" Then mnuOptionsOnTop.Checked = False
If Temp = "1" Then mnuOptionsOnTop.Checked = True

End Sub

Private Sub Form_Resize()
If Me.WindowState <> 1 Then
    Script.Width = Me.Width - 120
    Script.Height = Me.Height - 690
End If
End Sub

Private Sub Form_Unload(Cancel As Integer)
If ScriptChanged = True Then
    Dim result As Integer
    result = MsgBox("Save script before exiting?", vbYesNoCancel + vbExclamation, "Virtual Hypnotist")
    If result = vbYes Then
        Call mnuFileSave_Click
    End If
    If result = vbCancel Then
        Cancel = 1
        Exit Sub
    End If
End If
Set Secondfrm = Nothing
End Sub

Private Sub mnuCommentMark_Click()
TextAdd = "#"
Call addtext
End Sub

Private Sub mnuEditCopy_Click()
If ExceptionHandlers = True Then On Error GoTo ErrorHandler
Clipboard.Clear
If TypeOf Screen.ActiveControl Is TextBox Then
    Clipboard.SetText Screen.ActiveControl.SelText
ElseIf TypeOf Screen.ActiveControl Is ComboBox Then
    Clipboard.SetText Screen.ActiveControl.Text
ElseIf TypeOf Screen.ActiveControl Is PictureBox Then
    Clipboard.SetData Screen.ActiveControl.Picture
ElseIf TypeOf Screen.ActiveControl Is ListBox Then
    Clipboard.SetText Screen.ActiveControl.Text
Else
    ' No action makes sense for the other controls.
End If
Exit Sub
ErrorHandler:
err.Source = "Script Maker - mnuEditCopy"
Call ErrorReport("An error occurred while processing the clipboard.", vbCritical)
End Sub

Private Sub mnuEditCut_Click()
If ExceptionHandlers = True Then On Error GoTo ErrorHandler
' First do the same as a copy.
mnuEditCopy_Click
' Now clear contents of active control.
If TypeOf Screen.ActiveControl Is TextBox Then
    Screen.ActiveControl.SelText = ""
ElseIf TypeOf Screen.ActiveControl Is ComboBox Then
    Screen.ActiveControl.Text = ""
ElseIf TypeOf Screen.ActiveControl Is PictureBox Then
    Screen.ActiveControl.Picture = LoadPicture()
ElseIf TypeOf Screen.ActiveControl Is ListBox Then
    Screen.ActiveControl.RemoveItem Screen.ActiveControl.ListIndex
Else
    ' No action makes sense for the other controls.
End If
Exit Sub
ErrorHandler:
err.Source = "Script Maker - mnuEditCut"
Call ErrorReport("An error occurred while processing the clipboard.", vbCritical)
End Sub

Private Sub mnuEditDel_Click()
If ExceptionHandlers = True Then On Error GoTo ErrorHandler
' Now clear contents of active control.
If TypeOf Screen.ActiveControl Is TextBox Then
    Screen.ActiveControl.SelText = ""
ElseIf TypeOf Screen.ActiveControl Is ComboBox Then
    Screen.ActiveControl.Text = ""
ElseIf TypeOf Screen.ActiveControl Is PictureBox Then
    Screen.ActiveControl.Picture = LoadPicture()
ElseIf TypeOf Screen.ActiveControl Is ListBox Then
    Screen.ActiveControl.RemoveItem Screen.ActiveControl.ListIndex
Else
    ' No action makes sense for the other controls.
End If
Exit Sub
ErrorHandler:
err.Source = "Script Maker - mnuEditDel"
Call ErrorReport("An error occurred while processing the clipboard.", vbCritical)
End Sub

Private Sub mnuEditFind_Click()
Cnt = Script.SelStart + 1
ShowWindow = True
frmFindReplace.FindnReplace Script
End Sub

Private Sub mnuEditFindNext_Click()
Cnt = Script.SelStart + 1
ShowWindow = False
Call frmFindReplace.cmdFindNext_Click
End Sub

Private Sub mnuEditPaste_Click()
If ExceptionHandlers = True Then On Error GoTo ErrorHandler
If TypeOf Screen.ActiveControl Is TextBox Then
    Screen.ActiveControl.SelText = Clipboard.GetText()
ElseIf TypeOf Screen.ActiveControl Is ComboBox Then
    Screen.ActiveControl.Text = Clipboard.GetText()
ElseIf TypeOf Screen.ActiveControl Is PictureBox Then
    Screen.ActiveControl.Picture = Clipboard.GetData()
ElseIf TypeOf Screen.ActiveControl Is ListBox Then
    Screen.ActiveControl.AddItem Clipboard.GetText()
Else
    ' No action makes sense for the other controls.
End If
Exit Sub
ErrorHandler:
err.Source = "Script Maker - mnuEditPaste"
Call ErrorReport("An error occurred while processing the clipboard.", vbCritical)
End Sub

Private Sub mnuEditSelectAll_Click()
Script.SelStart = 0
Script.SelLength = Len(Script.Text)
End Sub

Private Sub mnuFileConvert_Click()
On Error GoTo 10
CommonDialog1.InitDir = App.path
CommonDialog1.CancelError = True
CommonDialog1.DefaultExt = ".txt"
CommonDialog1.Filter = "Text File (*.txt)|*.txt|"
CommonDialog1.DialogTitle = "Convert text file to script"
CommonDialog1.action = 1
If ExceptionHandlers = True Then On Error GoTo ErrorHandler
StartLoading:
Dim FileExists As Boolean
Dim I As Long
I = Len(Dir$(CommonDialog1.Filename))
If err Or I = 0 Then
    FileExists = False
    Else
        FileExists = True
End If

If ExceptionHandlers = True Then On Error GoTo ErrorHandler
If FileExists = False Then Error 53

Dim TempScript As String
Dim ScriptBuffer As String
Dim test1 As Integer
Dim test2 As Integer
Dim temppos As Long
Dim UnixBuffer As String
Dim UnixPos As Long
Script.Text = ""
UnixBuffer = ""
UnixPos = 0

'load file
Open CommonDialog1.Filename For Input As #1
    TempScript = ""
    Do
        'load the whole script into a single string
        DoEvents
        If UnixPos = 0 And Len(UnixBuffer) = 0 Then
            If EOF(1) = True Then Exit Do
            Line Input #1, ScriptBuffer
            If InStr(1, ScriptBuffer, Chr$(10)) > 0 Then UnixBuffer = ScriptBuffer
        End If
        UnixPos = InStr(1, UnixBuffer, Chr$(10))
        If UnixPos > 0 Then
        'If the file has only linefeeds (unix format), load it manually
            ScriptBuffer = Trim2(Mid$(UnixBuffer, 1, UnixPos - 1))
            UnixBuffer = Mid$(UnixBuffer, UnixPos + 1)
        End If
        'check for end of buffer
        If UnixPos = 0 And Len(UnixBuffer) > 0 Then
            ScriptBuffer = Trim2(Mid$(UnixBuffer, 1))
            UnixBuffer = ""
        End If
        ScriptBuffer = Trim2(ScriptBuffer)
        If ScriptBuffer <> "" Then TempScript = TempScript + ScriptBuffer + " "
    Loop
    TempScript = Trim2(TempScript)
    If TempScript <> "" Then
        'Parse script by adding <speak> commands before each regular line, and separate the sentences
        For I = 1 To Len(TempScript)
            'find the next period
            temppos = I
            Do
                test1 = InStr(temppos, TempScript, "... ", vbTextCompare)
                test2 = InStr(temppos, TempScript, ". ", vbTextCompare)
                If test2 <> test1 + 2 Then
                    test1 = 0
                    Exit Do
                Else
                    temppos = test2 + 1
                End If
            Loop
            If test1 = 0 And test2 = 0 Then
                Script.Text = Script.Text + "<speak> " + Trim2(Mid$(TempScript, I)) + vbCrLf
                I = Len(TempScript)
            End If
            If test2 > 0 Then
                Script.Text = Script.Text + "<speak> " + Trim2(Mid(TempScript, I, test2 - I + 1)) + vbCrLf
                I = test2 + 1
            End If
        Next I
    End If
Close #1

CommonDialog1.Filename = ""

MsgBox "The text file has been converted into a Virtual Hypnotist ISL script." + vbCrLf + "Make sure you take any old comments out of <speak> commands and use comment markers for them.", vbInformation, "Script Maker"

10 Exit Sub
ErrorHandler:
err.Source = "Script Maker - mnuFileConvert"
Call ErrorReport("An error occurred while loading the text file.", vbCritical)
Exit Sub
End Sub

Private Sub mnuFileExit_Click()
Unload Me
End Sub

Public Sub mnuFileLoad_Click()
If AutoLoadScript <> "" Then
    CommonDialog1.Filename = AutoLoadScript
    AutoLoadScript = ""
    GoTo StartLoading
End If

If ScriptChanged = True Then
    Dim result As Integer
    result = MsgBox("Save script?", vbYesNoCancel + vbExclamation, "Virtual Hypnotist")
    If result = vbYes Then Call mnuFileSave_Click: Exit Sub
    If result = vbCancel Then Exit Sub
End If

On Error GoTo 10
CommonDialog1.InitDir = App.path
CommonDialog1.CancelError = True
CommonDialog1.DefaultExt = ".txt"
CommonDialog1.Filter = "Text File (*.txt)|*.txt|"
CommonDialog1.DialogTitle = "Load Script"
CommonDialog1.action = 1
If ExceptionHandlers = True Then On Error GoTo ErrorHandler
StartLoading:
Dim FileExists As Boolean
Dim I As Integer
I = Len(Dir$(CommonDialog1.Filename))
If err Or I = 0 Then
    FileExists = False
    Else
        FileExists = True
End If
If ExceptionHandlers = True Then On Error GoTo ErrorHandler
If FileExists = False Then Error 53

Dim j As Long
Dim byteArray() As Byte
Dim Encrypted As Boolean
FileLoading = True
Script.Text = ""

'load file
Encrypted = IsEncrypted(CommonDialog1.Filename)
If Encrypted = False Then
    Open CommonDialog1.Filename For Binary As #1
    ReDim byteArray(0 To LOF(1) - 1)
    Get #1, , byteArray()
    Close #1
    Script.Text = StrConv(byteArray(), vbUnicode)
Else
    If HideEncrypted = False Then
        Dim EX As New EncryptXOR
        Script.Text = EX.DecryptFile(CommonDialog1.Filename, "VHYPNO")
    Else
        err.Source = "Script Maker - mnuFileLoad"
        Call MsgBox("Script file is encrypted", vbCritical, "Virtual Hypnotist")
        FileLoading = False
        Exit Sub
    End If
End If

FileLoading = False
  
Me.Caption = "Script Maker - " + CommonDialog1.Filename

OrigScript = Script.Text
ScriptChanged = False

10 Exit Sub
ErrorHandler:
err.Source = "Script Maker - mnuFileLoad"
Call ErrorReport("An error occurred while loading the script file.", vbCritical)
Script.Enabled = True
Exit Sub
End Sub


Private Sub mnuFileNew_Click()
If ScriptChanged = True Then
    Dim result As Integer
    result = MsgBox("Save script?", vbYesNoCancel + vbExclamation, "Virtual Hypnotist")
    If result = vbYes Then Call mnuFileSave_Click: Exit Sub
    If result = vbCancel Then Exit Sub
End If
Script.Text = ""
ScriptChanged = False
CommonDialog1.Filename = ""
Me.Caption = "Script Maker - Untitled"
End Sub

Private Sub mnuFileSave_Click()
If CommonDialog1.Filename = "" Then
    Call SaveScript(True, False)
Else
    Call SaveScript(False, False)
End If
End Sub

Private Sub mnuFileSaveAs_Click()
Call SaveScript(True, False)
End Sub

Private Sub mnuFileSaveEncrypted_Click()
Call SaveScript(True, True)
End Sub

Private Sub mnuGotoLabel_Click()
If ExceptionHandlers = True Then On Error GoTo ErrorHandler
If mnuOptionsShow.Checked = True Or RemoteSend = True Then TextAdd = LTrim$(Message.VHMessage(0, 1, 0, 0, 0, 0, 0, 0, 0, 0, True, False, "Enter label name", 0, 0)) + ":" + vbCrLf
If mnuOptionsShow.Checked = False Then TextAdd = "label:"
Call addtext
Exit Sub
ErrorHandler:
err.Source = "Script Maker - mnuGotoLabel"
Call MenuErrorHandler
End Sub

Private Sub mnuHelpAbout_Click()
frmAbout.Show
End Sub

Private Sub mnuHelpHelp_Click()
If ExceptionHandlers = True Then On Error GoTo ErrorHandler

Shell "hh " + App.path + "\vh.chm::/scriptmaker.html", vbNormalFocus
Exit Sub

ErrorHandler:
err.Source = "Script Maker - mnuHelpHelp"
   Call ErrorReport("An error occurred while loading Windows HTML Help.", vbExclamation)
   
End Sub

Private Sub mnuHelpScripts_Click()
If ExceptionHandlers = True Then On Error GoTo ErrorHandler

Shell "hh " + App.path + "\vh.chm::/scriptguide.html", vbNormalFocus
Exit Sub

ErrorHandler:
err.Source = "Script Maker - mnuHelpScripts"
   Call ErrorReport("An error occurred while loading Windows HTML Help.", vbExclamation)
   
End Sub

Private Sub mnuInsertAge_Click()
TextAdd = "%age%"
Call addtext
End Sub

Private Sub mnuInsertBackBal_Click()
TextAdd = "%backbal%"
Call addtext
End Sub

Private Sub mnuInsertBackDuration_Click()
TextAdd = "%backduration%"
Call addtext
End Sub

Private Sub mnuInsertBackFile_Click()
TextAdd = "%backfile%"
Call addtext
End Sub

Private Sub mnuInsertBackPosition_Click()
TextAdd = "%backposition%"
Call addtext
End Sub

Private Sub mnuInsertBackRate_Click()
TextAdd = "%backrate%"
Call addtext
End Sub

Private Sub mnuInsertBackVol_Click()
TextAdd = "%backvol%"
Call addtext
End Sub

Private Sub mnuInsertCharName_Click()
TextAdd = "%charname%"
Call addtext
End Sub

Private Sub mnuInsertCustBal_Click()
TextAdd = "%custbal%"
Call addtext
End Sub

Private Sub mnuInsertCustDuration_Click()
TextAdd = "%custduration%"
Call addtext
End Sub

Private Sub mnuInsertCustFile_Click()
TextAdd = "%custfile%"
Call addtext
End Sub

Private Sub mnuInsertCustPosition_Click()
TextAdd = "%custposition%"
Call addtext
End Sub

Private Sub mnuInsertCustRate_Click()
TextAdd = "%custrate%"
Call addtext
End Sub

Private Sub mnuInsertCustVol_Click()
TextAdd = "%custvol%"
Call addtext
End Sub

Private Sub mnuInsertDate_Click()
TextAdd = "%date%"
Call addtext
End Sub

Private Sub mnuInsertElapsedTime_Click()
TextAdd = "%elapsedtime%"
Call addtext
End Sub

Private Sub mnuInsertGender_Click()
TextAdd = "%gender%"
Call addtext
End Sub

Private Sub mnuInsertKeyPressedVar_Click()
TextAdd = "%keypressed%"
Call addtext
End Sub

Private Sub mnuInsertKeyVar_Click()
TextAdd = "%key%"
Call addtext
End Sub

Private Sub mnuInsertLineNum_Click()
TextAdd = "%linenum%"
Call addtext
End Sub

Private Sub mnuInsertMaskVol_Click()
TextAdd = "%maskvol%"
Call addtext
End Sub

Private Sub mnuInsertMath_Click()
If ExceptionHandlers = True Then On Error GoTo ErrorHandler
If mnuOptionsShow.Checked = True Or RemoteSend = True Then
    Temp = Message.VHMessage(0, 1, 0, 3, 0, 2, 0, 0, 0, 0, True, False, "Enter the number or variable to calculate, choose the operation, and enter a second number or variable", 0, 0)
    TextAdd = "(" + Trim2(Message.MessageText) + " " + Message.MessageOperation + " " + Trim2(Message.MessageText2) + ")"
End If
If mnuOptionsShow.Checked = False Then TextAdd = "("
Call addtext
Exit Sub
ErrorHandler:
err.Source = "Script Maker - mnuInsertMath"
Call MenuErrorHandler
End Sub

Private Sub mnuInsertName_Click()
TextAdd = "%name%"
Call addtext
End Sub

Private Sub mnuInsertSpeechRecVar_Click()
TextAdd = "%speechrec%"
Call addtext
End Sub

Private Sub mnuInsertSpeechTone_Click()
If ExceptionHandlers = True Then On Error GoTo ErrorHandler
If mnuOptionsShow.Checked = True Or RemoteSend = True Then TextAdd = "\chr=" + LTrim$(Message.VHMessage(0, 0, 0, 0, 0, 0, 0, 0, 0, 1, False, False, "Choose the voice parameters to use - note that these only work when the character is off (except monotone and whisper).", 0, 0)) + "\"
If mnuOptionsShow.Checked = False Then TextAdd = "\chr="
Call addtext
Exit Sub
ErrorHandler:
err.Source = "Script Maker - mnuInsertSpeechTone"
Call MenuErrorHandler
End Sub

Private Sub mnuInsertSpeechVar_Click()
TextAdd = "%speech%"
Call addtext
End Sub

Private Sub mnuInsertTextVar_Click()
TextAdd = "%text%"
Call addtext
End Sub

Private Sub mnuInsertTime_Click()
TextAdd = "%time%"
Call addtext
End Sub

Private Sub mnuInsertToneFreq1_Click()
TextAdd = "%tonefreq1%"
Call addtext
End Sub

Private Sub mnuInsertToneFreq2_Click()
TextAdd = "%tonefreq2%"
Call addtext
End Sub

Private Sub mnuInsertToneVol_Click()
TextAdd = "%tonevol%"
Call addtext
End Sub

Private Sub mnuInsertTrigger_Click()
TextAdd = "%trigger%"
Call addtext
End Sub

Private Sub mnuInsertVidBal_Click()
TextAdd = "%vidbal%"
Call addtext
End Sub

Private Sub mnuInsertVidDuration_Click()
TextAdd = "%vidduration%"
Call addtext
End Sub

Private Sub mnuInsertVidFile_Click()
TextAdd = "%vidfile%"
Call addtext
End Sub

Private Sub mnuInsertVidPosition_Click()
TextAdd = "%vidposition%"
Call addtext
End Sub

Private Sub mnuInsertVidRate_Click()
TextAdd = "%vidrate%"
Call addtext
End Sub

Private Sub mnuInsertVidVol_Click()
TextAdd = "%vidvol%"
Call addtext
End Sub

Private Sub mnuInsertVoiceVar_Click()
TextAdd = "%voice%"
Call addtext
End Sub

Private Sub mnuInsertYesNo_Click()
TextAdd = "%yesno%"
Call addtext
End Sub

Private Sub mnuOptionsBackground_Click()
Dim I As Long
If ExceptionHandlers = True Then On Error GoTo ErrorHandler
CommonDialog1.Color = Script.BackColor
CommonDialog1.flags = cdlCCFullOpen Or cdlCCRGBInit
CommonDialog1.ShowColor
I = CommonDialog1.Color
If I <> -1 Then Script.BackColor = I

WriteINIString 1, "script maker", "backcolor", LTrim$(Str$(Script.BackColor))

ErrorHandler:
Exit Sub
End Sub

Private Sub mnuOptionsFont_Click()
' Set Cancel to True.
   CommonDialog1.CancelError = True
   On Error GoTo ErrHandler
   
   'put current settings into the dialog box
   CommonDialog1.Color = Script.ForeColor
   CommonDialog1.FontName = Script.FontName
   CommonDialog1.FontSize = Script.FontSize
   CommonDialog1.FontBold = Script.FontBold
   CommonDialog1.FontItalic = Script.FontItalic
   CommonDialog1.FontUnderline = Script.FontUnderline
   CommonDialog1.FontStrikethru = Script.FontStrikethru

   ' Set the Flags property.
   CommonDialog1.flags = cdlCFBoth Or cdlCFEffects
   ' Display the Font dialog box.
   CommonDialog1.ShowFont
   ' Set text properties according to user's
   ' selections.
   Script.FontName = CommonDialog1.FontName
   Script.FontSize = CommonDialog1.FontSize
   Script.FontBold = CommonDialog1.FontBold
   Script.FontItalic = CommonDialog1.FontItalic
   Script.FontUnderline = CommonDialog1.FontUnderline
   Script.FontStrikethru = CommonDialog1.FontStrikethru
   Script.ForeColor = CommonDialog1.Color
   
   WriteINIString 1, "script maker", "fontname", Script.FontName
   WriteINIString 1, "script maker", "fontsize", LTrim$(Str$(Script.FontSize))
   WriteINIString 1, "script maker", "fontbold", LTrim$(Str$(Abs(Int(Script.FontBold))))
   WriteINIString 1, "script maker", "fontitalic", LTrim$(Str$(Abs(Int(Script.FontItalic))))
   WriteINIString 1, "script maker", "fontunderline", LTrim$(Str$(Abs(Int(Script.FontUnderline))))
   WriteINIString 1, "script maker", "fontstrike", LTrim$(Str$(Abs(Int(Script.FontStrikethru))))
   WriteINIString 1, "script maker", "textcolor", LTrim$(Str$(Script.ForeColor))
   
   Exit Sub
ErrHandler:
   ' User pressed Cancel button.
   Exit Sub
End Sub

Private Sub mnuOptionsOnTop_Click()
If mnuOptionsOnTop.Checked = False Then mnuOptionsOnTop.Checked = True Else mnuOptionsOnTop.Checked = False
WriteINIString 1, "script maker", "optionsontop", LTrim$(Str$(Abs(Int(mnuOptionsOnTop.Checked))))
End Sub

Private Sub mnuOptionsShow_Click()
If mnuOptionsShow.Checked = True Or RemoteSend = True Then mnuOptionsShow.Checked = False Else mnuOptionsShow.Checked = True
WriteINIString 1, "script maker", "messageboxes", LTrim$(Str$(Abs(Int(mnuOptionsShow.Checked))))
End Sub

Private Sub mnuOptionsWav_Click()
If mnuOptionsWav.Checked = False Then mnuOptionsWav.Checked = True Else mnuOptionsWav.Checked = False
End Sub

Private Sub mnuPreviewConsole_Click()
Console.Show
End Sub

Private Sub mnuPreviewConsoleMode_Click()
mnuPreviewConsoleMode.Checked = True
mnuPreviewFullMode.Checked = False
WriteINIString 1, "script maker", "previewmode", "console"
End Sub

Private Sub mnuPreviewFull_Click()
If mnuOptionsWav.Checked = True Then Call ChooseWAVFile
Call ClearArrays
Call LoadCustomScript(Script.Text, GetObjectLines(Script.Text))
Call CheckParms
End Sub

Private Sub mnuPreviewFullMode_Click()
mnuPreviewFullMode.Checked = True
mnuPreviewConsoleMode.Checked = False
WriteINIString 1, "script maker", "previewmode", "full"
End Sub

Private Sub mnuPreviewSelect_Click()
If mnuOptionsWav.Checked = True Then Call ChooseWAVFile
Call ClearArrays
Call LoadCustomScript(Script.SelText, GetObjectLines(Script.SelText))
Call CheckParms
End Sub

Private Sub mnuPreviewSyntax_Click()
'turn on syntax checking
CheckSyntax = True
Call ClearArrays
Call LoadCustomScript(Script.Text, GetObjectLines(Script.Text))
Call CheckParms
End Sub

Private Sub mnuVarInsert_Click()
If ExceptionHandlers = True Then On Error GoTo ErrorHandler
If mnuOptionsShow.Checked = True Or RemoteSend = True Then TextAdd = "%" + LTrim$(Secondfrm.VHMessage(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, False, False, "Choose which variable to use", 0, 255)) + "%"
If mnuOptionsShow.Checked = False Then TextAdd = "%"
Call addtext
Exit Sub
ErrorHandler:
err.Source = "Script Maker - mnuVarInsert"
Call MenuErrorHandler
End Sub

Private Sub CheckParms()
If ExceptionHandlers = True Then On Error GoTo ErrorHandler
If mnuPreviewFullMode.Checked = True And CheckSyntax = False Then
    If SynthSpeech = True And UseSAPI5 = False And frmSession.chkEnableChar.Value = 1 And CharacterFile = "" Then MsgBox "Please choose a character file", vbOKOnly + vbInformation, "Virtual Hypnotist": Exit Sub
    If frmSession.chkEnableVideo.Value = 1 And VideoFile = "" Then MsgBox "Please choose a video file", vbOKOnly + vbInformation, "Virtual Hypnotist": Exit Sub
    If frmSession.chkEnableSubliminals.Value = 1 And SubliminalsFile = "" Then MsgBox "Please choose a subliminals file", vbOKOnly + vbInformation, "Virtual Hypnotist": Exit Sub
    If frmSession.chkEnableAudio.Value = 1 And AudioFile = "" Then MsgBox "Please choose an audio file", vbOKOnly + vbInformation, "Virtual Hypnotist": Exit Sub
    If frmSession.chkEnableCustom.Value = 1 And frmSession.txtCustomAudio.Text = "" Then MsgBox "Please choose a custom audio file by clicking the Session Types button", vbOKOnly + vbInformation, "Virtual Hypnotist": Exit Sub
    If frmSession.optSessionStandard.Value = False Then
        If SynthSpeech = True And UseSAPI5 = False Then Char.Hide
    End If
    If frmSession.optSessionSubliminal.Value = True And NoSubWindow = False Then
        SubControlPanel.Show
        HypnoWinState = 1
    Else
        HypnoWinState = 2
    End If

    'uses SubControlPanel timer to force frmMain invisible
    If NoSubWindow = True Then SubControlPanel.Show: SubControlPanel.Hide

    Preview = False
    SkipScripts = True
    frmHypno.Show
Else
    Preview = True
    SkipScripts = False
    UpdateSpeechSettings frmSession.sliderVoicePitch.Value, frmSession.sliderVoiceSpeed.Value, frmSession.sliderVoiceVolume.Value
    Call Process(6, True, 0)

    'unload voice recognition component
    Set frmHypno.VDict1 = Nothing

    Unload frmHypno
    'get end time in ticks
    SessionEndTime = GetTickCount
End If

Exit Sub
ErrorHandler:
If err.Number = 364 Then Exit Sub 'skip the Object Unloaded errors
err.Source = "Script Maker - CheckParms"
Call ErrorReport("An error occurred while starting the preview session.", vbExclamation)
End Sub

Private Sub Script_Change()
If (Script.Text <> OrigScript) And FileLoading = False Then ScriptChanged = True Else ScriptChanged = False
End Sub

Private Sub Timer1_Timer()
If ScriptChanged = True And Right(Me.Caption, 1) <> "*" Then Me.Caption = Me.Caption + "*"
If ScriptChanged = False And Right(Me.Caption, 1) = "*" Then Me.Caption = Left$(Me.Caption, Len(Me.Caption) - 1)
End Sub

Private Sub ChooseWAVFile()
' Set CancelError is True
CommonDialog2.CancelError = True
On Error GoTo ErrHandler

CommonDialog2.InitDir = App.path

' Set flags
CommonDialog2.flags = cdlOFNOverwritePrompt Or cdlOFNPathMustExist Or cdlOFNNoReadOnlyReturn
' Set Dialog title
CommonDialog2.DialogTitle = "Save to a Wave File"
' Set filters
CommonDialog2.Filter = "All Files (*.*)|*.*|Wave Files " & "(*.wav)|*.wav"
' Specify default filter
CommonDialog2.FilterIndex = 2
' Display the Save dialog box
CommonDialog2.ShowSave

WriteToWav = CommonDialog2.Filename

Exit Sub
ErrHandler:
    'User pressed the Cancel button, do not show error
    If Not (err.Number = 32755) Then
        Call ErrorReport("An error occurred while selecting a wav file to output to.", vbExclamation)
    End If
End Sub

Private Sub SaveScript(ShowDialog As Boolean, Encrypt As Boolean)
Dim FileExists As Boolean
Dim I As Integer

If ShowDialog = True Then
    On Error GoTo 20
    CommonDialog1.InitDir = App.path
    CommonDialog1.CancelError = True
    CommonDialog1.DefaultExt = ".txt"
    CommonDialog1.Filter = "Text File (*.txt)|*.txt|"
    CommonDialog1.DialogTitle = "Save Script"
    CommonDialog1.action = 2
End If

If ExceptionHandlers = True Then On Error GoTo ErrorHandler
StartSaving:
I = Len(Dir$(CommonDialog1.Filename))
If err Or I = 0 Then
    FileExists = False
Else
    FileExists = True
End If

If FileExists = True Then
    If ShowDialog = True Then If MsgBox("Overwrite existing file?", vbYesNo + vbQuestion + vbDefaultButton2, "Virtual Hypnotist") = vbNo Then Exit Sub

    'erase contents of old file
    Open CommonDialog1.Filename For Output As #1
        Print #1, ""
    Close #1
End If

'Save File
If Encrypt = False Then
    'standard save
    Open CommonDialog1.Filename For Binary Access Write As #1
        Put #1, , Script.Text
    Close #1
Else
    'encrypt file using simple XOR
    Dim EX As New EncryptXOR
    Call EX.EncryptFile(Script.Text, CommonDialog1.Filename, "VHYPNO")
End If
         
Me.Caption = "Script Maker - " + CommonDialog1.Filename

OrigScript = Script.Text
ScriptChanged = False

20 Exit Sub
ErrorHandler:
err.Source = "Script Maker - SaveScript"
Call ErrorReport("An error occurred while saving the script file.", vbCritical)
Exit Sub
End Sub

Private Sub MenuErrorHandler()
Call ErrorReport("An error occurred in the Script Maker.", vbExclamation)
End Sub
