Copy link to clipboard
Copied
Hi,
I'm new to photoshop plugin development and I'm checking dissolve plugin. I want to add a string parameter and then I should be able to read and write the string in ReadScriptParameters() & WriteScriptParameters(). I just want to fill some text in the typeChar parameter and I do not need any UI for it. So how can I do it?
Thanks,
Dheeraj
Copy link to clipboard
Copied
Hi All,
I used putStringProc() to write the string in WriteScriptParameters() and GetStringLength() and GetString() functions to retrieve the string. The issue I'm facing is that the string is truncated when I read back the string. For Example, if I saved "abcd", then I get back "bcd". If the string is big then the string gets truncated from both ends. I used following code to read & write :
Read:
(sPSActionDescriptor->GetStringLength(actionDescriptor,
keyText,
&stringLength));
std::vector<char> vc(stringLength+1);
(sPSActionDescriptor->GetString(actionDescriptor, keyText, &vc[0], (uint32)vc.size()));
Write:
writeProcs->putStringProc(token, keyText, (const unsigned char*)"abcd");
What might be the problem? Am I doing it the wrong way?
Thanks,
Dheeraj
Copy link to clipboard
Copied
Use a pascal string, first byte is the length, or use the new suite based action procs for char *'s. Not obvious but the 255 usuall gives it away. You cannot use strings larger than 255 characters with this routine.
/**
* Stores an ID and corresponding string (\c typeChar) into a descriptor structure.
* @param PIWriteDescriptor The descriptor to write into
* @param DescriptorKeyID The key to write.
* @param ConstStr255Param The string to write.
* @returns Non-zero error if failure.
*/
typedef
MACPASCAL OSErr (*PutStringProc)(PIWriteDescriptor, DescriptorKeyID, ConstStr255Param);
Copy link to clipboard
Copied
Thanks for the info Tom Ruark. Can you please tell me wich routine to use if I want to save more than 255 characters?
Copy link to clipboard
Copied
See PIActions.h
You will need to acquire this suite
PSActionDescriptorProcs
and use these routines
/**
char* cstrValue);
/**
* Gets a string (\c typeChar) from a descriptor for a given key.
* @param descriptor The descriptor from which to read.
* @param key The key to read.
* @param cstrValue [OUT] The string returned.
* @param maxLength The maximum number of characters to return.
* @returns Non-zero error if failure
*/
SPAPI OSErr (*GetString)(PIActionDescriptor descriptor, DescriptorKeyID key,
char* cstrValue, uint32 maxLength);
If you are in a filter you will need to convert from the handle descriptor to the PIActionDescriptor. See the Hidden.cpp source file on how to do that.
AsHandle
HandleToDescriptor
P.S. Is it just me or is this a horrible editor for posting messages!!!
* Puts a string value (\c typeChar) into a descriptor for a given key.
* @param descriptor The descriptor in which to write.
* @param key The key to write.
* @param value The string to write.
* @returns Non-zero error if failure
*/
SPAPI OSErr (*PutString)(PIActionDescriptor descriptor, DescriptorKeyID key,
Copy link to clipboard
Copied
I apologize for the reply above. Is this a horrible editor or what!!!