• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to read and write strings?

Explorer ,
May 19, 2011 May 19, 2011

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

TOPICS
SDK

Views

1.2K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Explorer ,
May 20, 2011 May 20, 2011

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
May 20, 2011 May 20, 2011

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);

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 20, 2011 May 20, 2011

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
May 24, 2011 May 24, 2011

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,

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
May 24, 2011 May 24, 2011

Copy link to clipboard

Copied

LATEST

I apologize for the reply above. Is this a horrible editor or what!!!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines