This topic is meant to discuss the implementation of a common API (Application Programming Interface) which enables developers to create their scripts in a simpler way.
One pratical use of an API is the reduction of code lines needed to get tasks done like creating shortcuts for example and the simplification of coding making it easier to understand for others.
Also worth mentioning that using common functions also enables scripts to survive longer to overall project changes, meaning that a script done today will probably still work next year if a common method is adopted.
Please note that this API is mostly meant for Application scripts - the scripts which are supposed to add third party programs already supported on different platforms like Win9x, WinXP and Vista.
Both nativeEx and VistaPE already have their built-in API which is already used for some of the tasks described here - but we should work to create a common set of functions that can be used on both projects and eventually on the next projects to appear.
Flexibility and Expandability are good keywords to describe the future of these scripts.
So let the discussion start and see if we can in fact achieve this goal.
How do we build an API function under WinBuilder?
Using the [variables] section from the script.project file on each project it is possible to define new "commands" - so imagine this example:
[variables] MakeDesktopShortcut=run,%API%,CreateDesktopShortcut
on the %API% file:
[CreateDesktopShortcut] .... ... ..
and while running:
[process] MakeDesktopShortcut,This is an Example,myExampleFolder\myExample.exe
Or even a FileCopyExpand command which looks for a file from txtsetup.sif and decides whether to Cab Extract or copy the file from source.
There are a lot of ways to use this API and the best part is that Application scripts could then be used on any supported projects without much worries.
Meaning also that .script developers code once and others can use it on the project they prefer without changes..
-------------------------------------------------------------------------------------------
Proposed API
Global Variables
%Shell% - to know which shell is being used (using explorer as default)
Functions
Shortcut_Desktop - to create shortcut on desktop
Shortcut_StartMenu - same as above for Start Menu (allows to specify folder)
Shortcut_Startup - Add shortcut on startup list
Files_Extract - Extract all files inside the script on "folder" to the programs's folder
---------------------------------------------------------------------------------------------
Script Template
[variables]
%application%=myExample.exe
%shortcut_name%=This is my Example
%application_dir%=myExampleDir
[process]
Shortcut_Desktop
Shortcut_StartMenu,Applications
Files_Extract
---------------------------------------------------------------------------------------------
What does the community think about this?
Edited by Nuno Brito, 06 May 2007 - 06:40 PM.