#38141 - 12/29/11 01:18 PM
Re: Macros
[Re: Kennet]
|
OL Expert
Registered: 10/14/05
Posts: 4956
Loc: Objectif Lune Montreal
|
Kennet,
I just did some research, and it turns out that yes, vbscript is also supported. You'd have to use a .vbs extension for the macro files, and of course, port the code to vbscript.
Unfortunately, all I've ever seen are javascript macros, so I don't have any premade examples of a vbscript one. However, you could take the javascript macro that I've posted in another of your posts, and convert it to vbscript. You must keep all the same function declarations and descriptors, so it'll look very similar, just with vbscript syntax as opposed to javascript syntax.
Regards, Raphaël Lalonde Lefebvre
|
Top
|
|
|
|
#38146 - 12/29/11 02:21 PM
Re: Macros
[Re: Kennet]
|
OL Toddler
Registered: 12/28/11
Posts: 46
Loc: Denmark
|
... And it works now. For others who might be needing the VBScript method in the future, my altered version of your code follows: ' ****************************************************************************
' Function: TEMPLATE
'
' Standard template for PSM JavaScript macros.
'
' Language: VBScript
' Originally written in Javascript by: Raphaël Lalonde Lefebvre - Objectif Lune
' *** This macro is provided as is, it will not be supported, and no rights can be claimed ***
' *** Use at your own risk ***
'
' INSTRUCTIONS:
'
' To install, place this .vbs file in "Macro" folder of the PrintShop Mail's directory. If you do not see it, create it. Once done, restart PrintShop Mail,
' and the "TEMPLATE" function will appear.
'
' ****************************************************************************
' Function descriptor.
Function psmGetFunctionDescriptor(index)
' Descriptor syntax explanation:
' The first "STRING" is the function's category under which it will appear in the Expression Editor's list of functions.
' It does not have any impact on what the function returns, it's only used to place it in the right category. Ideally, it will
' be the same as the function's return type.
' The second "STRING" is the function's return type.
' Some supported types are:
' STRING: A string.
' NUMBER: A number.
' LOGICAL: True/False value.
' "index" seems to be a PSM system variable, and should be left alone.
if (index = 0) then
psmGetFunctionDescriptor = "STRING STRING TEMPLATE(STRING{string1;First string.},STRING{string2;Second string.})" & Chr(9) & "Enter function's description here. It is followed by usage examples." & Chr(9) & "TEMPLATE(""Hello"", ""World"") => Hello World"
else
psmGetFunctionDescriptor = ""
end if
End function
' Main function.
' This is the macro's main code. It should always have "psm" as the prefix.
' If you want a TEMPLATE macro, you need to call the main function "psmTEMPLATE".
' This template's sample code takes 2 strings as parameters, and displays them
' with a space between them.
Function psmTEMPLATE(string1, string2)
psmTEMPLATE = string1 & " " & string2
End function
' Below are some system functions. They should not be altered unless you know what y
Warning=""
Function psmGetWarning()
result = Warning
Warning = ""
psmGetWarning = result
End function
causeParameterNo = -1
Function psmGetWarningCauseParameter()
result = causeParameterNo
causeParameterNo = -1
psmGetWarningCauseParameter = result
End function
LanguageSet = ""
Function psmSetLanguage(lan)
LanguageSet = lan
End function
|
Top
|
|
|
|
#38174 - 01/04/12 01:48 PM
Re: Macros
[Re: Kennet]
|
OL Expert
Registered: 10/14/05
Posts: 4956
Loc: Objectif Lune Montreal
|
Kennet, Tested this template, and it does work. Thanks you very much for your contribution, this will be very useful for those who are more familiar with vbscript, and want to do macros!  Regards, Raphaël Lalonde Lefebvre
|
Top
|
|
|
|
|
|