Read Scripting Parameters within a Filter
Hello,
I'd like to have a Plug In which can read Scripting Parameters and run accordignly.
One of the code samples in the SDK is called "PoorMansTypeTool".
In its documentation it is said to be able to "Read scripting parameters".
I look into its code yet I couldn't figure how it does it.
Let's say I have a script with a variable 'a'.
The script launches a filter from the filter lists and want to pass the valu of the parameter 'a' to the filter.
How could that be done?
Are there any constraints on the parameter type, size, etc?
Has anyone tried it before?
If someone could guide me through the plug in code I'd be happy.
Thank You.
// make this a function so we can hide these from harness script
main();
function main() {
// Save the current preferences
var startRulerUnits = preferences.rulerUnits;
var startTypeUnits = preferences.typeUnits;
var startDisplayDialogs = displayDialogs;
// Set Photoshop to use pixels and display no dialogs
preferences.rulerUnits = Units.PIXELS;
preferences.typeUnits = TypeUnits.PIXELS;
displayDialogs = DialogModes.NO;
// make this stuff controlled by the harness
var maxTime = 1 * 60;
var iterations = 5;
var percIncrease = 20;
var timeIt = new Timer();
var tests = 0;
var errors = 0;
var eArray = new Array();
var dissolveLog = new File( "~/Desktop/Dissolve.log" );
dissolveLog.open( "w", "TEXT", "????" );
dissolveLog.writeln( "width,\theight,\tdepth,\tpercent,\tdoc create time,\tdissolve time" );
var maxWidth = 30000;
var minWidth = 256;
var incWidth = parseInt( (maxWidth - minWidth) / iterations );
if ( incWidth == 0 )
incWidth = 1;
var maxHeight = 30000;
var minHeight = 256;
var incHeight = parseInt( (maxHeight - minHeight) / iterations );
if ( incHeight == 0 )
incHeight = 1;
// start clean
while (documents.length) {
activeDocument.close(SaveOptions.DONOTSAVECHANGES);
var d = BitsPerChannelType.EIGHT;
for ( var w = minWidth; w < maxWidth; w += incWidth ) {
for ( var h = minHeight; h < maxHeight; h += incHeight ) {
try {
var timeImport = new Timer();
if ( d == BitsPerChannelType.EIGHT )
d = BitsPerChannelType.SIXTEEN;
else
d = BitsPerChannelType.EIGHT;
app.documents.add(UnitValue(w, "px"), UnitValue(h,"px"), undefined, "Dissolve Test", undefined, undefined, undefined, d);
timeImport.stop();
if ( activeDocument.width != w )
error++; // alert( activeDocument.width + ", " + w );
if ( activeDocument.height != h )
error++; // alert( activeDocument.height + ", " + h );
if ( d == 16 && activeDocument.bitsPerChannel != BitsPerChannelType.SIXTEEN )
error++; // alert( activeDocument.bitsPerChannel + ", " + d );
if ( d == 8 && activeDocument.bitsPerChannel != BitsPerChannelType.EIGHT )
error++; // alert( activeDocument.bitsPerChannel + ", " + d );
if ( activeDocument.bitsPerChannel == BitsPerChannelType.ONE )
error++; // alert( activeDocument.bitsPerChannel + ", " + d );
FitOnScreen(); // this makes everything really slow
var historyState = activeDocument.activeHistoryState;
for ( var dPerc = 0; dPerc <= 100; dPerc += percIncrease ) {
tests++;
var timeDissolve = new Timer();
Dissolve(dPerc);
timeDissolve.stop();
// WaitForRedraw(); // guess what this does to our slowness ness er
dissolveLog.write(w + ",\t" + h + ",\t" + d + ", " + dPerc );
dissolveLog.writeln(",\t" + timeImport.getTime() + ", " + timeDissolve.getTime() );
WaitForRedraw();
activeDocument.activeHistoryState = historyState;
if ( timeIt.getElapsed() > maxTime ) {
w = maxWidth + 1;
h = maxHeight + 1;
dPerc = 101;
catch(e) {
alert(e + ":" + e.line);
if ( e.message.search(/cancel/i) != -1 ) {
w = maxWidth + 1;
h = maxHeight + 1;
eArray[eArray.length] = e;
errors++;
// debugger;
} // end catch
} // end for height
} // end for width
dissolveLog.writeln( errors + " errors. " + tests + " tests in " + timeIt.getElapsed() + " seconds. " + tests/timeIt.getElapsed() + " tests/sec.");
dissolveLog.close();
dissolveLog.execute();
// end clean
while (documents.length) {
activeDocument.close(SaveOptions.DONOTSAVECHANGES);
// Reset the application preferences
preferences.rulerUnits = startRulerUnits;
preferences.typeUnits = startTypeUnits;
displayDialogs = startDisplayDialogs;
// 1) " FAIL" for failures
// 2) " PASS" for test results OK
// 3) " BUG" for known bugs, have the file name give the bug number
// 4) "ERROR" this comes from the harness if the script barfed/exception,
return errors == 0 ? ' PASS' : ' FAIL';
} // end function main
Function WaitForRedraw
Usage: Use it to force Photoshop to redraw the screen before continuing
Example:
WaitForRedraw();
function WaitForRedraw() {
var keyID = charIDToTypeID( "Stte" );
var desc = new ActionDescriptor();
desc.putEnumerated( keyID, keyID, charIDToTypeID( "RdCm" ) );
executeAction( charIDToTypeID( "Wait" ), desc, DialogModes.NO );
// WaitNSeconds, slow the script down so you can watch and figure out issues
function WaitNSeconds(seconds) {
startDate = new Date();
endDate = new Date();
while ((endDate.getTime() - startDate.getTime()) < (1000 * seconds))
endDate = new Date();
// FitOnScreen, fits the document and redraws the screen
function FitOnScreen() {
var id45 = charIDToTypeID( "slct" );
var desc7 = new ActionDescriptor();
var id46 = charIDToTypeID( "null" );
var ref1 = new ActionReference();
var id47 = charIDToTypeID( "Mn " );
var id48 = charIDToTypeID( "MnIt" );
var id49 = charIDToTypeID( "FtOn" );
ref1.putEnumerated( id47, id48, id49 );
desc7.putReference( id46, ref1 );
executeAction( id45, desc7, DialogModes.NO );
// Dissolve, given a percentage
function Dissolve( dPercent ) {
var id18 = stringIDToTypeID( "d9543b0c-3c91-11d4-97bc-00b0d0204936" );
var desc3 = new ActionDescriptor();
var id19 = charIDToTypeID( "Amnt" );
var id20 = charIDToTypeID( "#Prc" );
desc3.putUnitDouble( id19, id20, dPercent );
var id21 = charIDToTypeID( "disP" );
var id22 = charIDToTypeID( "mooD" );
var id23 = charIDToTypeID( "moD1" );
desc3.putEnumerated( id21, id22, id23 );
executeAction( id18, desc3, DialogModes.NO );
// DissolveOld, our old scripting params was this
// an interesting test would be to see the old plug-in vs the current one
function DissolveOld( dPercent ) {
var id12 = charIDToTypeID( "disS" );
var desc3 = new ActionDescriptor();
var id13 = charIDToTypeID( "Amnt" );
var id14 = charIDToTypeID( "#Prc" );
desc3.putUnitDouble( id13, id14, dPercent );
var id15 = charIDToTypeID( "disP" );
var id16 = charIDToTypeID( "mooD" );
var id17 = charIDToTypeID( "moD1" );
desc3.putEnumerated( id15, id16, id17 );
executeAction( id12, desc3, DialogModes.NO );
// Library for timing things in JavaScript
function Timer() {
// member variables
this.startTime = new Date();
this.endTime = new Date();
// member functions
// reset the start time to now
this.start = function () { this.startTime = new Date(); }
// reset the end time to now
this.stop = function () { this.endTime = new Date(); }
// get the difference in milliseconds between start and stop
this.getTime = function () { return (this.endTime.getTime() - this.startTime.getTime()) / 1000; }
// get the current elapsed time from start to now, this sets the endTime
this.getElapsed = function () { this.endTime = new Date(); return this.getTime(); }
// end Dissolve.jsx
Similar Messages
-
How do I code relative links as function parameters within Templates?
I am a newcomer looking for best practices for a "How Do I?" properly code relative links as function parameters within an Adobe template (DWT) which accomodates page creation at 2 different level of folders. Dreamweaver doesn't appear to handle auto-correction of relative links as function parameters as far as I can see. It's not clear to me what the best practice I should be following. While this is not exactly a SPRY question, I am hoping that someone using the Spry.Data.XMLDataSet had already found the best practice to use.
My Site
-- Multiple pages at this level and the parameter needs to be "_includes/UnitSideNavigation.xml"
SubFolder
-- Other pages at this level. and the parameter needs to be "../_includes/UnitSideNavigation.xml"
And this is the particular code snippet within a non edtable template area I would like to work for 2 levels of pages created from the template.
<script type="text/javascript">
var dsItems1 = new Spry.Data.XMLDataSet("_includes/UnitSideNavigation.xml", "/links/firstlevel");
var dslinks = new Spry.Data.NestedXMLDataSet(dsItems1, "secondlevels/secondlevel");
</script>
My environment is Windows/Vista using latest CS4 dreamweaver.
Any pointers appreciated. This is learn time for me. Hope I have made myself clear. AndyI use serverside includes instead of DWT for exactly that reason. Not only that, if you change anything within the template you must re-upload all of the files affected by the change; only the modified include file needs to be uploaded.
-
Is it possible to have parameters within planning Sheets
Hi - Is it possible to have paramaeters withing planning Sheets. I was able to save a macro successfully within a planning sheet. But wanted to know if we can pass parameters within a planning sheet.
Thanks,
VenkatYou can pass parameters upto some extent. If you want to filter the MDX query then you can use InterlacePlanner.AddFilter method. e.g. InterlacePlanner.AddFilter "Customer", "ABCD"
where ABCD is Customer dimension member. -
Executing a Perl Script from within a Servlet
I'm trying to call a script from within a servlet.This is the code i'm using:
Process process = Runtime.getRuntime().exec(new String[]{"sh","-c",script,nick,pass});
InputStream input = process.getInputStream();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
int i;
while ((i=input.read())!=-1) {
baos.write(i);
System.out.println(baos.toString());
I can`t make it work.This is the output i'm getting.
java.io.IOException: CreateProcess: sh -c /home/script.sh user pass error=2
at java.lang.Win32Process.create(Native Method)
at java.lang.Win32Process.(Win32Process.java:66)
at java.lang.Runtime.execInternal(Native Method)
at java.lang.Runtime.exec(Runtime.java:551)
at java.lang.Runtime.exec(Runtime.java:477)
at java.lang.Runtime.exec(Runtime.java:443)
at controllers.EmailAcountCreate.doPost(EmailAcountCreate.java:34)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
Thanks in advance.I am facing the same problem. Could you please post the answer if you have one now. Please treat this as very urgent.
-
How to get the RGB Working Space from within a Filter Plug-In?
Within my Filter Plug-In I need to access the image's icc profile data. I know this can be accomplished with the according data structure 'iCCprofileData'. But what if there is no profile assigned to the image? Then iCCprofileData is NULL and the default should apply which is the 'RGB Working Space' (assuming the Plug-In works in RGB mode only, what it does). But how can I get to know what the 'RGB Working Space' is from within my Plug-In?
As far as I know, the profile provided to the plugin API should never be NULL. If the image is not color managed, it still should have the working space profile in the ICCProfileData field.
-
Writing Unicode characters to scripting parameters on Windows
I am trying to read/write a file path that supports Unicode characters to/from scripting parameters (PIDescriptorParameters) with an Export plug-in. This works fine on OS X by using AliasHandle together with the "typeAlias" resource type in the "aete" section of the plugin resource file.
On Windows I am having trouble to make Photoshop correctly display paths with Unicode characters. I have tried:
- Writing null-terminated char* (Windows-1252) in a "typePath" parameter -- this works but obviously does not support Unicode.
- Writing null-terminated wchar* (UTF-16) in a "typePath" parameter -- this causes the saved path in the Action palette to be truncated to the first character, caused by null bytes in UTF-16. It appears PS does not understand UTF-16 in this case?
- Creating an alias record with sPSAlias->WinNewAliasFromWidePath and storing in a "typePath" or "typeAlias" parameter -- this causes the Action palette to show "txtu&", which does not make sense to me at all.
The question is: what is the correct scripting parameter resource type (typePath, typeAlias, ... ?) for file paths on Windows, and how do I write to it in such way that Photoshop will correctly display Unicode characters in the Actions palette?Hi
Skip the first (4 or 6 characters) and you'll get the Unicode value.
regards
Bartek -
Getting hold of the servlet context within a filter
How can I get hold of the servlet context from within a filter?
The Filter has a FilterConfig that contains the ServletContext.
class myFilter implements Filter {
private FilterConfig config;
public void init(FilterConfig filterConfig)
throws ServletException {
this.config = FilterConfig;
public void doFilter(ServletRequest request,
ServletResponse response,
FilterChain chain)
throws java.io.IOException,
ServletException {
ServletContext context = this.config.getServletContext();
} -
How to add batch server group in script parameters
Hi All,
Is there any way to incorporate the "background server groups" directly in the script parameters in REDWOOD? There is an option to provide the target server in parameter TARGET_SERVER. But its not working if i maintain a server group. Any help will be appreciated.
Thanks
Arun RaghavanHi Blom,
Thanks for the reply. I am not able to find any parameter with the name TARGET_GROUP. Can I add this explicitly as a new parameter? But i am not sure how it will correlate to the batch server group in SAP. I also tried to import a job with target group defined. But the imported copy doesn't contain any values for it. -
Executing a perl script from within java application
Hi,
Does anyone knows a way to execute a perl script from within java.
---kirkRuntime.exec("perl myscript.pl");
Of course whether that "works" depends on what the script does and where the java program runs. -
How to read URL Parameters in ABAP WebDynpro ?
Hi,
How and where (which class, method) in ABAP WebDynpro we can read URL Parameters ? I found answers for WebDynpro JAVA but nothing for ABAP.
Thanks
MeenalHi Meenal,
Please see a post by Sanjay Agarwal titled 'Sequencing Problem in Web Dynpro ABAP'. I believe you will find your answer there.
Cheers,
Rich -
How to read Adapter Parameters at run time
Hi All,
We want to write a adapter module that reads the Adapter type and the file name which the adapter picks up, directly from Adapter parameters at runtime and then our adapter module which is being used in the receiver adapter would read these parameters and use them for further processing.
Now the question is how to read the adapter type and the file name that the sender adapter picks up? I am sure a adapter module is being used internally by SAP that holds these parameters, but which internal adapter module does this and how to access it's parameters so that we can use them in our scenario.
Regards,
XIer
Edited by: XIer on Jan 9, 2008 12:36 AMCheck the file adapter FAQ. There is a SAP note with the file adapter FAQ that descirbes how the filename can be read with in a module.
The code looks like something like this,
Hashtable mp =
(Hashtable) inputModuleData.getSupplementalData(
"module.parameters");
String strFileName = "";
strFileName = (String) mp.get("FileName");
Regards
Bhavesh -
Is it possible to read Prezi files within the iOS app?
Hello,
I want to implement Prezi into my iOS app. I am totally unaware that "Is it possible to read Prezi files within the iOS app?".
If Yes, please provide some tutorial link, so that I can implement into my application.
Thanks & regard.You will get a better answer in
Developer Forums
Use your Developer credentials to log in there. -
How to read URL parameters of one wdp component into other WDP component?
Dear Experts,
Can anyone let me know how to read URL parameters of one wdp component into other WDP component?
My requirement is i have one standard WDP component with 3 URL parameters and i needto
read that URL parameters along with their values in my Z-WDP component.
Thanks
SKHi Santosh,
You can read parameters send from one WebDynpro Component to another component by adding code in "HANDLEDEFAULT" Event Handler method ( Window )of your target Web Dynpro Component.
data: lt_parameter type tihttpnvp,
ls_parameter type ihttpnvp.
lo_api_controller ?= wd_this->wd_get_api( ).
call method lo_api_controller->get_message_manager
receiving
message_manager = lo_message_manager.
clear : ls_parameter.
refresh : lt_parameter[].
* Read all URL parameters
wdevent->get_data( exporting name = if_wd_application=>all_url_parameters importing value = lt_parameter ).
if not lt_parameter[] is initial.
clear : ls_parameter.
read table lt_parameter into ls_parameter index 1.
if ls_parameter-name = 'ACTION' and
ls_parameter-value is initial.
lv_flag = 'X'.
clear : lo_msg.
lo_msg = 'Action Parameter Missing in URL Link !'.
* report message
call method lo_message_manager->report_error_message
exporting
message_text = lo_msg.
else.
endif.
Best Regards
Priyesh Shah -
I am writting a Crystal application, where users could run adhoc reports and schedule them. My AdHoc options works fine, but I am having some issues with the Scheduling portion. In my project, to read the parameters, I am using CrystalReportsPartsViewer control. Once I load the report to my session object and apply all the logon information, I issue the following command to display the parameters.
crptPartsViewer.ReportSource = Session("myReport")
Once the user enters the parameters and click on OK button, I read the parameters in the event PreRender of the CrystalReportsPartsViewer control and save them in the database for the schedular to read and process.
following is a portion of the parameter reading code:
Dim myParameterFields As New ParameterFields
myParameterFields = rptPartsViewer.ParameterFieldInfo
Dim MyparamField As New ParameterField
Dim i As Integer = 0
Dim strParamName As String = ""
Dim strParameterType As String
Dim strValues As String = ""
For i = 0 To myParameterFields.Count - 1
strParamName = myParameterFields.Item(i).Name
MyparamField.CurrentValues = myParameterFields.Item(i).CurrentValues
strParameterType = myParameterFields.Item(i).ParameterValueType
Dim myParameterdiscrVal As New ParameterDiscreteValue
Dim myParameterRangeVal As New ParameterRangeValue
Dim bIsRangeValue As Boolean = False
Dim j As Integer = 0
For j = 0 To MyparamField.CurrentValues.Count - 1
If MyparamField.CurrentValues.Item(j).IsRange = True Then
bIsRangeValue = True
myParameterRangeVal = MyparamField.CurrentValues.Item(j)
strValues = strValues & myParameterRangeVal.StartValue & "@^" & myParameterRangeVal.EndValue
Else
myParameterdiscrVal = MyparamField.CurrentValues.Item(j)
strValues = strValues & "@^" & myParameterdiscrVal.Value
End If
Next
My issue is, this works on and off. It works 9/10 times and stops working for a little while and starts working again. I thought of using CrystalReportsViewer control, but when the user clicks ok, reportsviewer starts processing the report. So i am using the partsviewer.
I am not sure whether this is the way to do it (read parameters without processing the report), but this is the only way that I could come up with. Could any one let me know whether there a better way for reading the parameters, once they are entered? Or am I doing it correct?
Any help is greatly appreciated.Can you clarify which version of crystal reports you are using. I know in XIr2 and earlier, it took 2 postbacks before these values were accessible. Its not something that is intended to be read though. To be able to guarantee the value, you would need to create your own prompts.
-
Reading URL parameters in ABAP webdynpro
I have a requirements to run my ABAP Webdynpro application view based on two parameters passed to it from portal. How can I read the parameters in ABAP webdynpro and use them to write my condition in the run time. I would appreciate it if someone has any code that would help me also.
Again your help and support is highly appreciated.
LilyHi Lily,
To read the URL parameters, you need to right the following code in the HANDLEDEFAULT method
of the your default window controller.
DATA : it_parameter TYPE tihttpnvp,
wa_parameter TYPE ihttpnvp.
DATA lo_nd_url_param TYPE REF TO if_wd_context_node.
DATA ls_url_param TYPE wd_this->element_url_param.
" Get all URL parameters
CALL METHOD wdevent->get_data
EXPORTING
name = if_wd_application=>all_url_parameters
IMPORTING
value = it_parameter.
" Get parameter values
CLEAR wa_parameter.
READ TABLE it_parameter WITH KEY name = 'PERNR' INTO wa_parameter.
IF sy-subrc EQ 0.
ls_url_param-pernr = wa_parameter-value.
ENDIF.
CLEAR wa_parameter.
READ TABLE it_parameter WITH KEY name = 'SUBTY' INTO wa_parameter.
IF sy-subrc EQ 0.
ls_url_param-subty = wa_parameter-value.
ENDIF.
CLEAR wa_parameter.
READ TABLE it_parameter WITH KEY name = 'BEGDA' INTO wa_parameter.
IF sy-subrc EQ 0.
ls_url_param-begda = wa_parameter-value.
ENDIF.
CLEAR wa_parameter.
READ TABLE it_parameter WITH KEY name = 'ZZPRNTOPT' INTO wa_parameter.
IF sy-subrc EQ 0.
ls_url_param-zzprntopt = wa_parameter-value.
ENDIF.
" Save URL parameter to context
lo_nd_url_param = wd_context->get_child_node( name = wd_this->wdctx_url_param ).
lo_nd_url_param->set_static_attributes(
static_attributes = ls_url_param ).
Regards,
Vikrant
Maybe you are looking for
-
I got a new laptop and I can't sync all my music onto iTunes without iTunes saying it will erase my songs on the phone, how do I fix this to where I can put all my music on my laptop?
-
LSMW: Profit center using BO BUS0015
Hi All, I am using the BO BUS0015 to create profit center. Idocs are posted successfully, when in partner profile i m chosing <b>Trigger by Background program</b> However when i using Trigger Immediately its giving an erro message : <b>Event for star
-
The best way to upgrade j4w on client computers?
Hi Together What's the way to upgrade J4W on client computers when the logged in user hasn't administrator permissions? We are planning the rollout through our central software deploying system. For a later upgrade we wish to use the build-in upgrade
-
Application Discovery and Load Balancer Service Application - Load Distribution
Hello, We have a four server farm with no external load balancer. All of the servers are configured as WFEs. Is there a console in central admin or in site settings where I can see which request goes to which server? Many thanks,
-
Hi, Please guide for the following: I have a table, having mentioned below columns Location Item Qty_In_Location Amount ====== ==== ========== ===== A Table 40 4000 A Chair 50 34000 B Desk 20 15000 I want to create a query which should give the resul