glosub_array()

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • RayYates
    Developer Partner



    • Dec 2006
    • 1517

    #1

    glosub_array()

    I was updating MivaScript.com and noticed the description for glosub_array() did not contain a return value and there were other errors.

    The description for the function says:

    "Works like glosub(), but search and replace are arrays that are iterated through, each value in the search array found in the string is replaced by the corresponding replace array value."

    Since I have never used this function I looked to the LSK figuring an example it usage would make it more clear.

    Code:
    <MvFUNCTION NAME = "AdminOrderFields_Sanitize_FieldCode" PARAMETERS = "field_id" STANDARDOUTPUTLEVEL = "">
        <MvASSIGN NAME = "l.search" INDEX = 1 VALUE = ":">    <MvASSIGN NAME = "l.replace" INDEX = 1 VALUE = "_">
        <MvASSIGN NAME = "l.search" INDEX = 2 VALUE = "-">    <MvASSIGN NAME = "l.replace" INDEX = 2 VALUE = "_">
    
        <MvFUNCTIONRETURN VALUE = "{ glosub_array( l.field_id, l.search, l.replace ) }">
    </MvFUNCTION>
    Just to confirm my understanding, multiple search and replace operations are performed on the string l.field_id. In effect the script below does the same thing. Am I correct?

    Code:
    <MvFUNCTION NAME = "AdminOrderFields_Sanitize_FieldCode" PARAMETERS = "field_id" STANDARDOUTPUTLEVEL = "">
        <MvFUNCTIONRETURN VALUE = "{ glosub( glosub( l.field_id, ":", "_" ), "-", "_") }">
    </MvFUNCTION>

    Ray Yates
    "If I have seen further, it is by standing on the shoulders of giants."
    --- Sir Isaac Newton
  • burch
    Administrator

    • Mar 2009
    • 630

    #2
    You are correct.

    Comment

    Working...
    X