1. Hey! Guest! The 35th GMC Jam will take place between November 28th, 12:00 UTC - December 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice

Skipping tags in a string.

Discussion in 'Programming' started by Edwin, Jul 30, 2019.

  1. Edwin

    Edwin Member

    Joined:
    Jul 15, 2018
    Posts:
    417
    Hello, nice people.

    I'm trying to create a script that will skip the tags like "[color=...]", "[/c]", "[alpha=...]" and stuff and then return a script_copy().

    Code:
    /// string_copy_tag(str,index,count)
    
    // Declare variables
    var str, index, count, p, cst, cct, ast, act, et, l, cstl, cctl, astl, actl;
    
    str = argument[0];
    index = argument[1];
    count = argument[2];
    
    cst = '[c=';
    cct = '[/c]';
    
    ast = '[a=';
    act = '[/a]';
    
    et = ']';
    
    l = string_length(str);
    
    cstl = string_length(cst);
    cctl = string_length(cct);
    
    astl = string_length(ast);
    actl = string_length(act);
    
    p = index - 1;
    
    // String copy
    while (p < count) {
        if (string_copy(str, p + 1, cstl) == cst) {
            p += cstl;
            p += string_pos(et, string_delete(str, 1, p));
        } else if (string_copy(str, p + 1, cctl) == cct) {
            p += cctl;
        } else if (string_copy(str, p + 1, astl) == ast) {
            p += astl;
            p += string_pos(et, string_delete(str, 1, p));
        } else if (string_copy(str, p + 1, actl) == act) {
            p += actl;
        } else {
            p ++;
        };
    };
    
    // Return
    return string_copy(str, index, p);
    
    I made this script but when I'm trying to change the count, it doesn't change the count itself. It's hard to explain but please look at this:

    [​IMG]

    "count" is a variable of an instance. "string" and "string_copy" are input and output string variables.

    How can I increase the count to make this work?
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice