News:

  • July 07, 2026, 01:51:41 PM

Login with username, password and session length

Author Topic: Strings and How Do I Fix the "Short" Ones?  (Read 34286 times)

Mike Nash

  • Hero Member
  • *****
  • Posts: 652
Strings and How Do I Fix the "Short" Ones?
« on: April 04, 2016, 04:25:58 PM »
I have somehow managed to get SS0-4, SS15, SS16 and SS31 stuck at a MaxLen of 40 with all the rest at 64 as they should be. This probably happened when I was messing around days ago and found the Cmore EA9 was only allowing me to enter 40 characters and I may have dropped the SS string length in Memory Configuration. I really don't know. I have since increased the table size to 150 (SS0-SS149) and the string length is greyed out and showing 64 there. I need these back as I am pre-pending Time and Date to these strings so it's hacking off the text at the end.

So how do I fix this and not lose the info in the SS's?

(I am still having issues with Memory View and Memory Image so I don't know that I can save the values out and get them back.)

Thanks!

Mike Nash

  • Hero Member
  • *****
  • Posts: 652
Re: Strings and How Do I Fix the "Short" Ones?
« Reply #1 on: April 04, 2016, 04:52:17 PM »
I went ahead, took the chance and set the SS memory size to zero and then took it back to 150. This got all the SS.MemLen back to 64, yea!

However, my string routine seems to be my issue. I did find I can edit the string in a data view and it will go back up to 64 characters.

So, I found my problem, but don't quite understand it. I was memcopy'ing a 40 character string to another one, then trying to STRPRINT to that another one and it was only printing 40 characters worth instead of 57. Deleting the (leftover) Memcopy solved the issue, but I don't understand the length being restricted at all in this fashion?!?

Mike Nash

  • Hero Member
  • *****
  • Posts: 652
Re: Strings and How Do I Fix the "Short" Ones?
« Reply #2 on: April 04, 2016, 04:57:08 PM »
So does anyone know if there is a 40 character limit on strings in the Cmore EA9 v6.14? Now that there is a 57 character string in the PLC, Cmore stops displaying after the first space since the rest is 40 contiguous characters I guess. Looks like I may be back to 2 strings per item anyway, bummer.

plcnut

  • Hero Member
  • *****
  • Posts: 814
    • premiersi.com
Re: Strings and How Do I Fix the "Short" Ones?
« Reply #3 on: April 04, 2016, 05:44:12 PM »
There is no such limit that I know of. I can't say that I have ever tried to display that many characters before though...
Circumstances don't determine who we are, they only reveal it.

~Jason Wolthuis
Premier Systems Integration, LLC
http://premiersi.com

plcnut

  • Hero Member
  • *****
  • Posts: 814
    • premiersi.com
Re: Strings and How Do I Fix the "Short" Ones?
« Reply #4 on: April 04, 2016, 05:45:48 PM »
Have you checked how you set up your SL tag in the Cmore tag database? Maybe the character count is wrong there?
Circumstances don't determine who we are, they only reveal it.

~Jason Wolthuis
Premier Systems Integration, LLC
http://premiersi.com

Mike Nash

  • Hero Member
  • *****
  • Posts: 652
Re: Strings and How Do I Fix the "Short" Ones?
« Reply #5 on: April 04, 2016, 05:57:09 PM »
Slap! I got bitten partially by the coincidence bug even though I am a firm believer in coincidences. I had the Cmore Dynamic Text object ever so slightly too narrow. Apparently, Cmore simply tosses out any part of a text string that won't fit as long as there is a space to break at. You get nada if there is no space. Pretty ugly behavior. I had checked my width with a static text object with the same font characteristics in the editor, but it wasn't quite enough - adding 5 pixels fixed it - Courier New so fixed width. I need a prettier fixed width font!

That explains the Cmore not displaying all of the string. I am still not understanding why the MaxLen would get shortened and be unable to put a longer string into it via code.

I could not get more than 40 characters from the Cmore to the PLC still.

And I am using SS rather than SL as 64 characters is more than I need.

Mike Nash

  • Hero Member
  • *****
  • Posts: 652
Re: Strings and How Do I Fix the "Short" Ones?
« Reply #6 on: April 04, 2016, 05:59:57 PM »
Have you checked how you set up your SL tag in the Cmore tag database? Maybe the character count is wrong there?

Ha! Yes that was another self-inflicted. I was 2 bytes short and had 56 instead of 58 - I need 57. I found that before the object width.

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3833
    • Host Engineering
Re: Strings and How Do I Fix the "Short" Ones?
« Reply #7 on: April 05, 2016, 07:55:55 AM »
So, I found my problem, but don't quite understand it. I was memcopy'ing a 40 character string to another one,

When you say "40" here, do you mean you had STRING block with Max Length of 40 characters that you were copying into SSxxx, or that the length of the string contents was 40 characters?

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3833
    • Host Engineering
Re: Strings and How Do I Fix the "Short" Ones?
« Reply #8 on: April 05, 2016, 08:00:09 AM »
Normally, when trying to do a MEMCOPY between two dissimilar sized STRING blocks (e.g. SS has buffer/max length of 64 characters and SL has buffer/max length of 256 characters), you should get an error when trying to enter that instruction (see attachment).

Mike Nash

  • Hero Member
  • *****
  • Posts: 652
Re: Strings and How Do I Fix the "Short" Ones?
« Reply #9 on: April 05, 2016, 09:49:54 AM »
I am getting more like what I expected this morning. Including the MEMCOPY then the STRPRINT to the same SSx working ok without dropping characters.

Maybe just a bad case of HUHS?*

1) C-more will not always display all of a string. If it has no spaces in the string it will display as much as it can in a too narrow text object. If it has a space, you only get up to the last space that will fit. Leads to confusion.
    e.g. 123456789a123456789b might show 123456789a123 but 123456789 1234567 would only show 123456789
 

2) When C-more writes a 44 character string to a Do-more SS location, the SS.MaxLen is set to the length C-more has for the tag. If it was MaxLen 64 and C-more writes a 23 character string, MaxLen becomes 44 in the Do-more. Why? What does this mean? If I change the size in the tag name database in C-more to 58 and write another string, MaxLen will change 58. If it sends a shorter length MaxLen does not decrease in size. At least this is what I think I am seeing.

Checked some more - I can data view edit a 64 character string into SS0 and SS0.MaxLen goes to 64. C-more then writes a 29 character string to SS0 and SS0.MaxLen is now 44 (which is the size I have set in the C-more Tag Database for the SS0 string only.)

So again, what is MaxLen's purpose and personality?

3) The tricky part seems to be that once C-more has set SS0.MaxLen to 44, a MEMCOPY from SS0 to SS147 results in SS147.MaxLen also dropping from 64 to 44. Now if I try to STRPRINT a longer string into SS147, it does not have enough room as it clips after 44 characters. Without the MEMCOPY, SS147.MaxLen stays at 64 and I can fit the STRPRINT result into just fine.


* Head Up Heinie Syndrome

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3833
    • Host Engineering
Re: Strings and How Do I Fix the "Short" Ones?
« Reply #10 on: April 05, 2016, 10:26:16 AM »
The Length in C-more MUST be set to the Max Length of the string of the specific Do-more block.  If it's 64 (e.g. SSn), then you must set that tag's (max) length to 64, NOT 44!  If it's 256 (e.g. SLn), then you must set that tag's (max) length to 256.

The .MaxLen is meant to be READONLY and can really mess up/corrupt your memory (especially if you make it LARGER than the actual buffer allocated for each string!!!).

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3833
    • Host Engineering
Re: Strings and How Do I Fix the "Short" Ones?
« Reply #11 on: April 05, 2016, 10:33:15 AM »
So, please re-do your C-more configuration for ALL the tags and make sure they match the SS block .MaxLen (64).

Also, a PGM->RUN transition SHOULD re-initialize all your .MaxLen string structure members to their proper values (i.e. 64 for all the SS strings, 256 for all the SL strings, etc.).

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3619
  • Darth Ladder
Re: Strings and How Do I Fix the "Short" Ones?
« Reply #12 on: April 05, 2016, 11:59:04 AM »
1) C-more will not always display all of a string. If it has no spaces in the string it will display as much as it can in a too narrow text object. If it has a space, you only get up to the last space that will fit. Leads to confusion.

THAT's extremely lame.  It should just show what it can and truncate.   >:(
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

Mike Nash

  • Hero Member
  • *****
  • Posts: 652
Re: Strings and How Do I Fix the "Short" Ones?
« Reply #13 on: April 05, 2016, 12:45:43 PM »
So, please re-do your C-more configuration for ALL the tags and make sure they match the SS block .MaxLen (64).

Also, a PGM->RUN transition SHOULD re-initialize all your .MaxLen string structure members to their proper values (i.e. 64 for all the SS strings, 256 for all the SL strings, etc.).

I am not writing to the .MaxLen at all. I know Data View doesn't allow it. That is just the behavior I see when the C-more writes to the string.

The issue I have with allowing the C-more to have all 64 characters for input is that I have no way to limit what the operator types as he is typing other than the tag character length.

It's bad enough the C-more text entry has no cursor, no loading of current value, and nothing better than backspace, clear or cancel for editing what is being typed.

Maybe I can have them enter a string to an internal tag and event manager it to the PLC string. I'll check that.

Mike Nash

  • Hero Member
  • *****
  • Posts: 652
Re: Strings and How Do I Fix the "Short" Ones?
« Reply #14 on: April 05, 2016, 12:47:50 PM »
1) C-more will not always display all of a string. If it has no spaces in the string it will display as much as it can in a too narrow text object. If it has a space, you only get up to the last space that will fit. Leads to confusion.

THAT's extremely lame.  It should just show what it can and truncate.   >:(

Some days I begin to wonder whether I am the only one having these issues.


But more likely I am just the squeakiest wheel.  :D