a!save() and saveInto()

anybody can explain a!save() and saveInto() some little more depth

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    Basically, if you just want to save the value of the component to a variable, you simply type the variable you want in saveInto.

    saveInto: ri!input

    That puts whatever the user chose, typed, selected, etc. into ri!input.  Easy.

    If you need to do something more complicated, or additional things, you can use a!save().  a!save takes a target, the variable the stuff goes into, and a value, the stuff that goes in there.  save!value is a unique variable that you have access to inside that function only, which is whatever the user chose, typed, selected, etc.

    saveInto: a!save(ri!input, save!value) does exactly the same thing as the other code above

    The advantage you get is that you can do all kinds of extra functions on the target, and all kinds of extra functions on the value.  You can, for instance, use an if() to determine which of 3 different variables you save into based on conditions; and at the same time enumerate the value, or sum it with something else, or concatenate a timestamp to the end of it, or whatever you want.  The possibilities are virtually limitless.

    Another fun thing is that saveInto accepts a list, and it will run the list in order from top to bottom.  It's one of only a couple of places where you're guaranteed an order of execution.  One common practice I see is a list with a target at the top and a bunch of saves.  This is what many programmers do when the order doesn't matter, or when it does and it's important that the top one be set first.

    saveInto:{

    ri!input,

    a!save(...),

    a!save(...),

    a!save(...)

    }

Reply
  • 0
    Certified Lead Developer

    Basically, if you just want to save the value of the component to a variable, you simply type the variable you want in saveInto.

    saveInto: ri!input

    That puts whatever the user chose, typed, selected, etc. into ri!input.  Easy.

    If you need to do something more complicated, or additional things, you can use a!save().  a!save takes a target, the variable the stuff goes into, and a value, the stuff that goes in there.  save!value is a unique variable that you have access to inside that function only, which is whatever the user chose, typed, selected, etc.

    saveInto: a!save(ri!input, save!value) does exactly the same thing as the other code above

    The advantage you get is that you can do all kinds of extra functions on the target, and all kinds of extra functions on the value.  You can, for instance, use an if() to determine which of 3 different variables you save into based on conditions; and at the same time enumerate the value, or sum it with something else, or concatenate a timestamp to the end of it, or whatever you want.  The possibilities are virtually limitless.

    Another fun thing is that saveInto accepts a list, and it will run the list in order from top to bottom.  It's one of only a couple of places where you're guaranteed an order of execution.  One common practice I see is a list with a target at the top and a bunch of saves.  This is what many programmers do when the order doesn't matter, or when it does and it's important that the top one be set first.

    saveInto:{

    ri!input,

    a!save(...),

    a!save(...),

    a!save(...)

    }

Children
No Data