Cli_Execute()

matt.chugg

Moderator
Is cli_execute frowned upon in an ash script ?

In my mind (which rarely makes any sense anyway) it seems like it should only be used for executing a command from the cli

HOWEVER in the scenario below which is better autosll(); or cli_execute();

I have a cleanup script, it does the usual stuff, uses items, autosells junk, puts stuff in the mall and pulverises, BUT, for each item it autosells it creates a server request and the only way I can think to make it less server intense (and faster) is to store the things that need autoselling in a kind of queue and execute them all together and let mafia deal with the 11 per request thing. only trouble is I think this involves making a string and adding items to it then cli_executing it. which to me seam like sloppy coding. (the script, not mafia!)

so whilst its not the question to the answer of life the universe and everything i'd appreciate a little guidance on the use of cli_execute() :)
 

holatuwol

Developer
Instead of creating the string manually, store all the needed values in a map and create a Javascript-style join function for the map type in question. =)  An example of how one might be written is attached.

PHP:
> call join.ash

10 disco ball, 9 disco mask, 3 helmet turtle, 12 mariachi pants, 5 pasta spoon, 6 ravioli hat, 7 saucepan, 2 seal tooth, 1 seal-clubbing club, 8 spices, 11 stolen accordion, 4 turtle totem
 

Attachments

  • join.ash
    750 bytes · Views: 61
Top