Links

Categories

Tags


« | Main | »

clause and goto

By Jewe | January 1, 2014

method bool Load(Logging log, string xmlFile)
{
    bool bSuccess = true;
    clause (string msg)
    {
        if (string::isEmpty(xmlFile))
            goto Error("No XML file specified");

        log.WriteTS({"Loading XML file ", xmlFile});
        File myFile;
        if (myFile.Open(xmlFile, Read))
            goto Error("File open failed " + xmlFile);
        System::Xml::Document doc = myFile.ReadText();
        myFile.Close();

        string wt = doc.GetNodeText("xml/waittime");
        if (wt == null)
            goto Error("<waittime> not found in XML");
        WaitTime = (int) wt;

        string mi = doc.GetNodeText("xml/maximages");
        if (mi == null)
            goto Error("<maximages> not found in XML");
        MaxImages = (int) mi;

        Options = doc.GetNodeText("xml/options");
        if (Options == null)
            goto Error("<options> not found in XML");
    }
    clause Error
    {
        log.WriteTS(msg);
        bSuccess = false;
    }
    return bSuccess;
}

Topics: code examples | Comments Off on clause and goto

Comments are closed.