Sprintf arguments

Options

It would be great if we could rearrange sprintf arguments in the editor, especially when we are building longer concatenated strings and need to insert an argument toward the beginning of the list.

I have had to undo and redo many arguments because of this.

Tagged:

Comments

  • Ray Deck
    Ray Deck Trusted Xano Expert ✭✭✭
    Options

    I don't like to use sprintf, and instead use the replace filter. The latter lets me replace a known token, like ADDRESS with the address I am looking to put in. stack a series of replace filters to replace the multiple tokens, and the order they appear in your text won't matter. CITY ADDRESS will get replaced with New York 1 Park Plaza and ADDRESS, CITY gets replaced with 1 Park Plaza, New York.

    This kind of more advanced text manipulation is part of the hardest 5% we crack together in State Change office hours and our discussion board.

  • MattLaro
    MattLaro Member ✭✭
    Options

    I'd tend to Agree with Ray on this. Sprintf is great for quick replacements (like an error message you want to point out a faulty value, as example) limited to one or two replacements, but is very prone to mistakes when you use with a large number of arguments.

    As you also point out, Xano does not allow reordering anything as of today. When using the replace filter instead, not only do you pinpoint exactly what value goes where, but adding/removing any placeholders in you original value will only require to add and remove the matching replace filter as well.