Page 3 of 4 FirstFirst 1 2 3 4 LastLast
Results 21 to 30 of 31

Thread: -Request- Breakfast functionality/collecting "free" items

  1. #21
    Junior Member
    Join Date
    Feb 2009
    Posts
    14

    Default

    Yup! You can string together any number of CLI commands as long as you put semi-colons between them.

    Note that there are a couple of commands that cannot be followed by another. Alias for instance, for very obvious reasons. There might be another few somewhere that I never use.
    Originally Posted by Bale View Post
    The set command doesn't work either unless you include linebreaks. Pretty sure ashq gums it all up as well.

  2. #22
    Senior Member Theraze's Avatar
    Join Date
    Mar 2010
    Posts
    8,731

    Default

    Well, ash or ashq work fine as long as you remember that as soon as you've invoked the new language, that's what that cli_execute will be until it's done. If you want to go back to CLI after invoking ASH, you'll need to run a new instance of cli_execute to do so. And if you started with CLI, any future CLI commands need to be spawned using cli_execute to get back.

  3. #23
    Minion Bale's Avatar
    Join Date
    Jun 2008
    Posts
    13,268

    Default

    Code:
    ashq cli_execute( "ashq cli_execute( "ashq cli_execute( "ashq cli_execute( "ashq cli_execute( "ash print("Nested!");" );" );" );" );" );

  4. #24
    Developer
    Join Date
    Aug 2009
    Posts
    2,683

    Default

    Code:
    ashq cli_execute( "ashq cli_execute( "ashq cli_execute( "ashq cli_execute( "ashq cli_execute( "ash print("Nested!");" );" );" );" );" );
    Originally Posted by Bale View Post
    Your quotation marks aren't escaped, so this'll throw a parsing error (expected ")", found ashq).

    First few levels:
    Code:
    ashq cli_execute( "ashq cli_execute( \"ashq cli_execute( \\\"ashq cli_execute( \\\\\"ashq ... \\\\\" );\\\" );\" );" );

  5. #25
    Minion Bale's Avatar
    Join Date
    Jun 2008
    Posts
    13,268

    Default

    Oops. Thanks for fixing that!

    It's interesting the way that the escape character keeps escalating.

  6. #26
    Developer
    Join Date
    Aug 2009
    Posts
    2,683

    Default

    Well, ultimately you need your underlying string to look like "cli_execute(\"stuff\");". One \ to escape the quotation mark so it shows up in the underlying string, then two to create a backslash. Since two backslashes are needed to create a backslash in the next layer, that quantity doubles when moving forward.

  7. #27
    Minion Bale's Avatar
    Join Date
    Jun 2008
    Posts
    13,268

    Default

    Oh, I got it. I just didn't anticipate it. Neato!

  8. #28
    Senior Member
    Join Date
    Apr 2009
    Posts
    1,713

    Default

    That's still wrong.
    Code:
    ashq cli_execute( "ashq cli_execute( \"ashq cli_execute( \\\"ashq cli_execute( \\\\\"ashq ... \\\\\" );\\\" );\" );" );
    Will execute (each \\ becomes \ and each " becomes ", but without overlap)
    Code:
    ashq cli_execute( "ashq cli_execute( \"ashq cli_execute( \\"ashq ... \\" );\" );" );
    Which looks fine, until you notice that the first \" fails to properly escape the ".

    Working from inside:
    Code:
    ashq ... -- all escaping is inside the ...
    ashq cli_execute( "ashq ..." );
    ashq cli_execute( "ashq cli_execute( \"ashq ...\" );" ); -- 1x \ on the innermost "
    ashq cli_execute( "ashq cli_execute( \"ashq cli_execute( \\\"ashq ...\\\" );\" );" ); -- 3x \ on the innermost "
    ashq cli_execute( "ashq cli_execute( \"ashq cli_execute( \\\"ashq cli_execute( \\\\\\\"ashq ...\\\\\\\" );\\\" );\" );" ); -- 7x \ on the innermost "
    You need to separately escape each \ and ". So it's not (previous)+2, but (previous)*2+1.
    Also, this is why library functions like escape_string (not in ash) exist.

    Code:
    string text = "ashq ..."; // ... needs to already be correctly escaped
    for (int i=10; i-->0; ) { // fortunately ash doesn't have the -- operator
        text = "ashq cli_execute( \"") + escape_string(text) + "\" );";
    }
    cli_execute(text);

  9. #29
    Minion Bale's Avatar
    Join Date
    Jun 2008
    Posts
    13,268

    Default

    LoL! Literally. A friend walked in, feeling annoyed with me, because she thought I overheard something she said in the next room.

    Thanks for the lesson!

  10. #30
    Developer fronobulax's Avatar
    Join Date
    Feb 2009
    Location
    D.C. suburbs of Virginia, USA
    Posts
    3,761

    Default

    LoL! Literally. A friend walked in, feeling annoyed with me, because she thought I overheard something she said in the next room.

    Thanks for the lesson!
    Originally Posted by Bale View Post
    That's what friends are for.
    You just vehemently agreed with me
    Originally Posted by Veracity View Post
    I agree with frono.
    Originally Posted by Veracity View Post
    There are 69 players more powerful than you.
    Originally Posted by Statistics Leaderboards

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •