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

How do I work around PIGetStr placing an invalid character in character buffer?

New Here ,
Sep 06, 2013 Sep 06, 2013

Copy link to clipboard

Copied

In an Export plug-in, I need to read in the destination file path from scripting parameters.  Often, the character at exportPath[0] is junk and not an actual part of the path (hence the check).  Recently, this junk has actually been alphanumeric characters.  I can write a more accurate platform-dependent workaround, but would prefer an actual solution.  As a note, this happens whenever I use PIGetStr, not just in the case of reading filepaths.

Is there a standard way to handle this behavior?

Example:

case keyFilePath:

          {

                    Str255 exportPath;

                    PIGetStr(token, &exportPath);

                    byte offset = 0;

                    if(!isalpha(exportPath[0]))

                                   offset = 1;

                    strcpy_s((char*)gDestination, 256 - offset, (char*)exportPath + offset);

                    DescParams->playInfo = 0; //Don't pop dialog.

                    break;

          }

Result in exportPath:  Ec:\temp\assets\textures\brick_stacked_tile_01_SpecColor_gradients.dds

Expected:  c:\temp\assets\textures\brick_stacked_tile_01_SpecColor_gradients.dds

TOPICS
SDK

Views

800

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

correct answers 1 Correct answer

Contributor , Sep 06, 2013 Sep 06, 2013

From PITypes.h:

typedef unsigned char Str255[256];  /*  first byte length of string. The string is zero terminated. */

It's pure legacy - this is how strings in ol' good Pascal used to be organized

Votes

Translate

Translate
Adobe
Contributor ,
Sep 06, 2013 Sep 06, 2013

Copy link to clipboard

Copied

From PITypes.h:

typedef unsigned char Str255[256];  /*  first byte length of string. The string is zero terminated. */

It's pure legacy - this is how strings in ol' good Pascal used to be organized

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
New Here ,
Sep 06, 2013 Sep 06, 2013

Copy link to clipboard

Copied

LATEST

So, those things that show up in green tell you how to use someone elses programming constructs.  Fascinating stuff.

/facepalm.  I even went to the definition in PITypes.h, and looked at it and was like "Hey, it's an unsigned character array of 256 characters" and never read the comment next to it.

Thank you for answering my question.    It seems like I need to pay more attention to details in the future.

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