|
03/04/2007, 10:06 AM
|
#1 (permalink)
|
|
Member
Join Date: Jan 2006
Location: Northern Virginia
Posts: 4,352
Thanks: 11
Thanked 95 Times in 33 Posts
|
MortScript: Standards/Best Practices
With all of the scripts being generated we need to discuss some standards and best practices that we should be following to avoid chaos.
Some rules I've been following.
1) Install simple scripts to \Windows\Start Menu\Programs\MortScript. If there is more than one script involved either create a subfolder and put it in there or make a cab installer to install like a regular app under \Program Files.
Scripts or shortcuts to scripts under \Windows\Start Menu\Programs\* can be set to buttons and started via voice command.
If you have a super duper script that you think needs special attention link it in the Programs folder and give it a nice icon.
2) Always get the current script path using SystemPath( "ScriptPath" ) when calling dependent scripts so that your scripts can be moved anywhere and still work.
I'm flexible on 1 if someone has a better idea. I don't like putting scripts in the \Program Files\MortScript folder or below. For the more elaborate applications with a cab install it should be installed under \Program Files in its own folder like a regular app with links back to the Programs folder.
Table of Contents
1) Script icons
MortScript: Standards/Best Practices
http://discussion.treocentral.com/sh...4&postcount=81
2) Cab template
MortScript: Standards/Best Practices
3) App delivery practices
http://discussion.treocentral.com/sh...8&postcount=34
4) Where to put registry values for your app
http://discussion.treocentral.com/sh...3&postcount=56
5) We Must Support Mort!
http://discussion.treocentral.com/sh...&postcount=111
6) Cab installs to storage card tips and tricks
http://discussion.treocentral.com/sh...&postcount=113
Last edited by hannip; 05/27/2007 at 01:41 PM.
|
|
|
03/04/2007, 10:45 AM
|
#2 (permalink)
|
|
Member
Join Date: Dec 2003
Location: Sac
Posts: 4,552
Thanks: 4
Thanked 14 Times in 14 Posts
|
Sounds good to me
__________________
Palm III > HS Visor > Treo 600 > Treo 650 > Treo 750 > Treo Pro > PrePlus GSM?
"95% of all software issues are due to USER ERROR."
|
|
|
03/04/2007, 11:09 AM
|
#3 (permalink)
|
|
Member
Join Date: Oct 2006
Posts: 2,098
Thanks: 17
Thanked 4 Times in 4 Posts
|
Sounds great.
|
|
|
03/04/2007, 12:04 PM
|
#4 (permalink)
|
|
Member
Join Date: Jan 2006
Location: Northern Virginia
Posts: 4,352
Thanks: 11
Thanked 95 Times in 33 Posts
|
Icons
Now that we know how to make resource files containing icons should we share a common resource file between our scripts or have separate resource files?
I had envisioned a shared ScriptIcons.dll resource file containing the icons for scripts with installers that could be versioned by setting a registry field such as this.
[HKLM\Software\Mort's MortScript]
ScriptIconsVersion 8
Mort in his infinite wisdom provided a setup.dll to be used in cab installs. I propose we use an install/uninstall template for our scripts. Attached below is a cab template that I propose we use for our installs.
Intructions for use:
1) download ScriptIcons.cab
2) change the name to <your app name>.cab
3) change the app name and install dir in the cab. The install dir should be unique to your application such as \Program Files\<your app name>
4) replace the ScriptIcons.dll in the cab with the latest version for your app.
5) add your scripts, shortcuts, etc to the cab.
6) edit the install.mscr to set the iconVersReq to the version number needed by your app. The version number will be an incrementing integer value each time new icons are added to ScriptIcons.dll. Add any additional customizations to the install.mscr and uninstall.mscr as needed and replace the ones in the cab with yours.
7) save your cab, test, and zip up to make it available.
Code:
# install.mscr - Used for post processing of a cab installation
# Notes:
# - Requires MortScript's setup.dll to be used by the cab.
# - MortScript.exe must be installed in the %installDir% along with this script
#
# what is our path?
instPath = SystemPath( "ScriptPath" )
# check if icon resource needs updating?
iconFile = "ScriptIcons.dll"
iconVersReq = 8
iconVers = 0
iconRefCount = 0
If ( FileExists( instPath \ iconFile ) )
If ( FileExists( "\Windows" \ iconFile ) )
If ( RegValueExists( "HKLM", "Software\Mort's MortScript", "ScriptIconsVersion" ) )
iconVers = RegRead( "HKLM", "Software\Mort's MortScript", "ScriptIconsVersion" )
iconRefCount = RegRead( "HKLM", "Software\Mort's MortScript", "ScriptIconsRefCount" )
EndIf
If ( iconVers < iconVersReq )
Copy( instPath \ iconFile , "\Windows" \ iconFile, 1 )
RegWriteString( "HKLM", "Software\Mort's MortScript", "ScriptIconsVersion", iconVersReq )
EndIf
iconRefCount = iconRefCount + 1
RegWriteDWord( "HKLM", "Software\Mort's MortScript", "ScriptIconsRefCount", iconRefCount )
Else
Copy( instPath \ iconFile , "\Windows" \ iconFile, 1 )
RegWriteString( "HKLM", "Software\Mort's MortScript", "ScriptIconsVersion", iconVersReq
RegWriteDWord( "HKLM", "Software\Mort's MortScript", "ScriptIconsRefCount", 1 )
EndIf
EndIf
Delete( instPath \ iconFile )
ShowWaitCursor
# Insert customizations here
HideWaitCursor
Code:
# uninstall.mscr - Used for pre processing of a cab uninstall
# Notes:
# - Requires MortScript's setup.dll to be used by the cab.
# - MortScript.exe must be installed in the %installDir% along with this script
#
# what is our path?
instPath = SystemPath( "ScriptPath" )
# check if icon resource needs to be deleted.
iconFile = "ScriptIcons.dll"
If ( FileExists( "\Windows" \ iconFile ) )
If ( RegValueExists( "HKLM", "Software\Mort's MortScript", "ScriptIconsRefCount" ) )
iconRefCount = RegRead( "HKLM", "Software\Mort's MortScript", "ScriptIconsRefCount" )
iconRefCount = iconRefCount - 1
If ( iconRefCount <= 0 )
Delete( "\Windows" \ iconFile )
RegDelete( "HKLM", "Software\Mort's MortScript", "ScriptIconsRefCount" )
RegDelete( "HKLM", "Software\Mort's MortScript", "ScriptIconsVersion" )
Else
RegWriteDWord( "HKLM", "Software\Mort's MortScript", "ScriptIconsRefCount", iconRefCount )
EndIf
EndIf
EndIf
ShowWaitCursor
# Insert customizations here
HideWaitCursor
Last edited by hannip; 08/10/2007 at 08:47 PM.
Reason: Version 8
|
|
|
03/04/2007, 03:34 PM
|
#5 (permalink)
|
|
Member
Join Date: Jan 2006
Location: Northern Virginia
Posts: 4,352
Thanks: 11
Thanked 95 Times in 33 Posts
|
Treo Keylight - using new standards
Here is the Treo Keylight cab utilizing the new cab template with customized install/uninstall scripts and shortcut with icon.
This cab has a cool feature in that it doesn't need a separate MortScript install. It also demonstrates how to create a special shortcut that uses the ScriptIcons.dll.
This is posted here so that it can be used as an example for other cab installs.
Code:
# install.mscr - Used for post processing of a cab installation
# Notes:
# - Requires MortScript's setup.dll to be used by the cab.
# - MortScript.exe must be installed in the %installDir% along with this script
#
# what is our path?
instPath = SystemPath( "ScriptPath" )
# check if icon resource needs updating?
iconFile = "ScriptIcons.dll"
iconVersReq = 4
iconVers = 0
iconRefCount = 0
If ( FileExists( instPath \ iconFile ) )
If ( FileExists( "\Windows" \ iconFile ) )
If ( RegValueExists( "HKLM", "Software\Mort's MortScript", "ScriptIconsVersion" ) )
iconVers = RegRead( "HKLM", "Software\Mort's MortScript", "ScriptIconsVersion" )
iconRefCount = RegRead( "HKLM", "Software\Mort's MortScript", "ScriptIconsRefCount" )
EndIf
If ( iconVers < iconVersReq )
Copy( instPath \ iconFile , "\Windows" \ iconFile, 1 )
RegWriteString( "HKLM", "Software\Mort's MortScript", "ScriptIconsVersion", iconVersReq )
EndIf
iconRefCount = iconRefCount + 1
RegWriteDWord( "HKLM", "Software\Mort's MortScript", "ScriptIconsRefCount", iconRefCount )
Else
Copy( instPath \ iconFile , "\Windows" \ iconFile, 1 )
RegWriteString( "HKLM", "Software\Mort's MortScript", "ScriptIconsVersion", iconVersReq
RegWriteDWord( "HKLM", "Software\Mort's MortScript", "ScriptIconsRefCount", 1 )
EndIf
EndIf
Delete( instPath \ iconFile )
ShowWaitCursor
# install the applicable shortcut
CreateShortcut( "\Windows\Start Menu\Programs\Keylight.lnk",\
"""" & instPath \ "MortScript.exe"" """ & instPath \ "Treo Keylight.mscr""?ScriptIcons.dll,-108" )
HideWaitCursor
Code:
# uninstall.mscr - Used for pre processing of a cab uninstall
# Notes:
# - Requires MortScript's setup.dll to be used by the cab.
# - MortScript.exe must be installed in the %installDir% along with this script
#
# what is our path?
instPath = SystemPath( "ScriptPath" )
# check if icon resource needs to be deleted.
iconFile = "ScriptIcons.dll"
If ( FileExists( "\Windows" \ iconFile ) )
If ( RegValueExists( "HKLM", "Software\Mort's MortScript", "ScriptIconsRefCount" ) )
iconRefCount = RegRead( "HKLM", "Software\Mort's MortScript", "ScriptIconsRefCount" )
iconRefCount = iconRefCount - 1
If ( iconRefCount <= 0 )
Delete( "\Windows" \ iconFile )
RegDelete( "HKLM", "Software\Mort's MortScript", "ScriptIconsRefCount" )
RegDelete( "HKLM", "Software\Mort's MortScript", "ScriptIconsVersion" )
Else
RegWriteDWord( "HKLM", "Software\Mort's MortScript", "ScriptIconsRefCount", iconRefCount )
EndIf
EndIf
EndIf
ShowWaitCursor
# delete shortcut
If ( FileExists( "\Windows\Start Menu\Programs\Keylight.lnk" ) )
Delete( "\Windows\Start Menu\Programs\Keylight.lnk" )
EndIf
HideWaitCursor
Last edited by hannip; 03/13/2007 at 08:17 PM.
Reason: Uses renamed icon resource file and new method to create a shortcut
|
|
|
03/04/2007, 03:55 PM
|
#6 (permalink)
|
|
Member
Join Date: Oct 2006
Posts: 2,098
Thanks: 17
Thanked 4 Times in 4 Posts
|
You are the best.Thanks for helping me out in my troubled day.
Phil C
Update,
WOW!!!!! 1 cab install how sweet
Last edited by slingbox; 03/04/2007 at 05:33 PM.
Reason: update
|
|
|
03/04/2007, 05:37 PM
|
#7 (permalink)
|
|
Member
Join Date: Oct 2006
Posts: 2,098
Thanks: 17
Thanked 4 Times in 4 Posts
|
hannip
So are we looking at putting scripts in cab with mort files now and how are we going to work icons into?
|
|
|
03/04/2007, 05:41 PM
|
#8 (permalink)
|
|
Member
Join Date: Jan 2006
Location: Northern Virginia
Posts: 4,352
Thanks: 11
Thanked 95 Times in 33 Posts
|
All scripts that follow this template will share the MortIcons.exe icon resource. Whenever we add a new icon for a new install we will increment the version number in the install script so that older installs don't backlevel the icon resource file.
|
|
|
03/04/2007, 05:49 PM
|
#9 (permalink)
|
|
Member
Join Date: Dec 2006
Posts: 63
Thanks: 0
Thanked 0 Times in 0 Posts
|
right now the morticons has 2 icon for keylight should we decide on one icon.
|
|
|
03/04/2007, 05:50 PM
|
#10 (permalink)
|
|
Member
Join Date: Jan 2006
Location: Northern Virginia
Posts: 4,352
Thanks: 11
Thanked 95 Times in 33 Posts
|
It's pointing to the first one now so yeah, we can replace the 2nd one with a new one for another app.
|
|
|
03/04/2007, 05:52 PM
|
#11 (permalink)
|
|
Member
Join Date: Dec 2006
Posts: 63
Thanks: 0
Thanked 0 Times in 0 Posts
|
but i think slingbox like the second one better....
|
|
|
03/04/2007, 05:52 PM
|
#12 (permalink)
|
|
Member
Join Date: Oct 2006
Posts: 2,098
Thanks: 17
Thanked 4 Times in 4 Posts
|
HOW SWEET!!!!!
Im looking at contents of keylight cab and how very easy this will be.
1)So we dont need are first version of mortscript on board if we follow cab with same install method.
2)How do we add icon to the resource file.
|
|
|
03/04/2007, 05:55 PM
|
#13 (permalink)
|
|
Member
Join Date: Jan 2006
Location: Northern Virginia
Posts: 4,352
Thanks: 11
Thanked 95 Times in 33 Posts
|
give me icons and I rebuild the resource with them.
|
|
|
03/04/2007, 05:57 PM
|
#14 (permalink)
|
|
Member
Join Date: Jan 2006
Location: Northern Virginia
Posts: 4,352
Thanks: 11
Thanked 95 Times in 33 Posts
|
Quote:
Originally Posted by fearthefox
but i think slingbox like the second one better....
|
lol, well keep it in there then so he can change his shortcuts.
|
|
|
03/05/2007, 12:35 AM
|
#15 (permalink)
|
|
Member
Join Date: Jan 2007
Location: Atlanta
Posts: 380
Thanks: 0
Thanked 1 Time in 1 Post
|
I'm scared of the CAB. Does that make me a weenie?
Seriously, there's good work goin on here. Question -- what if I wanted to bundle 30 or so voice-callable scripts into a single folder, say under the Windows\Start Menu\Programs\[MyNameHere] structure. Instead of the standard folder icon you get when a subdir is created as shown, I wanna create my own icon... let's say a folder with Mort's icon on it... This to keep my many scripts segregated for what reason I can't seem to justify past mere curiosity.
If it's not a good idea, I can accept that, too. Just wanted to know how to do it.
-- JDC
|
|
|
03/05/2007, 12:47 AM
|
#16 (permalink)
|
|
Member
Join Date: Jan 2006
Location: Northern Virginia
Posts: 4,352
Thanks: 11
Thanked 95 Times in 33 Posts
|
Yeah, if you have a large bundle like that it makes sense for them to have their own folder. Just curious why a subfolder under the standard \Windows\Start Menu\Programs\MortScript folder could not be just as good since they are voice callable? I can see if you wanted to do it for easier access or if you are worried about hierarchy precedence issues.
I mean if it's for your own use you can do whatever you like, but I'm worried that if everyone wants to create there own folder of scripts in the Programs folder it will fill up with folders quick.
Then again if you aren't using a cab install and all of your scripts are path immune you could leave it to the installer to pick where to put them.
|
|
|
03/05/2007, 01:15 AM
|
#17 (permalink)
|
|
Member
Join Date: Jan 2007
Location: Atlanta
Posts: 380
Thanks: 0
Thanked 1 Time in 1 Post
|
That's what worries me about the CAB install... It's like a dictator treading on my space... I don't know where the stuff will land (or tread) until after the install. Some CAB installs are so "good" I can never find where they went.
The main reason others might want a folder of "my own" is to serve as a temp directory to test my stuff. if they like 'em, they can move to a std scripts folder. Plus, I have so many apps under the "PROGRAMS" structure, in addition to scripts and shortcut .lnk, that a subfolder as described works out nicely. See attached. What's so special about the Games Folder (icon)? All I did was create a Folder called "Games".
-- JDC
|
|
|
03/05/2007, 01:33 AM
|
#18 (permalink)
|
|
Member
Join Date: Jan 2006
Location: Northern Virginia
Posts: 4,352
Thanks: 11
Thanked 95 Times in 33 Posts
|
Yeah, I don't know how to get an icon on the folder like that. hmm.
As I suggested to Slingbox in a PM I think we only want a cab install for our popular scripts to make it easy for the mass public to consume. Like Treo Keylight, your new XCast app, TreoVibe etc. For a group of voice activated scripts I think it's best to just let the user pick and choose which ones they want to copy to the device. If some become wildly popular we can always cab them up later.
Wooohooo! this post was my 2,000 post at treo central.
|
|
|
03/05/2007, 12:49 PM
|
#19 (permalink)
|
|
Member
Join Date: Jan 2007
Location: Atlanta
Posts: 380
Thanks: 0
Thanked 1 Time in 1 Post
|
Quote:
Originally Posted by hannip
Yeah, I don't know how to get an icon on the folder like that. hmm.
As I suggested to Slingbox in a PM I think we only want a cab install for our popular scripts to make it easy for the mass public to consume. Like Treo Keylight, your new XCast app, TreoVibe etc.
|
.. agreed
Quote:
Originally Posted by hannip
For a group of voice activated scripts I think it's best to just let the user pick and choose which ones they want to copy to the device. If some become wildly popular we can always cab them up later.
|
... also agreed, but still curious about the icon thingie.
Quote:
Originally Posted by hannip
Wooohooo! this post was my 2,000 post at treo central. 
|
 Congrats (if you percieve it as an honor).
BTW, you're averaging slightly over 150 posts per month... I've really only been contributing for about a month and am slightly over 150. At what point last year did your brain begin consuming itself from the inside out?
|
|
|
03/05/2007, 03:15 PM
|
#20 (permalink)
|
|
Member
Join Date: Jan 2006
Location: Northern Virginia
Posts: 4,352
Thanks: 11
Thanked 95 Times in 33 Posts
|
I just noticed that uninstalling MortScript eats our icon version info. I'll change the install/uninstall script to move them elsewhere. Will post tonight.
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
All times are GMT -4. The time now is 10:18 AM.
|
|