Home AMX User Forum NetLinx Studio

G3 Button Text not displaying long text string.

I'm using a CV10 panel and sending about 100 character text string to a certain button. The problem is twofold. Firstly, I cannot get more than about 50 characters to display. Doesn't matter whether I break the string up and concatenate it together in the send_command with carraige returns or not. Is there a limitation on button text that isn't documented? Secondly, it doesn't appear G3 has any text wrap attribute for button text. Is there an easy way to do text wrapping or am I going to have to code the text wrapping routine by hand?

Thanks,


Bill

Comments

  • DHawthorneDHawthorne Posts: 4,584
    I don't think the buttons have any limit other than what will fit in them. The limitation is the SEND_COMMAND. I forget what the cutoff is, and a quick search didn't turn it up, but there is a limit how big of a command you can send. I thought it was somewhere around 255 characters, though. It's possible (well, in my mind anyway, not having seen your screens) that the text is actually there, but cannot be displayed.

    But you are definitely on your own with word-wrap in a G3 panel. You can imbed a | character to force a line feed, but you will have to calculate ourself where to insert them.
  • ericmedleyericmedley Posts: 4,177
    I think the text limit is 255 chars. I can't speak with authority since I don't know that to be the case. I just found it by trial and error and error and error and etc...

    I wrote my own weather module (it uses NOAA's free telnet to get its info) before AMX came out with the i!-Weather and I wanted to be able to print out the entire 7-day forcast. It was commonly over 255 chars. I too couldn't find any docs on the limit of chars that could be sent.

    My first fix was to simply trim down to a 3-day forcast. However, the lameness of that soon caused me to loose sleep. so my next fix was to create a crawling text display. So the text would crawl across the screen like one of those LED displays you see in banks and schools and whatnot to display messages.

    That's how I dealt with it.

    I suppose a person could mess with having two text buttons abutted together and deal with it that way.

    Your problem of only seeing 50 chars seems to be more of a programming issue. The text may indeed be getting to the panel alright but you're comment about not having a 'text wraping' function is probably dead on. with G3 panels you probably have to do the text wrap yourself in programming.

    You could create a little routine that would insert a pipe '|' (Shift-Forward Slash) every 50 chars or so. that forces a carriage return in the button text window.

    example:

    text =" ' bla bla bla for 50 chars',$7C,'more stuff bla bla for 50 more chars',$7C,'bla bla' etc... The $7C is the hex ascii for a 'pipe'

    I do it with a for loop with 'X' equalling the length of the original string.

    Hope that helps
  • Limitation with AXLink
    DHawthorne wrote:
    I don't think the buttons have any limit other than what will fit in them. The limitation is the SEND_COMMAND. I forget what the cutoff is, and a quick search didn't turn it up, but there is a limit how big of a command you can send.
    Dave,

    You are on the right track. The limitation is the payload of the SEND_COMMAND after the device name including the command itself. I believe it is about 64 charaters. This has to do with the limitations of the Axlink bus. Any message to a device on Axlink can not exceed a maximum number of bytes.
    Send_Command TP,"'!T',<variable text address 1-255>,'<new text to be put in button>'"
    
    This format would give you a maximum of 60 charaters for the text.
  • 64 or 128

    I concur with Brian, my understanding is that a send_command is limited to 64 characters.

    However I also have in a dusty corner of my mind another factoid - that there is a limit of 128 characters on AXLink communications. Not sure if that has any bearing on this!

    When I asked in a different thread how to present on a G3 touchpanel lots of text which changes from time to time, the best response I got was to ftp it across as a bitmap. I can't imagine how you would do that from NetLinx code however!

    Eric, how did you do the crawling text display?
  • billyungbillyung Posts: 16
    Thanks. Solved.

    Thanks for all the help. The answer I needed was the 64 character limit on the send command. My text wrapping code ended up looking like this:

    integer mypos
    integer lastpos
    char longsourcestring
    char deststring1 [60]
    char deststring2 [60]
    char deststring3 [60]
    char deststring4 [60]

    mypos = find_string(longsourcestring, ' ', 46)
    if(mypos==0)mypos=256 //in case this is the last line.
    destring1 = left(longsourcestring, mypos-lastpos)

    lastpos=mypos

    lastpos=mypos
    mypos = find_string(longsourcestring, ' ',(lastpos+50))
    if(mypos==0)
    deststring2 = right_string(longsourcestring,(length_array(longsourcestring)-lastpos))
    else
    deststring2 = mid_string(longsourcestring, lastpos, mypos-lastpos)


    lather... rinse ... repeat.


    It works fine this way. I suppose if you have a really long word in just the right place, it might cutoff. This could be fixed if there were a way to search a string from the end toward the beginning for a space. I don't care though. It's plenty good enough now. I'm using this to display movie plot summaries from an older MAX unit. Quite happy to have the new feature without the $30k upgrade.


    Thanks again for all your help,


    Bill
  • ericmedleyericmedley Posts: 4,177
    Eric, how did you do the crawling text display?

    I tell the theory. The programming after that is not so bad.

    Let suppose you have a string that's 79 chars long.

    original_text='Now is the time for all good men to come to the aid of their country.'

    Set up a for loop that builds a temp string that is compsed of chars 1+X thru 30+X where X is an offset.

    // the following builds the little 30 char chunk for you.
    For(crawl_text_x=1;crawl_text_x<31;crawl_text_x++)
    {
    temp_text="temp_text,origianl_text[crawl_text_x+offset]"
    }
    (You can also get this done by using LEFT_STRING / RIGHT_STRING to isolate the 30 char chunk. I use the for loop as it allows me to stick in little conditionals like "remove any <CR's> or add spaces at the end of the string, etc....)


    ... after loop send the string

    first run: offset=0 text = "Now is the time for all good m"


    next step after the desired wait time is increment offset. I did it 3 chars at a time.

    Next step offset=3

    So the next temp text is " is the time for all good men "
    send string to the panel.

    Next Step offseet = 6

    So the next temp text is " the time for all good men to "
    send string to the panel.

    Repeat and account for the text wrap around. I put in 15 spaces at the end of my whole text to give the crawl a bit of space at the end.

    by lowering or raising the offset you speed up or slow down the crawler.

    Also, by lowering or raising the wait time between send_strings gets it done. I found that G3 panels don't handle times much under 10 - 20 ticks.

    You can trigger the event from a timeline or do it the old fashioned way.

    Hope that helps.
    ejm
  • TurnipTruckTurnipTruck Posts: 1,485
    ericmedley wrote:

    I wrote my own weather module (it uses NOAA's free telnet to get its info) before AMX came out with the i!-Weather....

    What is the address for the free weather data login?

    Thanks!
  • Thanks Eric

    I thought you had something magical - it turns out to be just good ole coding!

    Having said that, the idea of sending changing text to a button is new, if obvious, to me.

    Thanks.
  • viningvining Posts: 4,368
    Here's a function I wrote a week or so ago that looks for spaces starting at the max line lenght working backward. I needn't end up using it but you may if you'd like.

    DEFINE_CONSTANT
    
    nVT_MaxNumLines   =  10     // this can be set exact or higher than needed
    nVT_MaxDispStrLen  =  64    // max the VT field lenght to word word wrap
    
    DEFINE_FUNCTION CHAR[2000] fnSetStrCRLF(CHAR istrSTR[])//require constant values
         {
         stack_var char cStrTemp[2000]
         local_var integer i
         local_var integer n
         n = 1
         while (length_string(istrSTR) && n <= nVT_MaxNumLines)
    	  {
    	  if (length_string(istrSTR) > nVT_MaxDispStrLen)
    	       {
    	       for (i=1;i<=30;i++)//if no space in 30 chars give up
    		    {
    		    if (mid_string(istrSTR,nVT_MaxDispStrLen - i,1) == ' ')
    			 {
    			 cStrTemp = "cStrTemp,GET_BUFFER_STRING(istrSTR,nVT_MaxDispStrLen - i),13,10"
    			 i = 31
    			 n ++
    			 }
    		    else if (i = 30)
    			 {
    			 cStrTemp = istrSTR //give up and void while loop
    			 clear_buffer istrSTR
    			 }
    		    }
    	       }
    	  else
    	       {
    	       cStrTemp = "cStrTemp,istrSTR"
    	       n ++
    	       clear_buffer istrSTR
    	       }
    	  }
         clear_buffer istrSTR// shouldn't be needed
         RETURN cStrTemp;
         }
    
  • viningvining Posts: 4,368
    I should have included this function that Dave provided that removes any carriage returns you may alrEady have in your string. In you do, pass the string to this function and this function will call the one I previously posted pass back the return to this which will pass back it's return to where it was called.
    DEFINE_FUNCTION CHAR[2000] sReplace(CHAR strSTR[], CHAR strSEARCH[], CHAR strREPLACE[])
         {
         STACK_VAR INTEGER nPOS
         STACK_VAR CHAR strTRASH[2000]
         STACK_VAR CHAR strTEMP_STR[2000]
    
         nPOS = FIND_STRING(strSTR, "strSEARCH", 1)
         IF (!nPOS)
    	  RETURN strSTR;
         WHILE (nPOS)
    	  {
    	  strTEMP_STR = ""
    	  IF (nPOS > 1)
    	       strTEMP_STR = LEFT_STRING(strSTR, nPOS - 1)
    	  strTRASH = REMOVE_STRING(strSTR, "strTEMP_STR, strSEARCH", 1)
    	  strSTR = "strTEMP_STR, strREPLACE, strSTR"
    	  nPOS = FIND_STRING(strSTR, "strSEARCH", nPOS + LENGTH_STRING(strREPLACE))
    	  }
         if (length_string(strSTR) > nVT_MaxDispStrLen)
    	  {
    	  RETURN fnSetStrCRLF (strSTR);
    	  }
         else
    	  {
    	  RETURN strSTR;
    	  }
         }
    
    
    ///////////////////////////////////////////////////////////////////////////////
    ///////////  THIS LINE CALLS THE FUNCTION AND PASSES THE STRING //////////////
    sForecasts[n].description = fnReplace(get_buffer_string(iRSSBuf,nFBS - 1), "10", "32")
    
    
  • viningvining Posts: 4,368
    If you use this function change the local_vars to stack_vars. I must have been watching them and never reset.
    DEFINE_FUNCTION CHAR[2000] fnSetStrCRLF(CHAR istrSTR[])//require constant values
         {
         stack_var char cStrTemp[2000]
         local_var integer i
         local_var integer n
    
  • ericmedleyericmedley Posts: 4,177
    What is the address for the free weather data login?

    Thanks!

    66.28.69.161 port 23

    This is The Nation Weather Underground telnet site. It farms data from the NOAA feed and is updated every minute.

    However, I've found that you only need to update every 20 minutes or so since NOAA updates about that often.

    I'd operate it in Hyper terminal first to see how it works.

    It's pretty straight-forward.

    Hope that helps
    ejm
  • ericmedleyericmedley Posts: 4,177
    I thought you had something magical - it turns out to be just good ole coding!

    Having said that, the idea of sending changing text to a button is new, if obvious, to me.

    Thanks.

    Magical? I'm afraid not...
    I'm pretty old-skool when it comes to things like that.
Sign In or Register to comment.