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

Fetching character count values in C++

Explorer ,
Jun 03, 2020 Jun 03, 2020

Hi,

 

IDocument* doc = Utils<ILayoutUIUtils>()->GetFrontDocument();
InterfacePtr<ITextStoryThreadDict> textStoryThreadDict(doc, UseDefaultIID());

Text::StoryRange storyRange = textStoryThreadDict->GetThreadBlockTextRange();

PMString characterCount;
characterCount.AppendNumber(storyRange);
CAlert::InformationAlert(characterCount);

 

it shows an error that "cannot convert argument 1 from 'Text::StoryRange' to 'int32' " how can  I solve this error please guide me.

Nithu
TOPICS
Feature request , How to , SDK
1.2K
Translate
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
Community Expert ,
Jun 03, 2020 Jun 03, 2020

The Text::StoryRange is a class not an int32 variable that you can pass to AppendNumber method, there is not method defined for this conversion as well. Try the following

TextIndex blockStart = storyRange.GetStart();
TextIndex blockEnd = storyRange.GetEnd();

 

This will give you the start and end of the block. See the class details in the sdk for more information

 

-Manan

Translate
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 ,
Jun 06, 2020 Jun 06, 2020

Hi,

After using the start and end block InDesign get crashes is there is any other way to get the character count values

Nithu
Translate
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 ,
Jun 08, 2020 Jun 08, 2020

Hi,

I'm still struggling with the query I've posted. Can someone give me a solution..

Nithu
Translate
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
Community Expert ,
Jun 09, 2020 Jun 09, 2020

Of course it crashes:

 

CAlert::InformationAlert(characterCount);

 

This attempts to show 'characterCount' as if it's a string. But it is not -- it is a number. This was told you before in https://community.adobe.com/t5/indesign/plugin-creation-in-indesign/td-p/11119241?page=1

 

As we already explained to your alias/alter ego/coworker Jothi, you cannot learn InDesign SDK programming through cargo cult programming. You will have to properly learn C++ first; not only just the basics but every single detail of it. The SDK is meant for advanced programmers only, and there is no "beginner friendly" path into it.

Translate
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
Community Expert ,
Jun 09, 2020 Jun 09, 2020

To add to what Jongware mentioned and i have been telling you guys time and again that you need to learn stuff. I would add another thing to it, i gave you an answer on what sdk says, agreed that you don't have much experience with sdk but if you get a crash and you are asking for an alternative then it means you are finding faults with the sdk. Why do you think the sdk architect would create another route and leave a route that seems to be documented for this purpose susceptible to a crash? The plausible scenarios that i can think of

  • There are muliple ways to do things in an sdk for sure, but that does not mean a way would lead to undefined behaviour or crash. See the documentation, experiment, you might not be handling an error condition, like checking for null values, non negative indexes returned etc
  • The input to the api is not what it expects, Try varying the input, make it as simple as possible to atleast get it working. Once you have a working use case you can build from there to identify when an api works and when it does not

For me the key to learning any programming language is debugging your way out. Frankly speaking i don't rate myself even decent in C++ but i can surely debug things. If you let your guard down at the first crash without debugging the cause, i am afraid you are in the wrong trade here.

 

-Manan

Translate
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 ,
Jun 11, 2020 Jun 11, 2020
LATEST

duplicate thread locked

Translate
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