Ejemplo n.º 1
0
        private int CurrentWordEndPos()
        {
            if (tbExpression.Text == "")
            {
                return(0);
            }

            int index = tbExpression.SelectionStart - 1;

            while (true)
            {
                if (index < 0 || index > tbExpression.Text.Length - 1)
                {
                    break;
                }

                char c = tbExpression.Text[index];
                if (FlowDataManager.ValidNameChar(c) || c == '$')
                {
                    index++;
                }
                else
                {
                    break;
                }
            }
            index--;
            return(index);
        }
Ejemplo n.º 2
0
        /// function to get var name from a declaration
        private string TakeVarNameFromDeclaration(string expression)
        {
            string temp           = FlowDataManager.RemoveSpacing(expression + "=");
            string result         = "";
            bool   StartedVarName = false;

            for (int i = 0; i < temp.Length; i++)
            {
                if (temp[i] == ':')
                {
                    StartedVarName = true;
                    continue;
                }

                if (temp[i] == '=')
                {
                    break;
                }

                if (StartedVarName)
                {
                    result += temp[i];
                }
            }

            if (FlowDataManager.ValidName(result))
            {
                return(result);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 3
0
        // WATCH TABLE
        public void UpdateWatch(FlowDataManager flowData)
        {
            ClearWatch();
            List <KeyValuePair <string, VarInfo> > varList = flowData.GetVarList();

            foreach (var element in varList)
            {
                string varName  = element.Key;
                string varType  = element.Value.type.ToString().Remove(0, 3);
                string varValue = element.Value.value;

                switch (varType)
                {
                case "Number":
                {
                    break;
                }

                case "String":
                {
                    varValue = varValue.Replace("\"", "\"\"");
                    varValue = "\"" + varValue + "\"";
                    break;
                }

                case "Boolean":
                {
                    varValue = "$" + varValue;
                    break;
                }

                default:
                {
                    varValue = "Unhandled data type!";
                    break;
                }
                }

                if (element.Value.isNull)
                {
                    varValue = "$NULL";
                }

                dtvWatcher.Rows.Add(varName, varType, varValue);
            }
        }
Ejemplo n.º 4
0
        private IGoLink PickLinkFromConditionBlock(List<IGoLink> OutLinks, VarInfo blockResult, out string ErrorReport)
        {
            IGoLink pickedLink = null;
            ErrorReport = "";
            int countElement = OutLinks.Count;

            // check for duplicated link value:
            for(int i=0; i<countElement-1; i++)
                for(int j=i+1; j<countElement; j++)
                {
                    string linkValue1 = ( (OutLinks[i] as GoLabeledLink).FromLabel as GoText).Text;
                    linkValue1 = linkValue1.ToUpper();
                    linkValue1 = FlowDataManager.RemoveSpacing(linkValue1);
                    if (linkValue1 == "")
                    {
                        ErrorReport = "Error: Blank out-link label";
                        return null;
                    }
                    if (linkValue1[0] >= 'A' && linkValue1[0] <= 'Z')
                        linkValue1 = "$" + linkValue1;

                    string linkValue2 = ( (OutLinks[j] as GoLabeledLink).FromLabel as GoText).Text;
                    linkValue2 = linkValue2.ToUpper();
                    linkValue2 = FlowDataManager.RemoveSpacing(linkValue2);
                    if (linkValue2 == "")
                    {
                        ErrorReport = "Error: Blank out-link label";
                        return null;
                    }
                    if (linkValue2[0]>='A' && linkValue2[0]<='Z')
                        linkValue2 = "$" + linkValue2;

                    if(linkValue1 == "$ELSE")
                    {
                        pickedLink = OutLinks[i];
                    }
                    if(linkValue2 == "$ELSE")
                    {
                        pickedLink = OutLinks[j];
                    }
                    if(linkValue1 == "$ELSE" && linkValue2 == "$ELSE")
                    {
                        ErrorReport = "Error: Duplicated out link label/value: ELSE";
                        return null;
                    }

                    VarInfo linkVar1 = FlowDataManager.HandleConst(linkValue1);
                    VarInfo linkvar2 = FlowDataManager.HandleConst(linkValue2);

                    if( VarInfo.IsEqual(linkVar1,linkvar2) )
                    {
                        ErrorReport = "Error: Duplicated out link label/value: " + linkValue1;
                        return null;
                    }

                }

            // check all valid links
            foreach(IGoLink link in OutLinks)
            {
                string linkValue = ( (link as GoLabeledLink).FromLabel as GoText).Text;
                linkValue = linkValue.ToUpper();
                linkValue = FlowDataManager.RemoveSpacing(linkValue);
                if (linkValue == "")
                {
                    ErrorReport = "Error: Blank out-link label";
                    return null;
                }
                if (linkValue[0]>='A' && linkValue[0]<='Z')
                        linkValue = "$" + linkValue;

                if(linkValue == "$ELSE")
                {
                    continue;
                }

                VarInfo tempVar = FlowDataManager.HandleConst(linkValue);

                if(tempVar.isNull)
                {
                    ErrorReport = "Error: Illegal out-link label: " + linkValue;
                    return null;
                }

                if( VarInfo.IsEqual(tempVar, blockResult) )
                {
                    pickedLink = link;
                }
            }

            if(pickedLink == null)
            {
                ErrorReport = "Error: Couldn't find a label that matches value: " + blockResult.value;
                return null;
            }

            return pickedLink;
        }