Results 1 to 2 of 2
  1.    #1  
    In the last scripts that I wrote, I experimented with the "path" variables. I was able to create a generic header section that can be used in ALL my scripts without changing the code. I also created a subroutine, which I'm also gunna include in my scripts -- so that I can repeat the last command that was executed via mortscript. See code below.

    In essence, I'll be able able to issue the voice command:

    START AGAIN

    if I want to repeat the execution of the last MortScript executed. See the 2 examples below to see the generic code sections.

    Code:
    # PhoneOFF.mscr
    # 
    # Turn Phone OFF if ON, displays message if already OFF.
    # 
    #
    # Platform(s):	PPC
    #
    # PPC Tested:	Palm Treo 700w, Windows Mobile V5.1.195 Bld 14929.2.2.1
    #
    # Author: jdcochran@hotmail.com
    # Rel. 0.b  3.2.2007
    #
    # Release Note(s): Added generic code to extract paths; added "SaveLastCommand" subroutine
    # 
    # 
    
    Platform  = MortScriptType()
    AppDir = "\Windows\"
    App = "\wrlsmgr.exe"
    AppWindowName = "Wireless Manager"
    
    If (Platform eq "PC")
    	Message ("This App was created for PPC... script will abort.", ThisScriptName)
    
    	Call ExitScript
    EndIf
    
    ThisScriptPath = SystemPath("ScriptPath")
    ThisScriptName = SystemPath("ScriptName") & SystemPath("ScriptExt")
    LastScriptCommand = ThisScriptPath &"\" & "Again.mscr"
    
    Call SaveLastCommand 
    
    Call ReadPhoneStatus
    
    If (PhoneState = 0)
    	SleepMessage (5, "Phone is already OFF... script will abort.", ThisScriptName, 1)
    	Call ExitScript
    EndIf
    
    Run (AppDir & App)
    
    WaitForActive( AppWindowName, 10 )
    
    MouseClick( AppWindowName, 120,120 )
    
    Sleep (2000)
    
    Close (AppWindowName)
    
    #SendLeftSoft
    
    Sub ReadPhoneStatus
    	PhoneState = RegRead("HKLM", "System\State\Phone", "Cellular System Available")
    EndSub
    
    Sub SaveLastCommand
    	WriteLine = "CallScript (""" &ThisScriptPath &"\" &ThisScriptName & """)"
    	WriteFile (LastScriptCommand, WriteLine)
    EndSub
    
    Sub ExitScript
    	Exit
    	KillScript (ThisScriptName)
    EndSub

    Code:
    # PhoneON.mscr
    # 
    # Turn Phone ON if OFF, displays message if already ON.
    # 
    #
    # Platform(s):	PPC
    #
    # PPC Tested:	Palm Treo 700w, Windows Mobile V5.1.195 Bld 14929.2.2.1
    #
    # Author: jdcochran@hotmail.com
    # Rel. 0.b  3.1.2007
    #
    # Release Note(s): Added generic code to extract paths; added "SaveLastCommand" subroutine  
    # 
    # 
    
    Platform  = MortScriptType()
    ThisScriptName = "PhoneON.mscr"
    AppDir = "\Windows\"
    App = "\wrlsmgr.exe"
    AppWindowName = "Wireless Manager"
    
    If (Platform eq "PC")
    	Message ("This App was created for PPC... script will abort.", ThisScriptName)
    
    	Call ExitScript
    EndIf
    
    ThisScriptPath = SystemPath("ScriptPath")
    ThisScriptName = SystemPath("ScriptName") & SystemPath("ScriptExt")
    LastScriptCommand = ThisScriptPath &"\" & "Again.mscr"
    
    Call SaveLastCommand
    
    Call ReadPhoneStatus
    
    If (PhoneState = 4)
    	SleepMessage (5, "Phone is already ON... script will abort.", ThisScriptName, 1)
    	Call ExitScript
    EndIf
    
    Run (AppDir & App)
    
    WaitForActive( AppWindowName, 10 )
    
    MouseClick( AppWindowName, 120,120 )
    
    Sleep (2000)
    
    Close (AppWindowName)
    
    #SendLeftSoft
    
    Sub ReadPhoneStatus
    	PhoneState = RegRead("HKLM", "System\State\Phone", "Cellular System Available")
    EndSub
    
    Sub SaveLastCommand
    	WriteLine = "CallScript (""" &ThisScriptPath &"\" &ThisScriptName & """)"
    	WriteFile (LastScriptCommand, WriteLine)
    EndSub
    
    Sub ExitScript
    	Exit
    	KillScript (ThisScriptName)
    EndSub
  2.    #2  
    Looks like you're all alone on this one, JohnnyBoy.

Posting Permissions