Announcement

Collapse
No announcement yet.

tokenize bug?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    tokenize bug?

    I am attempting to use tokenize but it seems I can not use a variable as a token name:

    This works perfectly:
    Code:
    <mvassign name = "replacements[1]:token" value = "{ 'access_token' }">
    <mvassign name = "replacements[1]:value" value = "{ gettoken(theString,',',2) }">
    <mveval expr = "{ tokenize('%access_token% lives in Sweden.',replacements) }">
    This fails:
    Code:
    <mvassign name = "replacements[1]:token" value = "{ gettoken(theString,',',1) }">
    <mvassign name = "replacements[1]:value" value = "{ gettoken(theString,',',2) }">
    <mveval expr = "{ tokenize('%access_token% lives in Sweden.',replacements) }">
    It seems that the token replacement can not be a variable??

    Ideas? Thoughts? Bug?

    Bill
    Last edited by wmgilligan; 01-01-15, 06:51 PM.
    William Gilligan - Orange Marmalade, Inc.
    www.OrangeMarmaladeinc.com

    #2
    Re: tokenize bug?

    The code looks OK. I'd try putting in an MvEVAL to verify the contents of theString.
    Kent Multer
    Magic Metal Productions
    http://TheMagicM.com
    * Web developer/designer
    * E-commerce and Miva
    * Author, The Official Miva Web Scripting Book -- available on-line:
    http://www.amazon.com/exec/obidos/IS...icmetalproducA

    Comment


      #3
      Re: tokenize bug?

      Originally posted by Kent Multer View Post
      The code looks OK. I'd try putting in an MvEVAL to verify the contents of theString.
      Thanks Kent,
      I had done this - but - after your suggestion, I tried again with a simple variable and it worked fine.
      So - I retried with my setup, and failure...

      But further digging showed the only thing was that the first token had a quote in it which I was replacing with nothing.
      Code:
      <MvAssign name="theString" value="{ glosub(theInfo,'"','') }">
      On a whim, I added ltrim to the final variable and it worked.
      So I guess that there was something getting in there that broke it.

      Code:
      <mvassign name = "replacements[1]:token" value = "{ ltrim(gettoken(theString,',',1)) }">
      Thanks!
      Last edited by wmgilligan; 01-02-15, 11:51 AM.
      William Gilligan - Orange Marmalade, Inc.
      www.OrangeMarmaladeinc.com

      Comment


        #4
        Re: tokenize bug?

        Glad you got that fixed. Apprently tokenize() is sensitive about white space in token names.

        FYI, newer versions of the engine have a trim() function, which is does both ltrim() and rtrim() in one call. Miva Script is a very verbose language; I like to save a few keystrokes any place I can :^) .
        Kent Multer
        Magic Metal Productions
        http://TheMagicM.com
        * Web developer/designer
        * E-commerce and Miva
        * Author, The Official Miva Web Scripting Book -- available on-line:
        http://www.amazon.com/exec/obidos/IS...icmetalproducA

        Comment

        Working...
        X