public string[] SelectFirst(string[] FieldNames, string WhereWhat, string EqualsValue) {
			string[] sarrReturn=null;
			if (FieldNames!=null&&FieldNames.Length>0) {
				int[] iarrFieldAbs=new int[FieldNames.Length];
				sarrReturn=new string[FieldNames.Length];
				for (int iFieldRel=0; iFieldRel<FieldNames.Length; iFieldRel++) {
					try {
						iarrFieldAbs[iFieldRel]=this.InternalColumnIndexOf(FieldNames[iFieldRel]);
					}
					catch (Exception exn) {
						RReporting.ShowExn(exn,"getting column index and finding row","rtable SelectFirst(...){FieldNames["+iFieldRel.ToString()+"]:\""+RReporting.SafeIndex(FieldNames,iFieldRel,"FieldNames")+"\"}");
					}
				}
				int iWhat=this.InternalColumnIndexOf(WhereWhat);
				int iRow=-1;
				if (iWhat>-1) {
					iRow=this.InternalRowIndexOfFieldValue(iWhat,EqualsValue);
					if (iRow>-1) {
						for (int iFieldRel=0; iFieldRel<FieldNames.Length; iFieldRel++) {
							sarrReturn[iFieldRel]=this.tearr[iRow].Field(iarrFieldAbs[iFieldRel]);
							if (sarrReturn[iFieldRel]==null) RReporting.ShowErr("Getting row "+iRow+" failed.","selecting database row","string array SelectFirst(...)");
						}
					}
					else RReporting.Warning("Nothing to Select","selecting fields from table by value","rtable SelectFirst(FieldNames,WhereWhat=\""+RReporting.StringMessage(WhereWhat,true)+"\",EqualsValue=\""+RReporting.StringMessage(EqualsValue,true)+"\")");
				}
				else RReporting.ShowErr("Cannot find column \""+RReporting.StringMessage(WhereWhat,true)+"\"","selecting fields from table by value","rtable SelectFirst");
			}
			else RReporting.ShowErr((FieldNames==null)?"null":"zero-length"+" FieldNames--can't select.","selecting fields from table","rtable Select(FieldNames,WhereWhat=\""+RReporting.StringMessage(WhereWhat,true)+"\",EqualsValue=\""+RReporting.StringMessage(EqualsValue,true)+"\")");
			return sarrReturn;
		}//end SelectFirst
Esempio n. 2
0
        public static bool Run(string sLine)
        {
            bool   bGood    = false;
            string sCommand = "";
            string sArgs    = "";
            int    iSpace   = -2;

            if (sLine != null && sLine.Length > 0)
            {
                bool bBlock = false;
                for (int iNow = 0; iNow < sarrBlockCommand.Length; iNow++)
                {
                    if (sLine.StartsWith(sarrBlockCommand[iNow] + " ") || sLine.Contains(" " + sarrBlockCommand[iNow] + " "))                 //||sLine.Contains("|rm ")||sLine.Contains("&rm ")  )
                    {
                        bBlock = true;
                    }
                }
                if (sLine[0] != '/' && !sLine.Contains("|") && !sLine.Contains(">") && !sLine.Contains("<") && !sLine.Contains("&") && !sLine.Contains("xargs") && !bBlock)
                {
                    try {
                        System.Diagnostics.Process proc = new System.Diagnostics.Process();
                        proc.EnableRaisingEvents = false;
                        iSpace = sLine.IndexOf(" ");
                        if (iSpace > -1)
                        {
                            sCommand = sLine.Substring(0, iSpace);
                            sArgs    = sLine.Substring(iSpace + 1);
                            proc.StartInfo.FileName  = sCommand;
                            proc.StartInfo.Arguments = sArgs;
                        }
                        else
                        {
                            proc.StartInfo.FileName = sLine;
                        }
                        proc.Start();
                        //proc.WaitForExit();
                        bGood = true;
                    }
                    catch (Exception exn) {
                        bGood = false;
                        RReporting.ShowExn(exn, "running system command",
                                           String.Format("Run{sLine:{0}; sCommand:{1}; sArgs:{2}}",
                                                         RReporting.StringMessage(sLine, true), RReporting.StringMessage(sCommand, true), RReporting.StringMessage(sArgs, true)
                                                         )
                                           );
                    }
                }
                else
                {
                    Console.Error.WriteLine("Warning: blocked a system command: " + sLine);
                }
            }
            else
            {
                RReporting.Warning("Sent a blank string to RPlatform Run(string sSystemCommand)");
            }
            return(bGood);
        }        //end Run
		/// <summary>
		/// Updates entire row to given array where column WhereFieldName has the exact value of EqualsFieldValue
		/// </summary>
		/// <param name="sarrLiteralFields">Row to replace an existing row if found (or to append to the table if bAppendIfFieldValueNotFound is true)</param>
		/// <param name="WhereFieldName">Update query field name (column)</param>
		/// <param name="EqualsFieldValue">Update at this field value (row)</param>
		/// <param name="bAppendIfFieldValueNotFound">Whether to append the row the table if the query finds no row to update.  If false, method returns false if no row is modified.</param>
		/// <param name="bCopyRowByRef">Keep the row--the values will change here if changed elsewhere.  If false, each of the field values are copied to a new row array.</param>
		/// <returns></returns>
		public bool UpdateAll(out bool bInsertedNewRow, string[] sarrLiteralFields, string WhereFieldName, string EqualsFieldValue, bool bAppendIfFieldValueNotFound, bool bCopyRowByRef) {
			bInsertedNewRow=false;
			bool bGood=false;
			int iInternalRowIndex=-1;
			try {
				int iInternalColumnIndex=InternalColumnIndexOf(WhereFieldName);
				if (iInternalColumnIndex>-1) {
					//ValueExistsInColumn(iInternalColumnIndex,EqualsFieldValue)
					iInternalRowIndex=InternalRowIndexOfFieldValue(iInternalColumnIndex,EqualsFieldValue);
					if (iInternalRowIndex<0) {
						if (bAppendIfFieldValueNotFound) {
							iInternalRowIndex=iRows;
							iRows++;
							bInsertedNewRow=true;
						}
					}
					if (iInternalRowIndex>-1) {
						int iMaxIndex=(iInternalRowIndex>iRows)?iInternalRowIndex:iRows;
						if (iMaxIndex>=this.Maximum) Maximum=iMaxIndex+iMaxIndex/2+1;
						tearr[iInternalRowIndex]=new TableEntry(sarrLiteralFields,bCopyRowByRef);
						bGood=true;
					}
				}//end if WHERE field is accessible
				else {
					bGood=false;
					bInsertedNewRow=false;
					RReporting.ShowErr("Column does not exist","Updating Row","UpdateAll(...,"+RReporting.StringMessage(WhereFieldName,true)+"){Titles:"+RReporting.StringMessage(teTitles.ToCSVLine(this.cFieldDelimiter,this.cTextDelimiter,true),true)+"}");
				}
			}
			catch (Exception exn) {
				bGood=false;
				RReporting.ShowExn(exn,bInsertedNewRow?"inserting row":"updating row","rtable UpdateAll");
				//NOTE: must show exception BEFORE changing bInsertedNewRow so that bInsertedNewRow's status can be recorded
				if (bInsertedNewRow) {
					iRows--;
					if (iRows<0) iRows=0;
					bInsertedNewRow=false;
				}
			}
			return bGood;
		}//end UpdateAll
Esempio n. 4
0
        }        //end FromFixedHeightStaggered

        public bool FromImageValue(string sFile, int iCharWidth, int iCharHeight, int iRows, int iColumns)
        {
            bool  bGood = false;
            RAnim animNormal;

            RReporting.sLastFile = sFile;
            try {
                animNormal = new RAnim();
                bGood      = Init();
                if (bGood)
                {
                    Console.Error.WriteLine("FromImageValue...");
                    bGood = animNormal.SplitFromImage32(sFile, iCharWidth, iCharHeight, iRows, iColumns);
                    if (animNormal.Frame(0) == null)
                    {
                        Console.Error.WriteLine("SplitFromImage32...FAILED -- Null frame zero upon splitting image in " + String.Format("rfont FromImageValue(sFile={0},iCharWidth={1},iCharHeight={2},iRows={3},iColumns={4})", RReporting.StringMessage(sFile, true), iCharWidth, iCharHeight, iRows, iColumns));
                    }
                    else
                    {
                        Console.Error.WriteLine("SplitFromImage32...OK " + String.Format("rfont FromImageValue(sFile={0},iCharWidth={1},iCharHeight={2},iRows={3},iColumns={4})", RReporting.StringMessage(sFile, true), iCharWidth, iCharHeight, iRows, iColumns));
                    }
                    //animNormal.SaveSeq("etc/test/0.debug-glyph", "png");
                    //RImage.OverlayToBigNoClipRaw(ref riTarget, ref ipAt, ref animNormal.riFrame.byarrData, iCharWidth, iCharHeight, 4);
                    if (bGood)
                    {
                        Normal     = animNormal.CopyAsGray();
                        Bold       = Normal.Copy();
                        Italic     = Normal.Copy();
                        BoldItalic = Normal.Copy();
                        //TODO: finish modifying the Glyph Types -- italics using image manip
                    }
                    else
                    {
                        RReporting.ShowErr("Failed to split image", "splitting image from value", "rfont FromImageValue(" + RReporting.StringMessage(sFile, true) + ",...) {}");
                    }
                    //ShowAsciiTable();
                    //Console.Error.WriteLine("Normal.ToString(true):"+Normal.ToString(true));
                }
                else
                {
                    RReporting.ShowErr("Couldn't initialize font glyph graphics buffer", "initializing font graphics", "RFont FromImageValue");
                }
            }
            catch (Exception exn) {
                RReporting.ShowExn(exn, "initializing font graphics", "RFont FromImageValue");
            }
            return(bGood);
        }        //end FromImageValue
Esempio n. 5
0
        public bool FromFixedHeightStaggered(string sFile, int iCharHeight)          //this is named FromFixedHeightStaggered while the function it called anim.SplitFromFixedHeightStaggered
        {
            RReporting.sLastFile = sFile + "...";
            bool  bGood      = false;
            RAnim animNormal = null;

            bGood = Init();
            try {
                if (!sFile.EndsWith(".png"))
                {
                    animNormal = new RAnim();
                    RImage riNormal = new RImage();
                    RReporting.sLastFile = sFile + ".png";
                    if (!riNormal.Load(sFile + ".png", 4))                    //assumes 32-bit is needed
                    {
                        RReporting.ShowErr("Cannot load font file", "", "RAnim FromFixedHeightStaggered(\"" + RString.SafeString(sFile) + ".png\")");
                    }
                    RReporting.sParticiple = "splitting normal font image";
                    bGood = animNormal.SplitFromFixedHeightStaggered(riNormal, iCharHeight);
                    if (bGood)
                    {
                        Normal = animNormal;
                        bGood  = Normal != null;
                        if (Normal == null)
                        {
                            RReporting.ShowErr("failed to load normal font though split image returned true", "checking loaded normal font", "rfont_bgra32 FromFixedHeightStaggered");
                        }
                        if (File.Exists(sFile + "-bold.png"))
                        {
                            RReporting.sLastFile = sFile + "-bold.png";
                            if (animarrGlyphType[RFont.GlyphTypeBold] == null)
                            {
                                Bold = new RAnim();
                            }
                            RImage riBold = new RImage();
                            RReporting.sParticiple = "loading bold font image";
                            riBold.Load(sFile + "-bold.png", 4);                         //assumes 32-bit is needed
                            if (!Bold.SplitFromFixedHeightStaggered(riBold, iCharHeight))
                            {
                                RReporting.sParticiple = "falling back to generated bold font";
                                bGood = false;
                                RReporting.ShowErr("Could not split image to bold font frames", "separating bold font frames", "rfont_bgra32 FromFixedHeightStaggered");
                                Bold = animNormal.Copy();
                                //TODO: embolden font manually
                            }
                        }
                        else
                        {
                            RReporting.sParticiple = "getting bold font image from normal";
                            Bold = animNormal.Copy();
                            if (Bold != null)
                            {
                                //TODO: embolden font manually
                            }
                            else
                            {
                                bGood = false;
                                RReporting.ShowErr("Could not copy font frames", "copying font frames to bold font frames", "rfont_bgra32 FromFixedHeightStaggered");
                            }
                        }
                        RReporting.sParticiple = "getting italic font image from normal";
                        Italic = Normal.Copy();
                        if (Italic != null)
                        {
                            //TODO: italicize font manually
                        }
                        else
                        {
                            bGood = false;
                            RReporting.ShowErr("Could not copy font frames", "copying font frames to italic font frames", "rfont_bgra32 FromFixedHeightStaggered");
                        }
                        RReporting.sParticiple = "getting bold italic font image from bold";
                        BoldItalic             = Bold.Copy();
                        if (BoldItalic != null)
                        {
                            //TODO: italicize bold font manually
                        }
                        else
                        {
                            bGood = false;
                            RReporting.ShowErr("Could not copy font frames", "copying font frames to bold italic font frames", "rfont_bgra32 FromFixedHeightStaggered");
                        }
                        CalculateSpacing(GlyphTypeNormal);
                    }
                    else
                    {
                        RReporting.ShowErr("Could not split image to font frames", "separating font frames", "rfont_bgra32 FromFixedHeightStaggered");
                    }
                }
                else
                {
                    bGood = false;
                    RReporting.ShowErr("Font file base name must not end with extension--must have assumed png extension.", "checking raster font file", "rfont_bgra32 FromFixedHeightStaggered");
                }
            }
            catch (Exception exn) {
                bGood = false;
                RReporting.ShowExn(exn, "Splitting Proportional Font Glyphs", "FromFixedHeightStaggered(" + sFile + "," + iCharHeight.ToString() + ")");
            }
            if (this.animarrGlyphType != null)
            {
                for (int i = 0; i < RFont.iGlyphTypes; i++)
                {
                    if (animarrGlyphType[i] == null)
                    {
                        RReporting.ShowErr("Null glyph type " + RFont.GlyphTypeToString(i), "getting glyphs from images", "FromFixedHeightStaggered(sFile=" + RReporting.StringMessage(sFile, true) + ",iCharHeight=" + iCharHeight + ")");
                    }
                    else if (!animarrGlyphType[i].FrameIsCached(0))
                    {
                        RReporting.ShowErr("First glyph is null in glyph type " + RFont.GlyphTypeToString(i), "getting glyphs from images", "FromFixedHeightStaggered(sFile=" + RReporting.StringMessage(sFile, true) + ",iCharHeight=" + iCharHeight + ")");
                    }
                }
            }
            else
            {
                RReporting.ShowErr("Null glyph type array", "getting glyphs from images", "FromFixedHeightStaggered(sFile=" + RReporting.StringMessage(sFile, true) + ",iCharHeight=" + iCharHeight + ")");
            }
            return(bGood);
        }        //end FromFixedHeightStaggered
Esempio n. 6
0
 public bool Enq(string sAdd)           //Enqueue
 {
     if (!IsFull)
     {
         try {
             arrobjects[NewIndex] = sAdd;
             iCount_PlusFirstIsOneAfterLast++;
             //sLogLine="debug enq iCount_PlusFirstIsOneAfterLast="+iCount_PlusFirstIsOneAfterLast.ToString();
             return(true);
         }
         catch (Exception exn) {
             RReporting.ShowExn(exn, "accessing stringq array", "stringq Enq(" + RReporting.StringMessage(sAdd, false) + ") {enqueue-at:" + NewIndex.ToString() + "}");
         }
         return(false);
     }
     else
     {
         RReporting.ShowErr("StringQ is full, can't enqueue", "StringQ Enq(" + ((sAdd == null)?"null string":"non-null") + ") {used:" + iCount_PlusFirstIsOneAfterLast.ToString() + "}");
         return(false);
     }
 }
		public int InternalRowIndexOfFieldValue(int AtInternalColumnIndex, string FieldValue) {
			int iReturn=-1;
			string FieldDataNow;
			if (FieldValue!=null&&FieldValue!="") {
				for (int iRow=0; iRow<iRows; iRow++) {
					FieldDataNow=tearr[iRow].Field(AtInternalColumnIndex);
					if (FieldDataNow==null) {
						RReporting.ShowErr("Can't access field","getting internal row index by value","InternalRowIndexOfFieldValue(AtInternalColumnIndex="+AtInternalColumnIndex+", FieldValue="+RReporting.StringMessage(FieldValue,true)+"){Row:"+iRow+"}");
					}
					else if (FieldDataNow==FieldValue) {
						iReturn=iRow;
						break;
					}
				}
			}
			else {
				RReporting.Warning((FieldValue==null?"null":"zero-length")+" FieldValue search was skipped--reporting as not found.","looking for value in column","InternalRowIndexOfFieldValue");
			}
			return iReturn;
		}//end InternalRowIndexOfFieldValue
		}//end iReturn
		public bool Update(int InternalRowIndex, int InternalColumnIndex, string val) {
			bool bGood=false;
			try {
				if (InternalRowIndex>=0&&InternalRowIndex<this.Rows) {
					if (InternalColumnIndex>=0&&InternalColumnIndex<this.Columns) {
						if (tearr!=null) {
							bGood=tearr[InternalRowIndex].SetField(InternalColumnIndex,val);
						}
						else RReporting.ShowErr("Tried to update column in null table","updating field by internal indeces","Update("+InternalRowIndex.ToString()+","+InternalColumnIndex.ToString()+","+RReporting.StringMessage(val,false)+"){tearr:null}");
					}
					else RReporting.ShowErr("Tried to update column beyond range","updating field by internal indeces","Update("+InternalRowIndex.ToString()+","+InternalColumnIndex.ToString()+","+RReporting.StringMessage(val,false)+")");
				}
				else RReporting.ShowErr("Tried to update row beyond range","updating field by internal indeces","Update("+InternalRowIndex.ToString()+","+InternalColumnIndex.ToString()+","+RReporting.StringMessage(val,false)+")");
			}
			catch (Exception exn) {
				RReporting.ShowExn(exn,"updating row by internal indeces","Update("+InternalRowIndex.ToString()+","+InternalColumnIndex.ToString()+","+RReporting.StringMessage(val,false)+")");
			}
			return bGood;
		}
		}//end Save
		public bool SaveChunk(string sFile, bool bReplaceNewLineWithTabInsteadOfHTMLBrWithMarkerProperty, bool bExtendedTitleColumns, int RowStart, int RowCount, int ColStart, int ColCount) {
			StreamWriter fsDest=null;
			//sLastFile=sFile; do NOT set, since only saving a chunk and therefore says nothing about the source
			//if (sLastFile==null) sLastFile="";
			bool bGood=false;
			//int iLines=0;
			RecheckIntegrity();
			try {
				fsDest=new StreamWriter(sFile);
				if (TitleRowIsNonBlank) {
					//fsDest.WriteLine(teTitles.ToCSVLine(cFieldDelimiter,cTextDelimiter,bReplaceNewLineWithTabInsteadOfHTMLBrWithMarkerProperty));
					string sTitles="";
					string sField="";
					int ColAbs=ColStart;
					for (int ColRel=0; ColRel<ColCount; ColRel++) {
						sField="";
						if (bExtendedTitleColumns) {
							sField=RString.SafeString(GetForcedType(ColAbs),false);
							if (sField!="") sField+=" ";
						}//end if bExtendedTitleColumns
						string FieldDataNow=teTitles.Field(ColAbs);
						if (FieldDataNow==null) {
							RReporting.ShowErr("Can't access field","saving csv file","Save("+RReporting.StringMessage(sFile,true)+","+(bReplaceNewLineWithTabInsteadOfHTMLBrWithMarkerProperty?"TAB as newline mode":"BR with marker as newline mode")+"){Row:title; Column:"+ColAbs+"}");
						}
						sField+=RString.SafeString(FieldDataNow,false);
						if (bExtendedTitleColumns) {
							string sMeta=GetForcedMeta(ColAbs);
							if (sMeta!=null) {
								sMeta=RString.SafeString(sMeta,false);
								sMeta=RString.RemoveEndsWhiteSpace(sMeta);
								if (!sMeta.StartsWith("{")) {
									sMeta=RString.Replace(sMeta,"{","");
									sMeta="{"+sMeta;
								}
								if (!sMeta.EndsWith("}")) {
									sMeta=RString.Replace(sMeta,"}","");
									sMeta+="}";
								}
								sField+=sMeta;
							}//end if metadata
						}//end if bExtendedTitleColumns
						sTitles+=((ColRel!=0)?",":"")+RTable.LiteralFieldToCSVField(sField,this.cFieldDelimiter,this.cTextDelimiter,bReplaceNewLineWithTabInsteadOfHTMLBrWithMarkerProperty);
						ColAbs++;
					}//end for field (column header)
					fsDest.WriteLine(sTitles);
				}//end if Title Row is not blank
				Console.Error.Write("Writing row range "+RowStart+" to "+(RowStart+RowCount-1)+" of "+iRows+" (total "+0+" to "+(iRows-1)+")...");
				int RowAbs=RowStart;
				for (int RowRel=0; RowRel<RowCount&&RowAbs<iRows; RowRel++) {
					fsDest.WriteLine(RowToCSVLine(RowAbs,bReplaceNewLineWithTabInsteadOfHTMLBrWithMarkerProperty,ColStart,ColCount));
					RowAbs++;
				}
				fsDest.Close();
				Console.Error.WriteLine("done.");
				bGood=true;
			}
			catch (Exception exn) {
				Console.Error.WriteLine("Could not save table to \""+sFile+"\":");
				Console.Error.WriteLine(exn.ToString());
				bGood=false;
				try { fsDest.Close(); }
				catch (Exception exn2) {
					RReporting.ShowExn(exn2,"closing file after exception","rtable Load");
				}
			}
			return bGood;
		}//end SaveChunk
		}//end Delete_AllWithMarker
		public bool Save(string sFile, bool bReplaceNewLineWithTabInsteadOfHTMLBrWithMarkerProperty, bool Set_bSaveMetaDataInTitleRow) {
			if (sLastFile==sFileUnknown) {
				sLastFile=sFile;
				if (sLastFile==null) sLastFile="";
			}
			bSaveMetaDataInTitleRow=Set_bSaveMetaDataInTitleRow;
			StreamWriter fsDest=null;
			bool bGood=false;
			//int iLines=0;
			Delete_AllWithMarker();
			RecheckIntegrity();
			try {
				fsDest=new StreamWriter(sFile);
				if (TitleRowIsNonBlank) {
					//fsDest.WriteLine(teTitles.ToCSVLine(cFieldDelimiter,cTextDelimiter,bReplaceNewLineWithTabInsteadOfHTMLBrWithMarkerProperty));
					string sTitles="";//cumulative
					string sField="";//cumulative
					for (int iCol=0; iCol<teTitles.Columns; iCol++) {
						sField="";//sField=RString.SafeString(GetForcedType(iCol),false);//old way
						if (bSaveMetaDataInTitleRow) sField=RString.SafeString(GetForcedType(iCol),false);
						if (sField!="") sField+=" ";
						string FieldDataNow=teTitles.Field(iCol);
						if (FieldDataNow==null) {
							RReporting.ShowErr("Can't access field","saving csv file","Save("+RReporting.StringMessage(sFile,true)+","+(bReplaceNewLineWithTabInsteadOfHTMLBrWithMarkerProperty?"TAB as newline mode":"BR with marker as newline mode")+"){Row:title; Column:"+iCol+"}");
						}
						sField+=RString.SafeString(FieldDataNow,false);
						if (bSaveMetaDataInTitleRow) {
						string sMeta=GetForcedMeta(iCol);
							if (sMeta!=null) {
								sMeta=RString.SafeString(sMeta,false);
								sMeta=RString.RemoveEndsWhiteSpace(sMeta);
								if (!sMeta.StartsWith("{")) {
									sMeta=RString.Replace(sMeta,"{","");
									sMeta="{"+sMeta;
								}
								if (!sMeta.EndsWith("}")) {
									sMeta=RString.Replace(sMeta,"}","");
									sMeta+="}";
								}
								sField+=sMeta;
							}//end if metadata
						}//end if bSaveMetaDataInTitleRow
						sTitles+=((iCol!=0)?",":"")+RTable.LiteralFieldToCSVField(sField,this.cFieldDelimiter,this.cTextDelimiter,bReplaceNewLineWithTabInsteadOfHTMLBrWithMarkerProperty);
					}//end for column title iCol
					fsDest.WriteLine(sTitles);
				}
				Console.Error.Write("Writing "+iRows+" rows...");
				for (int iNow=0; iNow<iRows; iNow++) {
					fsDest.WriteLine(RowToCSVLine(iNow,bReplaceNewLineWithTabInsteadOfHTMLBrWithMarkerProperty));
				}
				fsDest.Close();
				Console.Error.WriteLine("done.");
				bGood=true;
			}
			catch (Exception exn) {
				Console.Error.WriteLine("Could not save table to \""+sFile+"\":");
				Console.Error.WriteLine(exn.ToString());
				bGood=false;
				try { fsDest.Close(); }
				catch (Exception exn2) {
					RReporting.ShowExn(exn2,"closing file after exception","rtable Load");
				}
			}
			return bGood;
		}//end Save
		public bool Load(string sFile, bool FirstRowHasTitles) {
			sLastFile=sFile;
			if (sLastFile==null) sLastFile="";
			bool bGood=false;
			bFirstRowLoadAndSaveAsTitles=FirstRowHasTitles;
			StreamReader fsSource=null;
			string sLine=null;
			try {
				fsSource=new StreamReader(sFile);
				if (bFirstRowLoadAndSaveAsTitles) {
					sLine=fsSource.ReadLine();
					if ( bShowNewlineWarning && (RString.Contains(sLine,'\n')||RString.Contains(sLine,'\r')) ) {
						MessageBox.Show("Warning: newline character found in field.  File may have been saved in a different operating system and need line breaks converted.");
						bShowNewlineWarning=false;
					}
					teTitles=new TableEntry(RTable.SplitCSV(sLine,cFieldDelimiter,cTextDelimiter));
					//Parse TYPE NAME{METANAME:METAVALUE;...} title row notation:
					if (teTitles.Columns>0) {
						sarrFieldMetaData=new string[teTitles.Columns];
						iarrFieldType=new int[teTitles.Columns];
						for (int iColumn=0; iColumn<teTitles.Columns; iColumn++) {
							string FieldDataNow=teTitles.Field(iColumn);
							if (FieldDataNow==null) {
								RReporting.ShowErr("Field is not accessible","loading csv file","Load("+RReporting.StringMessage(sFile,true)+",...){Row 0:Titles; Column:"+iColumn+"}");
							}
							int iType=StartsWithType(FieldDataNow);
							int iStartName=0;
							if (iType>-1) {
								iarrFieldType[iColumn]=iType;
								iStartName=sarrType[iType].Length+1; //teTitles.SetField(iColumn,RString.SafeSubstring(teTitles.Field(iColumn),sarrType[iType].Length+1));
							}
							else {
								RReporting.Debug("Unknown type in column#"+iColumn.ToString()+"("+RReporting.StringMessage(FieldDataNow,true)+")");
							}
							int iMetaData=-1;
							//if (FieldDataNow!=null) {
							iMetaData=FieldDataNow.IndexOf("{");
							//}
							if (iMetaData>-1) {
								//string FieldDataNow=teTitles.Field(iColumn);
								if (FieldDataNow==null) {
									RReporting.ShowErr("Can't access field","loading csv file","rtable Load("+RReporting.StringMessage(sFile,true)+"){Row:titles; Column:"+iColumn+"}");
								}
								this.sarrFieldMetaData[iColumn]=FieldDataNow.Substring(iMetaData);
								while (iMetaData>=0 && (FieldDataNow[iMetaData]=='{'||FieldDataNow[iMetaData]==' ')) iMetaData--;
								teTitles.SetField(iColumn,RString.SafeSubstringByInclusiveEnder(FieldDataNow,iStartName,iMetaData));
							}
							else {
								teTitles.SetField(iColumn,RString.SafeSubstring(FieldDataNow,iStartName));
							}
						}//end for iColumn in title row
					}//end if teTitles.Columns>0
				}//if bFirstRowLoadAndSaveAsTitles
				tearr=new TableEntry[256];
				for (int iNow=0; iNow<tearr.Length; iNow++) {
					tearr[iNow]=null;
				}
				iRows=0;
				//if (!bFirstRowLoadAndSaveAsTitles||sLine!=null) {
				if (bAllowNewLineInQuotes) {
					bool bInQuotes=false;
					string sLineCombined="";
					while ( (sLine=fsSource.ReadLine()) != null ) {
						if (iRows>=Maximum) Maximum=iRows+iRows/2+1;
						for (int iChar=0; iChar<RString.SafeLength(sLine); iChar++) {
							if (sLine[iChar]==this.cTextDelimiter) bInQuotes=!bInQuotes;
						}
						sLineCombined+=sLine;
						if (!bInQuotes) {
							tearr[iRows]=new TableEntry(RTable.SplitCSV(sLineCombined,cFieldDelimiter,cTextDelimiter));
							iRows++;
							sLineCombined="";
						}
					}//end while not end of file
					if (sLineCombined!="") { //get bad data so it doesn't get lost
						tearr[iRows]=new TableEntry(RTable.SplitCSV(sLineCombined,cFieldDelimiter,cTextDelimiter));
						iRows++;
					}
				}
				else {
					while ( (sLine=fsSource.ReadLine()) != null ) {
						if (iRows>=Maximum) Maximum=iRows+iRows/2+1;
						tearr[iRows]=new TableEntry(RTable.SplitCSV(sLine,cFieldDelimiter,cTextDelimiter));
						iRows++;
					}
				}
				//}//if any data rows
				if (iRows<Maximum) {
					for (int i=iRows; i<Maximum; i++) {
						tearr[i]=new TableEntry();
					}
				}
				bGood=true;
				fsSource.Close();
			}
			catch (Exception exn) {
				RReporting.ShowExn(exn,"Loading table","rtable Load(\""+RReporting.StringMessage(sFile,true)+"\",FirstRowHasTitles="+(FirstRowHasTitles?"yes":"no")+")");
				try { fsSource.Close(); }
				catch (Exception exn2) {
					RReporting.ShowExn(exn2,"closing file after exception","rtable Load");
				}
			}
			return bGood;
		}//end Load