Ejemplo n.º 1
0
        public void AddFunction(string[] param)
        {
            int index = 0;


            while (index < param.Length)
            {
                if (index == param.Length)
                {
                    return;
                }
                this.toSend = this.toSend + param[index] + "(";
                index++;
                while (!param[index].Equals("endLine"))
                {
                    if (index >= param.Length)
                    {
                        break;
                    }
                    string str = param[index]; //.ToLower();
                    if (!str.Equals("null") && !str.Equals("default"))
                    {
                        str = KMString.ToGPBinary(str);
                    }
                    this.toSend = this.toSend + str;
                    index++;
                    if (!param[index].Equals("endLine"))
                    {
                        this.toSend = this.toSend + ", ";
                    }
                }
                index++;
                this.toSend = this.toSend + "); ";
            }
        }
Ejemplo n.º 2
0
        public static void RawStringToGPBinaryString(string inStr, ref string outStr)
        {
            int idx = 0;
            //inStr = Encoding.UTF32.GetString(Encoding.Unicode.GetBytes(inStr));
            string command, p = "";

            System.Char c;
            outStr = "";
            int start = 0, end = 0;

            inStr = inStr.Replace("\n", " ");
            inStr = inStr.Replace("\r", " ");

            while (idx < inStr.Length)
            {
                while (idx < inStr.Length && (c = inStr[idx]) == ' ')
                {
                    idx++;
                }
                if (idx >= inStr.Length)
                {
                    break;
                }
                start = idx;
                while (idx < inStr.Length && (c = inStr[idx]) != '(')
                {
                    idx++;
                }
                if (idx >= inStr.Length - 1)
                {
                    idx--;
                }
                end     = idx;
                command = inStr.Substring(start, end - start + 1);
                outStr += command;
                idx++;
                while (idx < inStr.Length && inStr[idx] == ' ')
                {
                    idx++;
                }
                // les paramètres
                while (idx < inStr.Length)
                {
                    if (inStr[idx] == '"') // on commence un texte
                    {
                        idx++;
                        p = "";
                        while (idx < inStr.Length && (c = inStr[idx]) != '"')
                        {
                            p += c;
                            idx++;
                        }
                        if (idx >= inStr.Length - 1)
                        {
                            break;
                        }
                        p = GetUnicodeString(p);
                        p = KMString.ToGPBinary(p);
                        idx++;
                        outStr += p; // "\"" + p + "\"";

                        while (idx < inStr.Length && (c = inStr[idx]) == ' ')
                        {
                            idx++;
                        }
                        // premier cas on a terminé la ligne de commande
                        if ((c = inStr[idx]) == ')')
                        {
                            outStr += "); ";
                            while (idx < inStr.Length && (c = inStr[idx]) != ';') // on cherche la fin de la ligne
                            {
                                idx++;
                            }
                            if (idx >= inStr.Length - 1)
                            {
                                break;
                            }
                        }
                        outStr += ", ";
                    }
                    //sinon on process le prochain paramètre
                    p = "";
                    while (idx < inStr.Length && (c = inStr[idx]) != ',')
                    {
                        if (c == ')')
                        {
                            break;
                        }
                        p += c;
                        idx++;
                    }
                    if (!string.IsNullOrEmpty(p))
                    {
                        p = KMString.ToGPBinary(p);
                    }
                    if ((c = inStr[idx]) == ')')
                    {
                        outStr += p;
                        idx--;
                    }
                    else
                    {
                        if (!string.IsNullOrEmpty(p))
                        {
                            outStr += p + ", ";
                        }
                    }
                    idx++;
                    if (idx >= inStr.Length - 1)
                    {
                        break;
                    }
                    while (idx < inStr.Length && inStr[idx] == ' ')
                    {
                        idx++;
                    }
                    if (idx >= inStr.Length - 1)
                    {
                        break;
                    }
                    if (inStr[idx] == ')')
                    {
                        outStr += "); ";
                        idx++;
                    }
                    if (idx >= inStr.Length - 1)
                    {
                        break;
                    }
                    while (idx < inStr.Length && inStr[idx] == ' ')
                    {
                        idx++;
                    }
                    if (idx >= inStr.Length - 1)
                    {
                        break;
                    }
                    if (inStr[idx] == ';')
                    {
                        //outStr += "; ";
                        idx++;
                        break;
                    }
                }
                while (idx < inStr.Length && inStr[idx] == ' ')
                {
                    idx++;
                }
                if (idx >= inStr.Length - 1)
                {
                    break;
                }
            }
        }