Change a string from single quote to dbl quote

Product Compare Forums Multi-Edit User Created Macros Change a string from single quote to dbl quote

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #1513
    AndyColson
    Participant

    [code:312b47ir]// Andy Colson I donate this to the public domain April 29, 2005
    // ———————————————————————–
    // Change a single quote to a double quote, your cursor must
    // be right before the string or inside the string.
    // It also respects escaped single quotes either:
    // ”
    // \’
    // and converts them to a single quote
    // ———————————————————————–

    macro_file changeQuote;

    void changeQuote()
    {
    int ok = 0;
    Refresh = 0;
    mark_pos;

    if (Cur_Char != ””) {
    while (c_col > 1) {
    left;
    if (Cur_Char == ””) {
    ok = 1;
    break;
    }
    }
    } else {
    ok = 1;
    }

    if (ok == 0) {
    make_message(’no start quote found’);
    goto_mark;
    Refresh = 1;
    return();
    }

    Del_Char;
    Text(’"’);

    // this ‘is ”a\” test

    ok = 0;
    while (ok == 0)
    {
    Forward_Till(””);
    if (Cur_Char == ””)
    {
    ok = 0;
    // if the previous char is backslash, or the next is a quote,
    // its an escaped quote, go on...
    left;
    if (Cur_Char == ‘\’) {
    Del_Char;
    right;
    } else {
    right; // back to where we were, the quote
    right; //next char, is it a quote too?
    if (Cur_Char == ””) {
    Del_Char; //ok, this is the dbl quote, kill it
    } else {
    left; //ok, back to the quote
    ok = 1;
    }
    }
    } else {
    down;
    goto_col(1);
    }
    }

    if (Cur_Char == ””) {
    Del_Char;
    Text(’"’);
    }
    goto_mark;
    Refresh = 1;
    }
    [/code:312b47ir]

Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.