Loading ...
Sorry, an error occurred while loading the content.

fscommand2("GetPlatform")

Expand Messages
  • Dale Rankine
    Hey everyone, just found a little gotcha when using Device Central CS4 (don t know if this exists in CS3 as well). When you are getting the return value of
    Message 1 of 13 , Mar 3 9:42 PM
    • 0 Attachment

      Hey everyone, just found a little gotcha when using Device Central CS4 (don’t know if this exists in CS3 as well).

       

      When you are getting the return value of status = fscommand2(“GetPlatform”, “platform”); for Nokia S40 devices, the string that comes back looks like “Nokia OS”. You might then be checking that value in order to change some conditions in your application, so you might do something like if(platform == “Nokia OS”) ...

       

      What isn’t obvious from tracing the variable is that there’s a whitespace at the end of this string (as in “Nokia OS “) and so that test on the absolute value needs to also include the whitespace, otherwise it fails.

       

      Returns the same too (with the whitespace) for FL2 and FL3

       

      Just came across this doing some development today and just thought I’d share that one with y’all ...

       

      Dale.

       

       

      ------------------------------------------------------

      dale@...

      www.dalerankine.com

      Adobe Certified Instructor (Mobile)

      Certified Flash Lite Developer
      Adobe Community Expert (Mobile)

      Adobe Ambassador (Pacific)

      Forum Nokia Champion

      Mobile Monday Brisbane Co-Manager

       

       

       

    • Barry Beattie
      Dale, is there a trim() function availble to help here? if (trim(fscommand2(“GetPlatform”, “platform”)) == “Nokia OS ) { // etc.... }
      Message 2 of 13 , Mar 4 2:02 AM
      • 0 Attachment
        Dale, is there a "trim()" function availble to help here?


        if (trim(fscommand2(“GetPlatform”, “platform”)) == " “Nokia OS" )
        {
        // etc....
        }




        On Wed, Mar 4, 2009 at 3:42 PM, Dale Rankine <dale@...> wrote:
        > Hey everyone, just found a little gotcha when using Device Central CS4
        > (don’t know if this exists in CS3 as well).
        >
        >
        >
        > When you are getting the return value of status = fscommand2(“GetPlatform”,
        > “platform”); for Nokia S40 devices, the string that comes back looks like
        > “Nokia OS”. You might then be checking that value in order to change some
        > conditions in your application, so you might do something like if(platform
        > == “Nokia OS”) ...
        >
        >
        >
        > What isn’t obvious from tracing the variable is that there’s a whitespace at
        > the end of this string (as in “Nokia OS “) and so that test on the absolute
        > value needs to also include the whitespace, otherwise it fails.
        >
        >
        >
        > Returns the same too (with the whitespace) for FL2 and FL3
        >
        >
        >
        > Just came across this doing some development today and just thought I’d
        > share that one with y’all ...
        >
        >
        >
        > Dale.
        >
        >
        >
        >
        >
        > ------------------------------------------------------
        >
        > dale@...
        >
        > www.dalerankine.com
        >
        > Adobe Certified Instructor (Mobile)
        >
        > Certified Flash Lite Developer
        > Adobe Community Expert (Mobile)
        >
        > Adobe Ambassador (Pacific)
        >
        > Forum Nokia Champion
        >
        > Mobile Monday Brisbane Co-Manager
        >
        >
        >
        >
        >
        >
        >
        >
      • Scott Janousek
        Nope no built in trim as in PHP, in AS2 ... but if you search there are tons of custom functions out there for reuse. -sj
        Message 3 of 13 , Mar 4 8:10 AM
        • 0 Attachment
          Nope no built in trim as in PHP, in AS2 ... but if you search there are
          tons of custom functions out there for reuse.

          -sj

          On 3/4/2009 5:02 AM, Barry Beattie wrote:
          > Dale, is there a "trim()" function availble to help here?
          >
          >
          > if (trim(fscommand2(“GetPlatform”, “platform”)) == " “Nokia OS" )
          > {
          > // etc....
          > }
          >
          >
          >
        • Jesse Warden
          like: var str = cow ; str = str.split( ).join( ); ... like: var str = cow ; str = str.split( ).join( ); On Wed, Mar 4, 2009 at 11:10 AM, Scott
          Message 4 of 13 , Mar 4 8:15 AM
          • 0 Attachment
            like:

            var str = "cow ";
            str = str.split(" ").join("");

            On Wed, Mar 4, 2009 at 11:10 AM, Scott Janousek <scott@...> wrote:

            Nope no built in trim as in PHP, in AS2 ... but if you search there are
            tons of custom functions out there for reuse.

            -sj

            On 3/4/2009 5:02 AM, Barry Beattie wrote:
            > Dale, is there a "trim()" function availble to help here?
            >
            >
            > if (trim(fscommand2(“GetPlatform”, “platform”)) == " “Nokia OS" )
            > {
            > // etc....
            > }
            >
            >
            >


          • Scott Janousek
            that s my favorite, but it depends on your needs. :) ... that s my favorite, but it depends on your needs. :) On 3/4/2009 11:15 AM, Jesse Warden wrote: like:
            Message 5 of 13 , Mar 4 8:21 AM
            • 0 Attachment
              that's my favorite, but it depends on your needs. :)

              On 3/4/2009 11:15 AM, Jesse Warden wrote:

              like:


              var str = "cow ";
              str = str.split(" ").join("");

              On Wed, Mar 4, 2009 at 11:10 AM, Scott Janousek <scott@scottjanousek .com> wrote:

              Nope no built in trim as in PHP, in AS2 ... but if you search there are
              tons of custom functions out there for reuse.

              -sj

              On 3/4/2009 5:02 AM, Barry Beattie wrote:
              > Dale, is there a "trim()" function availble to help here?
              >
              >
              > if (trim(fscommand2(“ GetPlatform” , “platform”)) == " “Nokia OS" )
              > {
              > // etc....
              > }
              >
              >
              >




            • Brent Arnold
              What about indexOf. var platform:String = fscommand2(³GetPlatform², ³platform²); If(platform.toLowerCase().indexOf(³nokia²) != -1) { // you¹ve got nokia
              Message 6 of 13 , Mar 4 8:23 AM
              • 0 Attachment
                Re: [FlashLite] fscommand2("GetPlatform") What about indexOf.

                 var platform:String = fscommand2(“GetPlatform”, “platform”);
                If(platform.toLowerCase().indexOf(“nokia”) != -1)
                {
                   // you’ve got nokia
                }


                iBrent


                From: Scott Janousek <scott@...>
                Organization: scottjanousek.com
                Reply-To: <FlashLite@yahoogroups.com>
                Date: Wed, 04 Mar 2009 11:10:23 -0500
                To: <FlashLite@yahoogroups.com>
                Subject: Re: [FlashLite] fscommand2("GetPlatform")

                 
                 

                Nope no built in trim as in PHP, in AS2 ... but if you search there are
                tons of custom functions out there for reuse.

                -sj

                On 3/4/2009 5:02 AM, Barry Beattie wrote:
                > Dale, is there a "trim()" function availble to help here?
                >
                >
                > if (trim(fscommand2(“GetPlatform”, “platform”)) == " “Nokia OS" )
                > {
                >   // etc....
                > }
                >
                >
                >    

                  
                    


              • Weyert de Boer
                The issue I have had was bugs in the API calls for FL. I have had a custom device which runned FL. I had to use fscommand2 access specific native
                Message 7 of 13 , Mar 4 10:03 AM
                • 0 Attachment
                  The issue I have had was bugs in the API calls for FL. I have had a
                  custom device which runned FL. I had to use fscommand2 access specific
                  native functionality. Only the issue was that when you wanted to write
                  data to a text file and read it again. And some calls similar to
                  GetPlatform would include garbage data. Like stuff after the null
                  character of the string which makes it hard to compare or use it.
                  Because it was hard to remove the garbage (random length). Really
                  enjoying...
                • Brent Arnold
                  Sorry if this post gets double posted, I thought my email response would go through... What about using indexOf()? var platform:String =
                  Message 8 of 13 , Mar 4 10:19 AM
                  • 0 Attachment
                    Sorry if this post gets double posted, I thought my email response would go through...

                    What about using indexOf()?

                    var platform:String = fscommand2("GetPlatform", "platform");
                    if (platform.toLowerCase().indexOf("nokia") != -1)
                    {
                    // you've got a Nokia phone
                    }


                    iBrent



                    --- In FlashLite@yahoogroups.com, Scott Janousek <scott@...> wrote:
                    >
                    > that's my favorite, but it depends on your needs. :)
                    >
                    > On 3/4/2009 11:15 AM, Jesse Warden wrote:
                    > >
                    > > like:
                    > >
                    > >
                    > > var str = "cow ";
                    > > str = str.split(" ").join("");
                    > >
                    > > On Wed, Mar 4, 2009 at 11:10 AM, Scott Janousek
                    > > <scott@... <mailto:scott@...>> wrote:
                    > >
                    > > Nope no built in trim as in PHP, in AS2 ... but if you search
                    > > there are
                    > > tons of custom functions out there for reuse.
                    > >
                    > > -sj
                    > >
                    > > On 3/4/2009 5:02 AM, Barry Beattie wrote:
                    > > > Dale, is there a "trim()" function availble to help here?
                    > > >
                    > > >
                    > > > if (trim(fscommand2("GetPlatform", "platform")) == " "Nokia OS" )
                    > > > {
                    > > > // etc....
                    > > > }
                    > > >
                    > > >
                    > > >
                    > >
                    > >
                    > >
                    >
                  • Scott Janousek
                    Detecting device platform info ... here is a good starting point for Nokia specific device platforms (but can be adapted to other platforms supporting
                    Message 9 of 13 , Mar 4 11:12 AM
                    • 0 Attachment
                      Detecting device platform info ... here is a good starting point for Nokia specific device platforms (but can be adapted to other platforms supporting fscommand2 as well):

                      http://library.forum.nokia.com/index.jsp?topic=/Flash_Lite_Developers_Library/GUID-0772B436-6988-45FE-8C96-BEEAE461D48B.html

                      -sj

                      On 3/4/2009 1:19 PM, Brent Arnold wrote:

                      Sorry if this post gets double posted, I thought my email response would go through...

                      What about using indexOf()?

                      var platform:String = fscommand2(" GetPlatform" , "platform");
                      if (platform.toLowerCa se().indexOf( "nokia") != -1)
                      {
                      // you've got a Nokia phone
                      }


                    • Barry Beattie
                      ... hang on, that won t work: Nokia OS would be NokiaOS you re splitting the string into an array based on a space as the delimiter and then joining the
                      Message 10 of 13 , Mar 4 2:11 PM
                      • 0 Attachment
                        > var str = "cow ";
                        > str = str.split(" ").join("");

                        hang on, that won't work:

                        "Nokia OS " would be

                        "NokiaOS"

                        you're splitting the string into an array based on a space as the delimiter

                        and then joining the array to a string. Any delimiter occurance would
                        be a new array element to then join (now without the space)
                      • Darren Osadchuk
                        Probably other ways to do it, but: var str = Nokia OS ; while (str.charAt(str.length-1) == ) { str = str.substr(0, str.length-1); } would work. D.
                        Message 11 of 13 , Mar 4 2:26 PM
                        • 0 Attachment
                          Probably other ways to do it, but:

                          var str = "Nokia OS ";
                          while (str.charAt(str.length-1) == " ") {
                          str = str.substr(0, str.length-1);
                          }

                          would work.

                          D.

                          Barry Beattie wrote:
                          >
                          >
                          > > var str = "cow ";
                          > > str = str.split(" ").join("");
                          >
                          > hang on, that won't work:
                          >
                          > "Nokia OS " would be
                          >
                          > "NokiaOS"
                          >
                          > you're splitting the string into an array based on a space as the delimiter
                          >
                          > and then joining the array to a string. Any delimiter occurance would
                          > be a new array element to then join (now without the space)
                          >
                          >
                        • Weyert de Boer
                          Depends if the null character is getting translated to a space also in these methods. If not, it would work if you use String.fromCharCode(0) probably.
                          Message 12 of 13 , Mar 4 2:33 PM
                          • 0 Attachment
                            Depends if the null character is getting translated to a space also in
                            these methods. If not, it would work if you use String.fromCharCode(0)
                            probably.

                            > Probably other ways to do it, but:
                            >
                            > var str = "Nokia OS ";
                            > while (str.charAt(str.length-1) == " ") {
                            > str = str.substr(0, str.length-1);
                            > }
                            >
                            > would work.
                            >
                            > D.
                            >
                            > Barry Beattie wrote:
                            > >
                            > >
                            > > > var str = "cow ";
                            > > > str = str.split(" ").join("");
                            > >
                            > > hang on, that won't work:
                            > >
                            > > "Nokia OS " would be
                            > >
                            > > "NokiaOS"
                            > >
                            > > you're splitting the string into an array based on a space as the
                            > delimiter
                            > >
                            > > and then joining the array to a string. Any delimiter occurance would
                            > > be a new array element to then join (now without the space)
                            > >
                            > >
                            >
                            >
                          • Maxim Antinori
                            Agree with iBrent, I like the indexOf approach to this, simpler/faster than splits and joins...
                            Message 13 of 13 , Mar 5 10:25 AM
                            • 0 Attachment
                              Agree with iBrent, I like the indexOf approach to this, simpler/faster than splits and joins...

                              >
                              > var platform:String = fscommand2("GetPlatform", "platform");
                              > if (platform.toLowerCase().indexOf("nokia") != -1)
                              > {
                              > // you've got a Nokia phone
                              > }
                              >
                              >
                              > iBrent
                              >
                              >
                              >
                            Your message has been successfully submitted and would be delivered to recipients shortly.