Boolean ReadScriptParams (GPtr globals) { PIReadDescriptor token = NULL; DescriptorKeyID key = NULLID; DescriptorTypeID type = NULLID; double percent = 0; const double minValue = kPercentMin, maxValue = kPercentMax; DescriptorUnitID percentUnitPass = unitPercent; OSType x = typeNull; DescriptorKeyIDArray array = { keyMyShape, keyMyChannels, keyMyCreate, NULLID }; int32 flags = 0; OSErr stickyError = noErr; Boolean returnValue = true; if (DescriptorAvailable(NULL)) { /* playing back. Do our thing. */ token = OpenReader(array); if (token) { while (PIGetKey(token, &key, &type, &flags)) { switch (key) { case keyMyArea: PIGetEnum(token, &x); gWhatArea = KeyToEnum(x, typeMySelect); break; case keyMyAmount: // optional PIGetPinUnitFloat(token, &minValue, &maxValue, &percentUnitPass, &percent); gPercent = (short)percent; break; case keyMyChannels: PIGetEnum(token, &x); gWhatChannels = KeyToEnum(x, typeMyComposite); break; case keyMyCreate: PIGetEnum(token, &x); gCreate = KeyToEnum(x, typeMyCreate); break; } } stickyError = CloseReader(&token); // closes & disposes. if (stickyError) { if (stickyError == errMissingParameter) // missedParamErr == -1715 ; /* (descriptorKeyIDArray != NULL) missing parameter somewhere. Walk IDarray to find which one. */ else gResult = stickyError; } } returnValue = PlayDialog(); /* return TRUE if want to show our Dialog */ } return returnValue; }
Boolean ReadScriptParams (GPtr globals) { PIReadDescriptor token = NULL; // token we'll use to read descriptor DescriptorKeyID key = NULLID; // the next key DescriptorTypeID type = NULLID; // the type of the key we read int32 flags = 0; // any flags for the key // Populate this array if we're expecting any keys, // must be NULLID terminated: DescriptorKeyIDArray array = { NULLID }; // While we're reading keys, errors will stick around and be reported // when we close the token: OSErr err = noErr; // Assume we want to pop our dialog unless explicitly told not to: Boolean returnValue = true; if (DescriptorAvailable(NULL)) { // descriptor suite is available, go ahead and open descriptor: // PIUtilities routine to open descriptor handed to us by host: token = OpenReader(array); if (token) { // token was valid, so read keys from it: while (PIGetKey(token, &key, &type, &flags)) { // got a valid key. Figure out where to put it: switch (key) { // match a key to its expected type:case keyAmount: case 0: break; default: break; // Read scripting keys and values here. // See PIActions.h and PIUtilities.h for // routines and macros for scripting functions. } // key } // PIGetKey // PIUtilities routine that automatically deallocates, // closes, and sets token to NULL: err = CloseReader(&token); if (err) { // an error did occur while we were reading keys: if (err == errMissingParameter) // missedParamErr == -1715 { // missing parameter somewhere. Walk IDarray to find which one. } else { // serious error. Return it as a global result: gResult = err; } } // stickyError } // didn't have a valid token // Whether we had a valid token or not, we were given information // as to whether to pop our dialog or not. PIUtilities has a routine // to check that and return TRUE if we should pop it, FALSE if not: returnValue = PlayDialog(); } // descriptor suite unavailable return returnValue; } // end ReadScriptParams
OSErr ReadScriptParams (GPtr globals) { PIReadDescriptor token = NULL; // token we'll use to read descriptor DescriptorKeyID key = NULLID; // the next key DescriptorTypeID type = NULLID; // the type of the key we read int32 flags = 0; // any flags for the key // Populate this array if we're expecting any keys, // must be NULLID terminated: DescriptorKeyIDArray array = { keyHorizontal, keyVertical, keyXFactor, keyGaussianBlurData, NULLID }; // While we're reading keys, errors will stick around and be reported // when we close the token: OSErr err = noErr; // Assume we want to pop our dialog unless explicitly told not to: Boolean returnValue = gQueryForParameters; if (DescriptorAvailable(NULL)) { // descriptor suite is available, go ahead and open descriptor: // PIUtilities routine to open descriptor handed to us by host: token = OpenReader(array); if (token) { // token was valid, so read keys from it: while (PIGetKey(token, &key, &type, &flags)) { // got a valid key. Figure out where to put it: switch (key) { // match a key to its expected type:case keyAmount: case keyHorizontal: int32 h; err = PIGetInt(token, &h); gPointH = (short)h; break; case keyVertical: int32 v; err = PIGetInt(token, &v); gPointV = (short)v; break; case keyXFactor: err = PIGetInt(token, &gXFactor); break; case keyGaussianBlurData: err = PIGetBool(token, &gGaussianBlurData); break; // ignore all other cases and classes } // key } // PIGetKey // PIUtilities routine that automatically deallocates, // closes, and sets token to NULL: err = CloseReader(&token); if (err) { // an error did occur while we were reading keys: if (err == errMissingParameter) // missedParamErr == -1715 { // missing parameter somewhere. Walk IDarray to find which one. } else { // serious error. Return it as a global result: gResult = err; } } // stickyError } // didn't have a valid token // Whether we had a valid token or not, we were given information // as to whether to pop our dialog or not. PIUtilities has a routine // to check that and return TRUE if we should pop it, FALSE if not: returnValue = PlayDialog(); } // descriptor suite unavailable gQueryForParameters = returnValue; return err; } // end ReadScriptParams
void OpenScriptParams (GPtr globals) { DescriptorKeyID key = 0; DescriptorTypeID type = 0; int32 flags = 0; int32 depth = gOutputDepth; double rows = gLastRows, columns = gLastCols; const double minRows = kRowsMin, maxRows = kRowsMax, minColumns = kColumnsMin, maxColumns = kColumnsMax; unsigned long pixelsUnitPass = unitPixels; PIDescriptorHandle descriptor; ReadDescriptorProcs *reader; PIReadDescriptor token; // why the hell isn't this stuff in the main source base? #ifndef PIGetKey #define PIGetKey(token, key, type, flags) \ reader->getKeyProc(token, key, type, flags) #endif #ifndef PIGetPinUnitFloat #define PIGetPinUnitFloat(token, min, max, unit, value) \ reader->getPinnedUnitFloatProc(token, min, max, unit, value) #endif #ifndef PIGetInt #define PIGetInt(token, value) \ reader->getIntegerProc(token, value) #endif if (gStuff->descriptorParameters) { descriptor = gStuff->descriptorParameters->descriptor; reader = gStuff->descriptorParameters->readDescriptorProcs; token = reader->openReadDescriptorProc(descriptor, NULL); /* don't know how many we're going to be passed, so don't bother with array */ if (token) { while (PIGetKey(token, &key, &type, &flags)) { /* nothing to do here switch (key) { case keyVertical: PIGetPinUnitFloat(token, &minRows, &maxRows, &pixelsUnitPass, &rows); gLastRows = (int32)rows; break; case keyHorizontal: PIGetPinUnitFloat(token, &minColumns, &maxColumns, &pixelsUnitPass, &columns); gLastCols = (int32)columns; break; case keyDepth: PIGetInt(token, &depth); gOutputDepth = (int16)depth; break; } */ } } // HostCloseReader reader->closeReadDescriptorProc(token); PIDisposeHandle( gStuff->descriptorParameters->descriptor ); gStuff->descriptorParameters->descriptor = NULL; } /* return true if want to show our Dialog */ }