OSErr WriteScriptParams (GPtr globals) { PIWriteDescriptor token = NULL; // token to write our parameters to OSErr err = noErr; // we'll return any error with this if (DescriptorAvailable(NULL)) { // Descriptor suite is available. Open a token: // PIUtilities has a routine that will create a descriptor to write // parameters to: token = OpenWriter(); if (token) { // was able to create the token, write our keys: PIPutInt(token, keyHorizontal, gPointH); PIPutInt(token, keyVertical, gPointV); PIPutInt(token, keyXFactor, gXFactor); PIPutBool(token, keyGaussianBlurData, gGaussianBlurData); // PIUtilities has a routine that will close the token, collapse // it, and store it in the struct that the host will then grab // and store for recording and/or subsequent scripting. It tells // the host that the dialog is optional. You can override this // by setting recordInfo to whatever you need. It then // deallocates token and sets it to NULL: err = CloseWriter(&token); } // wasn't able to create token } // descriptor suite unavailable return err; } // end WriteScriptParams
OSErr WriteScriptParams (GPtr globals) { PIWriteDescriptor token = NULL; // token to write our parameters to OSErr err = noErr; // we'll return any error with this if (DescriptorAvailable(NULL)) { // Descriptor suite is available. Open a token: // PIUtilities has a routine that will create a descriptor to write // parameters to: token = OpenWriter(); if (token) { // was able to create the token, write our keys: // Write scripting keys and values here. // See PIActions.h and PIUtilities.h for // routines and macros for scripting functions. // PIUtilities has a routine that will close the token, collapse // it, and store it in the struct that the host will then grab // and store for recording and/or subsequent scripting. It tells // the host that the dialog is optional. You can override this // by setting recordInfo to whatever you need. It then // deallocates token and sets it to NULL: err = CloseWriter(&token); } // wasn't able to create token } // descriptor suite unavailable return err; } // end WriteScriptParams
OSErr WriteScriptParams (GPtr globals) { PIWriteDescriptor token = NULL; double percent = gPercent; OSErr gotErr = noErr; if (DescriptorAvailable(NULL)) { /* recording. Do our thing. */ token = OpenWriter(); if (token) { PIPutEnum(token, keyMyArea, typeMySelect, EnumToKey(gWhatArea, typeMySelect)); if (gWhatArea == iSelectRandom) PIPutUnitFloat(token, keyMyAmount, unitPercent, &percent); PIPutEnum(token, keyMyChannels, typeMyComposite, EnumToKey(gWhatChannels, typeMyComposite)); PIPutEnum(token, keyMyCreate, typeMyCreate, EnumToKey(gCreate, typeMyCreate)); gotErr = CloseWriter(&token); /* closes and sets to dialog optional */ /* done. Now pass handle on to Photoshop */ } } return gotErr; }