Since I upgraded.

Home Forums General Programming Since I upgraded.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #5806
    Bomma72
    Participant
      • Topics: 20
      • Replies: 68
      • Total: 88

      I am having trouble with my string variables.  After I define them or if I populate them with the value of a label when I try to run the len command or the string.sub command I always get an error.

      “string expected, got userdata”

      This didn’t happen before.  Not sure what is different now.

       

      #5825
      Bomma72
      Participant
        • Topics: 20
        • Replies: 68
        • Total: 88

        So did some more checking and the weirdest thing about this is that if I do a console command it I get the string value.

        #5835
        Bomma72
        Participant
          • Topics: 20
          • Replies: 68
          • Total: 88

          OK after the second night of trying to figure this out I am starting to think this may be a bug with the newly compiled Mac version of Ctrlr.  I just don’t know.  Seems to only happen with strings, though maybe I am doing something wrong.

          Here is an example of the code I am trying to use.

          label = panel:getModulatorByName(“lblPhTtl”):getComponent()
          local PatchName = label:getPropertyString(“uiLabelText”)

          for i=1,10 do

          char = string.sub(PatchName,i,i)  –Tried this first

          ** returns bad argument #1 to ‘sub’ (string expected, got userdata).
          char = PatchName:getByte(i)  — Then tried this

          ** returns attempt to call method ‘getByte’ (a nil value)

          end

          I should mention that there is data in the label field and if I do a console(PatchName) command I get the correct results.  Also this worked fine with the current build that is defaulted to on the site.  Should I just go back to that one?

           

          • This reply was modified 11 years, 2 months ago by Bomma72.
          • This reply was modified 11 years, 2 months ago by Bomma72.
          #5838
          dasfaker
          Keymaster
            • Topics: 80
            • Replies: 793
            • Total: 873
            • ★★★

            Try changing local PatchName = label:getPropertyString(“uiLabelText”) with local PatchName = label:getProperty(“uiLabelText”)

            #5847
            Bomma72
            Participant
              • Topics: 20
              • Replies: 68
              • Total: 88

              Hi, Thanks for the reply.  So I tried to put your command into practice however, same issue.  For whatever reason all of the strings taken from the label are seen as userdata and I can’t even convert them to string as it say they are nil when I try.  I also changed the label thinking maybe this was a legacy issue.  No such luck.

              At this point I am going to go back to the older version of Ctrlr though I hate to do it.

              #5848
              atom
              Keymaster
                • Topics: 159
                • Replies: 2945
                • Total: 3104
                • ★★★★★

                It’s all String() classes, always look at your object for what they are, i included a handy what() mehtod for example

                >>> l = panel:getComponent("myLabel"):getProperty("uiLabelText")
                debug (what (l))
                console (l)
                Object type [string]
                -----------------------------------------------------------------
                
                Members:
                
                
                Attributes:
                
                -----------------------------------------------------------------
                Object type [string]
                -----------------------------------------------------------------
                
                Members:
                
                
                Attributes:
                
                -----------------------------------------------------------------
                Label text
                

                Or:

                >>> l = panel:getLabel("myLabel"):getText()
                debug (what (l))
                console (l)
                Object type [String]
                -----------------------------------------------------------------
                
                Members:
                	              equalsIgnoreCase:	function
                	                        __init:	function
                	                   toLowerCase:	function
                	         lastIndexOfIgnoreCase:	function
                	              removeCharacters:	function
                	                   paddedRight:	function
                	                      contains:	function
                	                      swapWith:	function
                	                 getHexValue32:	function
                	          fromLastOccurrenceOf:	function
                	             indexOfIgnoreCase:	function
                	                    startsWith:	function
                	                        length:	function
                	                        quoted:	function
                	         trimCharactersAtStart:	function
                	                      endsWith:	function
                	               matchesWildcard:	function
                	                      unquoted:	function
                	                 getFloatValue:	function
                	                  containsOnly:	function
                	   containsWholeWordIgnoreCase:	function
                	                      hashCode:	function
                	                repeatedString:	function
                	                isQuotedString:	function
                	      compareLexicographically:	function
                	                       compare:	function
                	                   getIntValue:	function
                	                        append:	function
                	         upToFirstOccurrenceOf:	function
                	          startsWithIgnoreCase:	function
                	             getLastCharacters:	function
                	                   lastIndexOf:	function
                	                       isEmpty:	function
                	            containsIgnoreCase:	function
                	              retainCharacters:	function
                	                       indexOf:	function
                	                replaceSection:	function
                	  initialSectionContainingOnly:	function
                	                    isNotEmpty:	function
                	                 containsAnyOf:	function
                	           trimCharactersAtEnd:	function
                	              lastIndexOfAnyOf:	function
                	   initialSectionNotContaining:	function
                	                       replace:	function
                	                     substring:	function
                	                  indexOfAnyOf:	function
                	                          trim:	function
                	         fromFirstOccurrenceOf:	function
                	            dropLastCharacters:	function
                	                   toUpperCase:	function
                	                       trimEnd:	function
                	             containsWholeWord:	function
                	    indexOfWholeWordIgnoreCase:	function
                	             compareIgnoreCase:	function
                	    containsNonWhitespaceChars:	function
                	                         __add:	function
                	          upToLastOccurrenceOf:	function
                	              indexOfWholeWord:	function
                	           getTrailingIntValue:	function
                	                    paddedLeft:	function
                	                getDoubleValue:	function
                	             replaceCharacters:	function
                	                        toUTF8:	function
                
                
                Attributes:
                
                -----------------------------------------------------------------
                Object type [String]
                -----------------------------------------------------------------
                
                Members:
                	              equalsIgnoreCase:	function
                	                        __init:	function
                	                   toLowerCase:	function
                	         lastIndexOfIgnoreCase:	function
                	              removeCharacters:	function
                	                   paddedRight:	function
                	                      contains:	function
                	                      swapWith:	function
                	                 getHexValue32:	function
                	          fromLastOccurrenceOf:	function
                	             indexOfIgnoreCase:	function
                	                    startsWith:	function
                	                        length:	function
                	                        quoted:	function
                	         trimCharactersAtStart:	function
                	                      endsWith:	function
                	               matchesWildcard:	function
                	                      unquoted:	function
                	                 getFloatValue:	function
                	                  containsOnly:	function
                	   containsWholeWordIgnoreCase:	function
                	                      hashCode:	function
                	                repeatedString:	function
                	                isQuotedString:	function
                	      compareLexicographically:	function
                	                       compare:	function
                	                   getIntValue:	function
                	                        append:	function
                	         upToFirstOccurrenceOf:	function
                	          startsWithIgnoreCase:	function
                	             getLastCharacters:	function
                	                   lastIndexOf:	function
                	                       isEmpty:	function
                	            containsIgnoreCase:	function
                	              retainCharacters:	function
                	                       indexOf:	function
                	                replaceSection:	function
                	  initialSectionContainingOnly:	function
                	                    isNotEmpty:	function
                	                 containsAnyOf:	function
                	           trimCharactersAtEnd:	function
                	              lastIndexOfAnyOf:	function
                	   initialSectionNotContaining:	function
                	                       replace:	function
                	                     substring:	function
                	                  indexOfAnyOf:	function
                	                          trim:	function
                	         fromFirstOccurrenceOf:	function
                	            dropLastCharacters:	function
                	                   toUpperCase:	function
                	                       trimEnd:	function
                	             containsWholeWord:	function
                	    indexOfWholeWordIgnoreCase:	function
                	             compareIgnoreCase:	function
                	    containsNonWhitespaceChars:	function
                	                         __add:	function
                	          upToLastOccurrenceOf:	function
                	              indexOfWholeWord:	function
                	           getTrailingIntValue:	function
                	                    paddedLeft:	function
                	                getDoubleValue:	function
                	             replaceCharacters:	function
                	                        toUTF8:	function
                
                
                Attributes:
                
                -----------------------------------------------------------------
                Label text
                

                Always know what data you are dealing with

                #5850
                dasfaker
                Keymaster
                  • Topics: 80
                  • Replies: 793
                  • Total: 873
                  • ★★★

                  This is what I do to get characters from a uiLabel string:

                  label = panel:getModulatorByName("Patch Name"):getComponent()
                  PatchName= label:getProperty ("uiLabelText")

                  character1 = string.byte((PatchName), 1)
                  ..
                  character10 = string.byte((PatchName), 10)

                  Hope this helps

                  #5893
                  Bomma72
                  Participant
                    • Topics: 20
                    • Replies: 68
                    • Total: 88

                    Thanks for this, I got it!!

                    I was using

                    PatchName = label:getPropertyString(“uiLabelText”)

                    PatchName = label:getPropertyString(“uiLabelText”)

                    Removing the string part works.

                    It’s strange as the other worked worked in the old version, and like I said it also would display the string when I called it in the console.  Anyway know I know.

                    Thanks again.

                     

                  Viewing 8 posts - 1 through 8 (of 8 total)
                  • The forum ‘Programming’ is closed to new topics and replies.
                  There is currently 0 users and 59 guests online
                  No users are currently active
                  Forum Statistics
                  Threads: 2,495, Posts: 17,374, Members: 77,605
                  Most users ever online was 12 on January 22, 2019 3:47 pm
                  Ctrlr