IMPORTANT ANNOUNCEMENT

These forums were permanently set to read-only mode on July 20, 2022. From that day onwards, no new posting or comment is allowed on the site, but the historical content remains intact and searchable.

A new location for posting questions about PlanetPress Suite is now available:

OL Learn - PlanetPress Classic (opens in new tab)

Topic Options
#38139 - 12/29/11 01:01 PM Macros
Kennet Offline
OL Toddler

Registered: 12/28/11
Posts: 46
Loc: Denmark
Hi

I was told a while back by our retailer, that macros could be scripted in Javascript OR VBscript.

Is it only possible in Javascript?

Top
#38141 - 12/29/11 01:18 PM Re: Macros [Re: Kennet]
Raphael Lalonde Lefebvre Offline
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
#38144 - 12/29/11 01:27 PM Re: Macros [Re: Raphael Lalonde Lefebvre]
Kennet Offline
OL Toddler

Registered: 12/28/11
Posts: 46
Loc: Denmark
Hi Raphaël

I've actually allready tried that, and the macro doesn't show up in PrintShop Mail. The VBscript-syntax is correct (tested it via double-clicking the .vbs) - i guess i might have messed up somewhere.

But thanks for the reply - then i know its worth keep trying to get it to work. I'll look over my code again :-)

Top
#38146 - 12/29/11 02:21 PM Re: Macros [Re: Kennet]
Kennet Offline
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:
Code:
' ****************************************************************************
' 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]
Raphael Lalonde Lefebvre Offline
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! smile

Regards,
Raphaël Lalonde Lefebvre

Top