Author Topic: Undocumented Function TextGetText?  (Read 3531 times)

flyer

  • Newbie
  • *
  • Posts: 16
  • Karma: +0/-0
    • View Profile
Undocumented Function TextGetText?
« on: July 23, 2012, 04:32:02 am »
Hi there,

I've searched the forums and documentation, but nowhere does it mention the TextGetText function...

There is obviously one documented for EditGetText and NoteGetText, but this one does not seem to have any explanatory notes with it.

I actually think it is there but not used as my app does compile and the function seems to provide the expected output.

The problem is that I think it might be this that is causing the stack to become corrupted around the destination character variable when I use it.

I could be wrong on that, but I don't understand why I keep on getting this annoying stack corruption.  I read somewhere that an error can be caused by using strlen on a non-null character terminated string, but I took out my call to strlen and the same error occured...

Is TextGetText a function that is usable by us or is it something internal that should not be called?

Thanks for any help,


Flyer

tim

  • Administrator
  • Hero Member
  • *****
  • Posts: 1595
  • Karma: +11/-1
    • View Profile
    • DragonFireSDK
Re: Undocumented Function TextGetText?
« Reply #1 on: July 23, 2012, 07:39:27 am »
You can use TextGetText() if you like.  Make sure that the char array you use is 100 bytes long and after you call TextGetText() set the last char in the array to NULL.

For example:

Code: [Select]
char MyBuffer[100];
...
TextGetText(MyText,MyBuffer);
MyBuffer[99]=0;
...
Tim Sommers
DragonFireSDK Team

flyer

  • Newbie
  • *
  • Posts: 16
  • Karma: +0/-0
    • View Profile
Re: Undocumented Function TextGetText?
« Reply #2 on: July 23, 2012, 02:20:27 pm »
Thanks for the reply Tim.

I tried as you suggested, but when I add a breakpoint and step through the code line by line, after calling TextGetText, I look at the field_text (MyBuffer equivalent) array individual positions and for some reason, all of the positions after 14 are not available (instead of showing the index and whatever value is in each position only a ? is seen).

Could this be related to the TextGetText function?

Code: [Select]
int Field_Width(int type, int *Field)
{
//0 = Edit / 1 = Text
int array_size(0), size(0), i;
char field_text[100];
if (type == 0) EditGetText(*Field,field_text);
else if (type == 1)
{
TextGetText(*Field,field_text);
field_text[99] = NULL;
}
array_size = strlen(field_text);
if (array_size == 0) return 0;
else
{
for (i = 0 ; i < array_size ; i++)
{
size += Arial24[field_text[i]] + 1;
}
}
return size;
}

The above is my function in which I try and use TextGetText.  I believe that everything else is OK and I simply pass in Type = 1 and a pointer to an int that is representing a 'Text' label (this label correctly contains the string "one").

Thanks for your help,


F

flyer

  • Newbie
  • *
  • Posts: 16
  • Karma: +0/-0
    • View Profile
Re: Undocumented Function TextGetText?
« Reply #3 on: July 24, 2012, 11:53:56 am »
Hi again,

I have tried using the TextGetText function now simply to read the contents of a text label into a char array 100 bytes long.

The only thing my function does (see code below) is create a char variable (field_text[100]) and then reads in the text from a given text label (for testing lets say the text is "abc").  I then set the field_text[99] position to 0.

From looking at the field_text variable immediately after doing the above, it seems that field_text has correctly accepted the "one" string.  The problem is after the function terminates I get the following message:

"Run-Time Check Failure #2 - Stack around the variable 'field_text' was corrupted."

Is there anything that I am doing wrong which seems obvious to anybody?  Is the TextGetText essentially identical to the EditGetText function?  I guess that from the previous reply there must be something different becuase you advised me to ensure that the final position of my receiving char array was NULL.

Make sure that the char array you use is 100 bytes long and after you call TextGetText() set the last char in the array to NULL.

Below is my code:

Code: [Select]
int Field_Width(int type, int *Field)
{
//0 = Edit / 1 = Text
int array_size(0), size(0), i;
char field_text[100];
if (type == 0) EditGetText(*Field,field_text);
else if (type == 1)
{
TextGetText(*Field,field_text);
field_text[99] = NULL;
}
return 0;
}

I pass in type = 1 and *Field represents a text label.

F

tim

  • Administrator
  • Hero Member
  • *****
  • Posts: 1595
  • Karma: +11/-1
    • View Profile
    • DragonFireSDK
Re: Undocumented Function TextGetText?
« Reply #4 on: July 24, 2012, 02:16:05 pm »
Question: why is Field an integer pointer?  Why not just pass in the value of the field handle (as a straight up int parameter...)?
Tim Sommers
DragonFireSDK Team

flyer

  • Newbie
  • *
  • Posts: 16
  • Karma: +0/-0
    • View Profile
Re: Undocumented Function TextGetText?
« Reply #5 on: July 24, 2012, 02:40:04 pm »
It's just me trying to be clever with an array containing a list of texts.

I tried altering the function to accept a simple int for field and the same error occured.

TextGetText seems to work OK (using both a simple int and a pointer to the int method) in that it correctly reads into the destination buffer the text contained within the text label, but something strange seems to be happening to my field_text variable and I can't see any reason for it unfortunately.

The purpose of the whole exercise is to try and detect the characters used and determine what the width of the text label will be so I can reposition/centre it so it looks good no matter what is typed into the field (centre justification).

Is there a way to do this automatically via the sdk?  If not I guess I will add it to the suggestions list!

Thanks for the reply

tim

  • Administrator
  • Hero Member
  • *****
  • Posts: 1595
  • Karma: +11/-1
    • View Profile
    • DragonFireSDK
Re: Undocumented Function TextGetText?
« Reply #6 on: July 24, 2012, 02:47:06 pm »
An upcoming update will include a TextGetWidth() function that will return the width of the label in pixels.
Tim Sommers
DragonFireSDK Team

HunterGreen

  • Guest
Re: Undocumented Function TextGetText?
« Reply #7 on: March 19, 2014, 01:07:54 pm »
As that was posted more than a year ago, did TextGetWidth() ever get implemented?

flyer

  • Newbie
  • *
  • Posts: 16
  • Karma: +0/-0
    • View Profile
Re: Undocumented Function TextGetText?
« Reply #8 on: July 29, 2014, 10:09:50 am »
I would also like to ask for the status of the aforementioned update...