Exemplo n.º 1
0
    public static SAtt FindSAtt(SAtt llist, string code)
    {
        //{Search through the list looking for a String Attribute}
        //{whose code matches CODE and return its address.}
        //{Return Nil if no such SAtt can be found.}

        //{Initialize IT to Nil.}
        SAtt it = null;

        code = code.ToUpper();

        //{Check through all the SAtts looking for the SATT in question.}
        while (llist != null)
        {
            string S = llist.info;
            S = texutil.ExtractWord(ref S).ToUpper();
            if (S == code)
            {
                it = llist;
            }

            llist = llist.next;
        }

        return(it);
    }
Exemplo n.º 2
0
    public static SAtt StoreSAtt(ref SAtt llist, string info)
    {
        //{ Add string attribute Info to the list. This procedure }
        //{ doesn't check to make sure this attribute isn't duplicated. }
        SAtt it = CreateSAtt(ref llist);

        it.info = info;

        //{Return a pointer to the new attribute.}
        return(it);
    }
Exemplo n.º 3
0
    public static string SAttValue(SAtt llist, string code)
    {
        //{Find a String Attribute which corresponds to Code, then}
        //{return its embedded alligator string.}
        SAtt it = FindSAtt(llist, code);

        if (it == null)
        {
            return("");
        }

        return(texutil.RetrieveAString(it.info));
    }
Exemplo n.º 4
0
    public static SAtt CreateSAtt(ref SAtt llist)
    {
        //{Add a new element to the head of LList.}

        //{Allocate memory for our new element.}
        SAtt it = new SAtt();

        //{Attach IT to the list.}
        it.next = llist;
        llist   = it;

        //{Return a pointer to the new element.}
        return(it);
    }
Exemplo n.º 5
0
    public static void WriteSAtt(SAtt SA, StreamWriter f)
    {
        //{ Output the provided list of string attributes. }

        //{ Export String Attributes }
        while (SA != null)
        {
            //{ Error check- only output valid string attributes. }
            if (SA.info.IndexOf('<') >= 0)
            {
                f.WriteLine(SA.info);
            }
            SA = SA.next;
        }

        //{ Write the sentinel line here. }
        f.WriteLine("Z");
    }
Exemplo n.º 6
0
    public static void RemoveSAtt(ref SAtt llist, SAtt lmember)
    {
        //{Locate and extract member LMember from list LList.}
        //{Then, dispose of LMember.}

        //{ Initialize A and B}
        SAtt B = llist;
        SAtt A = null;

        //{Locate LMember in the list. A will thereafter be either Nil,}
        //{if LMember if first in the list, or it will be equal to the}
        //{element directly preceding LMember.}
        while (B != lmember && B != null)
        {
            A = B;
            B = B.next;
        }

        if (B == null)
        {
            //{Major FUBAR. The member we were trying to remove can't}
            //{be found in the list.}
            Crt.Write("ERROR- RemoveSAtt asked to remove a link that doesnt exist.");
            do
            {
                rpgtext.RPGKey();
            } while (true);
        }
        else if (A == null)
        {
            //{There's no element before the one we want to remove,}
            //{i.e. it's the first one in the list.}
            llist = B.next;
            B     = null;
        }
        else
        {
            //{We found the attribute we want to delete and have another}
            //{one standing before it in line. Go to work.}
            A.next = B.next;
            B      = null;
        }
    }
Exemplo n.º 7
0
    public static SAtt ReadSAtt(StreamReader f)
    {
        //{ Read some string attributes from the file. }
        SAtt it = null;

        //{ Keep processing this file until either the sentinel }
        //{ is encountered or we run out of data. }
        string line = "Z";

        do
        {
            //{ read the next line of the file. }
            line = f.ReadLine();

            //{ If this is a valid string attribute, file it. }
            if (line.IndexOf('<') >= 0)
            {
                StoreSAtt(ref it, line);
            }
        }while (line != "Z");

        return(it);
    }
Exemplo n.º 8
0
    public static SAtt SetSAtt(ref SAtt llist, string info)
    {
        //{Add string attribute Info to the list. However, a gear}
        //{may not have two string attributes with the same name.}
        //{So, check to see whether or not the list already contains}
        //{a string attribute of this type; if so, just replace the}
        //{INFO field. If not, create a new SAtt and fill it in.}

        //{Determine the CODE of the string.}
        string code = info;

        code = texutil.ExtractWord(ref code);

        //{See if that code already exists in the list,}
        //{if not create a new entry for it.}
        SAtt it = FindSAtt(llist, code);

        //{Plug in the value.}
        if (texutil.RetrieveAString(info) == "")
        {
            if (it != null)
            {
                RemoveSAtt(ref llist, it);
            }
        }
        else
        {
            if (it == null)
            {
                it = CreateSAtt(ref llist);
            }
            it.info = info;
        }

        //{Return a pointer to the new attribute.}
        return(it);
    }