Esempio n. 1
0
 public static byte[] ToByteArray(string sData)
 {
     byte[] byarrReturn = null;
     try {
         if (sData != null && sData.Length > 0)
         {
             byarrReturn = new byte[sData.Length];
             for (int iNow = 0; iNow < sData.Length; iNow++)
             {
                 byarrReturn[iNow] = (byte)(sData[iNow] & 0xFF);
             }
         }
         else
         {
             if (bDebug)
             {
                 RReporting.Debug("ToByteArray warning: no data");
             }
         }
         if (RReporting.SafeLength(sData) != RReporting.SafeLength(byarrReturn))
         {
             Console.Error.WriteLine("ToByteArray error: source string length was {0} but result was a {1}-length byte array",
                                     RReporting.SafeLength(sData), RReporting.SafeLength(byarrReturn));
         }
     }
     catch (Exception exn) {
         RReporting.ShowExn(exn);
     }
     return(byarrReturn);
 }        //end ToByteArray
Esempio n. 2
0
        }        //end Redim(ref string[],...)

        public static bool Redim(ref int[] valarr, int iSetSize, string sSender_ForErrorTracking)
        {
            bool bGood = false;

            if (iSetSize == 0)
            {
                valarr = null;
            }
            else if (iSetSize > 0)
            {
                if (iSetSize != RReporting.SafeLength(valarr))
                {
                    int[] valarrNew = new int[iSetSize];
                    for (int iNow = 0; iNow < iSetSize; iNow++)
                    {
                        if (iNow < RReporting.SafeLength(valarr))
                        {
                            valarrNew[iNow] = valarr[iNow];
                        }
                        else
                        {
                            valarrNew[iNow] = 0;
                        }
                    }
                    valarr = valarrNew;
                    bGood  = true;
                }
            }
            else
            {
                RReporting.ShowErr("Tried to set " + sSender_ForErrorTracking + " maximum strings to less than zero" + " set maximum strings", "setting " + sSender_ForErrorTracking + " to negative maximum {iSetSize:" + iSetSize.ToString() + "}");
            }
            return(bGood);
        }        //end Redim(ref int[],...)
Esempio n. 3
0
        public static bool Redim(ref string[] valarr, int iSetSize)
        {
            bool bGood = false;

            if (iSetSize == 0)
            {
                valarr = null;
            }
            else if (iSetSize > 0)
            {
                if (iSetSize != RReporting.SafeLength(valarr))
                {
                    string[] valarrNew = new string[iSetSize];
                    for (int iNow = 0; iNow < iSetSize; iNow++)
                    {
                        if (iNow < RReporting.SafeLength(valarr))
                        {
                            valarrNew[iNow] = valarr[iNow];
                        }
                        else
                        {
                            valarrNew[iNow] = "";
                        }
                    }
                    valarr = valarrNew;
                    bGood  = true;
                }
            }
            else
            {
                string sCallStack = RReporting.StackTraceToLatinCallStack(new System.Diagnostics.StackTrace());
                RReporting.ShowErr("Tried to set " + sCallStack + " maximum strings to less than zero" + " set maximum strings", "setting " + sCallStack + " to negative maximum {iSetSize:" + iSetSize.ToString() + "}");
            }
            return(bGood);
        }        //end Redim(ref string[],...)
Esempio n. 4
0
        }        //end Redim byte[]

        public static bool Redim(ref PictureBox[] arrNow, int iSetSize)
        {
            bool bGood = false;

            if (iSetSize != RReporting.SafeLength(arrNow))
            {
                if (iSetSize <= 0)
                {
                    arrNow = null; bGood = true;
                }
                else
                {
                    try {
                        //bool bGood=false;
                        PictureBox[] arrNew = new PictureBox[iSetSize];
                        for (int iNow = 0; iNow < arrNew.Length; iNow++)
                        {
                            if (iNow < RReporting.SafeLength(arrNow))
                            {
                                arrNew[iNow] = arrNow[iNow];
                            }
                            else
                            {
                                arrNew[iNow] = null;                           //new PictureBox();//null;//Var.Create("",TypeNULL);
                            }
                        }
                        arrNow = arrNew;
                        //bGood=true;
                        //if (!bGood) RReporting.ShowErr("No vars were found while trying to set MaximumSeq!");
                        bGood = true;
                    }
                    catch (Exception e) {
                        bGood = false;
                        string sCallStack = RReporting.StackTraceToLatinCallStack(new System.Diagnostics.StackTrace());
                        RReporting.ShowExn(e, "resizing picture box array", "Redim(PictureBox array)[" + sCallStack + " failed setting PictureBox array Maximum]");
                    }
                }
            }
            else
            {
                bGood = true;
            }
            return(bGood);
        }        //Redim