⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qimport3common.pas

📁 在C++Builder中直接用于数据的输出
💻 PAS
📖 第 1 页 / 共 4 页
字号:
unit QImport3Common;

{$I VerCtrl.inc}

{$IFDEF VCL6} 
  {$WARN SYMBOL_PLATFORM OFF} 
{$ENDIF}

interface

uses
  {$IFDEF QI_UNICODE}
    {$IFDEF VCL10} WideStrings, {$ELSE} EmsWideStrings, {$ENDIF}
    EmsWideStringGrid,
  {$ENDIF}
  Classes, IniFiles, QImport3, DB, XLSMapParser3, Windows, Graphics
  {$IFNDEF NOGUI}, Grids, Controls, DBGrids, ComCtrls{$ENDIF};

const
  //---------------------
  //  Don't localize it !
  //---------------------
  QI_PALETTE_PAGE = 'EMS Advanced Import 3';
  QI_ABOUT = '(About EMS AdvancedImport 3)';
{$IFDEF CS}
  QI_REG_URL = 'http://www.componentsource.com';
{$ELSE}
  QI_REG_URL = 'http://www.sqlmanager.net/products/tools/advancedimport/buy';
{$ENDIF}

  QI_WIZARD_HELP = 'AImportWizard.hlp';

  QI_FULL_PRODUCT_NAME = 'Advanced Data Import for Delphi(R) and C++ Builder(R) (%s)';
  QI_COPYRIGHT = '(C) 1999-2007  EMS Database Management Solutions, Ltd.  All rights reserved.';
  QI_VERSION = '3.00';

  QIW_FIRST_STEP = 'FIRST_STEP';
    QIW_FILE_NAME = 'FileName';
    QIW_IMPORT_TYPE = 'ImportType';
    QIW_GO_TO_LAST_PAGE = 'GoToLastPage';
    QIW_AUTO_SAVE_TEMPLATE = 'AutoSaveTemplate';
  QIW_XLSX_MAP = 'XLSX_MAP';
  QIW_XLSX_OPTIONS = 'XLSX_OPTIONS';
    QIW_XLSX_SKIP_LINES = 'SkipLines';
    QIW_XLSX_SHEET_NAME = 'SheetName';
    QIW_XLSX_NEED_FILLMERGE = 'NeedFillMerge';
    QIW_XLSX_LOAD_HIDDENSHEET = 'LoadHiddenSheet';
  QIW_DOCX_MAP = 'DOCX_MAP';
    QIW_DOCX_SKIP_LINES = 'SkipLines';
    QIW_DOCX_TABLE_NUMBER = 'TableNumber';
  QIW_DOCX_OPTIONS = 'DOCX_OPTIONS';
  QIW_ODS_MAP = 'ODS_MAP';
  QIW_ODS_OPTIONS = 'ODS_OPTIONS';
    QIW_ODS_SKIP_LINES = 'SkipLines';
    QIW_ODS_SHEET_NAME = 'SheetName';
  QIW_ODT_MAP = 'ODT_MAP';
  QIW_ODT_OPTIONS = 'ODT_OPTIONS';
    QIW_ODT_SKIP_LINES = 'SkipLines';
    QIW_ODT_SHEET_NAME = 'SheetName';
    QIW_ODT_USE_HEADER = 'UseHeader';
  QIW_XLS_MAP = 'XLS_MAP';
  QIW_XLS_OPTIONS = 'XLS_OPTIONS';
    QIW_XLS_SKIP_COLS = 'SkipCols';
    QIW_XLS_SKIP_ROWS = 'SkipRows';
  QIW_TXT_MAP = 'TXT_MAP';
  QIW_TXT_OPTIONS = 'ASCII_OPTIONS';
    QIW_TXT_SKIP_LINES = 'SkipLines';
  QIW_CSV_MAP = 'CSV_MAP';
  QIW_CSV_OPTIONS = 'CSV_OPTIONS';
    QIW_CSV_DELIMITER = 'Delimiter';
    QIW_CSV_SKIP_LINES = 'SkipLines';
    QIW_CSV_QUOTE = 'Quote';
  QIW_DBF_MAP = 'DBF_MAP';
  QIW_DBF_OPTIONS = 'DBF_OPTIONS';
    QIW_DBF_SKIP_DELETED = 'SkipDeleted';
  QIW_HTML_MAP = 'HTML_MAP';
  QIW_HTML_OPTIONS = 'HTML_OPTIONS';
    QIW_HTML_SKIP_LINES = 'SkipLines';
  QIW_XML_MAP = 'XML_MAP';
  QIW_XML_OPTIONS = 'XML_OPTIONS';
    QIW_XML_WRITE_ON_FLY = 'WriteOnFly';
  QIW_MDB_MAP = 'ACCESS_MAP';
  QIW_MDB_OPTIONS = 'ACCESS_OPTIONS';
    QIW_MDB_PASSWORD = 'Password';
    QIW_MDB_SOURCETYPE = 'SourceType';
    QIW_MDB_TABLENAME = 'TableName';
  QIW_MDB_QUERY = 'ACCESS_SQL';
    QIW_MDB_SQL_LINE = 'Line_';
  QIW_BASE_FORMATS = 'BASE_FORMATS';
    QIW_BF_DECIMAL_SEPARATOR = 'DecimalSeparator';
    QIW_BF_THOUSAND_SEPARATOR = 'ThousandSeparator';
    QIW_BF_SHORT_DATE_FORMAT = 'ShortDateFormat';
    QIW_BF_LONG_DATE_FORMAT = 'LongDateFormat';
    QIW_BF_DATE_SEPARATOR = 'DateSeparator';
    QIW_BF_SHORT_TIME_FORMAT = 'ShortTimeFormat';
    QIW_BF_LONG_TIME_FORMAT = 'LongTimeFormat';
    QIW_BF_TIME_SEPARATOR = 'TimeSeparator';
    //QIW_BF_LEFT_QUOTATION = 'LeftQuotation';
    //QIW_BF_RIGHT_QUOTATION = 'RightQuotation';
    //QIW_BF_QUOTATION_ACTION = 'QuotationAction';
  QIW_BOOLEAN_TRUE = 'BOOLEAN_TRUE';
  QIW_BOOLEAN_FALSE = 'BOOLEAN_FALSE';
  QIW_NULL_VALUES = 'NULL_VALUES';
  QIW_DATA_FORMATS = 'DATA_FORMATS_';
    QIW_DF_GENERATOR_VALUE = 'GeneratorValue';
    QIW_DF_GENERATOR_STEP = 'GeneratorStep';
    QIW_DF_CONSTANT_VALUE = 'ConstantValue';
    QIW_DF_NULL_VALUE = 'NullValue';
    QIW_DF_DEFAULT_VALUE = 'DefaultValue';
    QIW_DF_LEFT_QUOTE = 'LeftQuote';
    QIW_DF_RIGHT_QUOTE = 'RightQuote';
    QIW_DF_QUOTE_ACTION = 'QuoteAction';
    QIW_DF_CHAR_CASE = 'CharCase';
    QIW_DF_CHAR_SET = 'CharSet';
  QIW_REPLACEMENTS = 'REPLACEMENTS_';
    QIW_RP_TEXT_TO_FIND = 'TextToFind';
    QIW_RP_REPLACE_WITH = 'ReplaceWith';
    QIW_RP_IGNORE_CASE = 'IgnoreCase';
  QIW_ITEM = 'ITEM_';
  QIW_LAST_STEP = 'LAST_STEP';
    QIW_COMMIT_AFTER_DONE = 'CommitAfterDone';
    QIW_COMMIT_REC_COUNT = 'CommitRecCount';
    QIW_IMPORT_REC_COUNT = 'ImportRecCount';
    QIW_CLOSE_AFTER_IMPORT = 'CloseAfterImport';
    QIW_ENABLE_ERROR_LOG = 'EnableErrorLog';
    QIW_ERROR_LOG_FILE_NAME = 'ErrorLogFileName';
    QIW_REWRITE_ERROR_LOG_FILE = 'RewriteErrorLogFile';
    QIW_SHOW_ERROR_LOG = 'ShowErrorLog';
    QIW_ENABLE_SQL_LOG = 'EnableSQLLog';
    QIW_SQL_LOG_FILE_NAME = 'SQLLogFileName';
    QIW_REWRITE_SQL_LOG_FILE = 'RewriteSQLLogFile';
    QIW_IMPORT_MODE = 'ImportMode';
    QIW_ADD_TYPE = 'AddType';
    QIW_KEY_COLUMNS = 'KeyColumns';


  QI_BASE = 'BASE';
    QI_FILE_NAME = 'FileName';
    QI_IMPORT_TYPE = 'ImportType';
    QI_IMPORT_DESTINATION = 'ImportDestination';
    QI_IMPORT_MODE = 'ImportMode';
    QI_MAP = 'MAP';
    QI_KEY_COLUMNS = 'KeyColumns';
    QI_GRID_CAPTION_ROW = 'GridCaptionRow';
    QI_GRID_START_ROW = 'GridStartRow';
    QI_COMMIT_AFTER_DONE = 'CommitAfterDone';
    QI_COMMIT_REC_COUNT = 'CommitRecCount';
    QI_IMPORT_REC_COUNT = 'ImportRecCount';
    QI_ENABLE_ERROR_LOG = 'EnableErrorLog';
    QI_ERROR_LOG_FILE_NAME = 'ErrorLogFileName';
    QI_REWRITE_ERROR_LOG_FILE = 'RewriteErrorLogFile';
    QI_SHOW_ERROR_LOG = 'ShowErrorLog';
    {QI_ENABLE_SQL_LOG = 'EnableSQLLog';
    QI_SQL_LOG_FILE_NAME = 'SQLLogFileName';
    QI_SQL_LOG_FILE_REWRITE = 'SQLLogFileRewrite';}
  BASE_FORMATS = 'BASE_FORMATS';
    BF_DECIMAL_SEPARATOR = 'DecimalSeparator';
    BF_THOUSAND_SEPARATOR = 'ThousandSeparator';
    BF_SHORT_DATE_FORMAT = 'ShortDateFormat';
    BF_LONG_DATE_FORMAT = 'LongDateFormat';
    BF_SHORT_TIME_FORMAT = 'ShortTimeFormat';
    BF_LONG_TIME_FORMAT = 'LongTimeFormat';
    //BF_LEFT_QUOTATION = 'LeftQuotation';
    //BF_RIGHT_QUOTATION = 'RightQuotation';
    BF_QUOTATION_ACTION = 'QuotationAction';
  BOOLEAN_TRUE = 'BOOLEAN_TRUE';
  BOOLEAN_FALSE = 'BOOLEAN_FALSE';
  NULL_VALUES = 'NULL_VALUES';
  DATA_FORMATS = 'DATA_FORMATS_';
    DF_GENERATOR_VALUE = 'GeneratorValue';
    DF_GENERATOR_STEP = 'GeneratorStep';
    DF_CONSTANT_VALUE = 'ConstantValue';
    DF_NULL_VALUE = 'NullValue';
    DF_DEFAULT_VALUE = 'DefaultValue';
    DF_LEFT_QUOTE = 'LeftQuote';
    DF_RIGHT_QUOTE = 'RightQuote';
    DF_QUOTE_ACTION = 'QuoteAction';
    DF_CHAR_CASE = 'CharCase';
    DF_CHAR_SET = 'CharSet';

  XLS_OPTIONS = 'XLS_OPTIONS';
    XLS_SKIP_COLS = 'SkipCols';
    XLS_SKIP_ROWS = 'SkipRows';
  ASCII_OPTIONS = 'ASCII_OPTIONS';
    ASCII_SKIP_LINES = 'SkipLines';
    ASCII_COMMA = 'Comma';
    ASCII_Quote = 'Quote';
  DBF_OPTIONS = 'DBF_OPTIONS';
    DBF_SKIP_LINES = 'SkipLines';
  HTML_OPTIONS = 'HTML_OPTIONS';
    HTML_SKIP_LINES = 'SkipLines'; {!HTML}
  XML_OPTIONS = 'XML_OPTIONS';
    XML_SKIP_LINES = 'SkipLines';
    XML_WRITE_ON_FLY = 'WriteOnFly';
  DATA_SET_OPTIONS = 'DATA_SET_OPTIONS';
    DATA_SET_SKIP_LINES = 'SkipLines';
  ODS_OPTIONS = 'ODS_OPTIONS';
    ODS_SKIP_LINES = 'SkipRows';
    ODS_SHEET_NAME = 'SheetName';
    ODS_NOT_EXPAND_MERGED_VALUE = 'NotExpandMergedValue';
  ODT_OPTIONS = 'ODT_OPTIONS';
    ODT_SKIP_LINES = 'SkipRows';
    ODT_SHEET_NAME = 'SheetName';
    ODT_USE_HEADER = 'UseHeader';
    ODT_COMPLEX_TABLE = 'ComplexTable';
  XLSX_OPTIONS = 'XLSX_OPTIONS';
    XLSX_SKIP_LINES = 'SkipRows';
    XLSX_SHEET_NAME = 'SheetName';
    XLSX_LOAD_HIDDEN_SHEET = 'LoadHiddenSheet';
    XLSX_NEED_FILL_MERGE = 'NeedFillMerge';
  DOCX_OPTIONS = 'DOCX_OPTIONS';
    DOCX_SKIP_LINES = 'SkipRows';
    DOCX_TABLE_NUMBER = 'TableNumber';
    DOCX_NEED_FILLMERGE = 'NeedFillMerge';

  XLS_EXT = '.xls';
  XLSX_EXT = '.xlsx';
  DOCX_EXT = '.docx';
  ODS_EXT = '.ods';
  ODT_EXT = '.odt';
  DBF_EXT = '.dbf';
  DB_EXT  = '.db';
  HTM_EXT = '.htm';
  HTML_EXT = '.html';
  XML_EXT = '.xml';
  TXT_EXT = '.txt';
  CSV_EXT = '.csv';
  MDB_EXT = '.mdb';

const
  PathDelim  = {$IFDEF WIN} '\'; {$ELSE} '/'; {$ENDIF}

  SShortMonthNameJan = 'Jan';
  SShortMonthNameFeb = 'Feb';
  SShortMonthNameMar = 'Mar';
  SShortMonthNameApr = 'Apr';
  SShortMonthNameMay = 'May';
  SShortMonthNameJun = 'Jun';
  SShortMonthNameJul = 'Jul';
  SShortMonthNameAug = 'Aug';
  SShortMonthNameSep = 'Sep';
  SShortMonthNameOct = 'Oct';
  SShortMonthNameNov = 'Nov';
  SShortMonthNameDec = 'Dec';

  SLongMonthNameJan = 'January';
  SLongMonthNameFeb = 'February';
  SLongMonthNameMar = 'March';
  SLongMonthNameApr = 'April';
  SLongMonthNameMay = 'May';
  SLongMonthNameJun = 'June';
  SLongMonthNameJul = 'July';
  SLongMonthNameAug = 'August';
  SLongMonthNameSep = 'September';
  SLongMonthNameOct = 'October';
  SLongMonthNameNov = 'November';
  SLongMonthNameDec = 'December';

  SShortDayNameSun = 'Sun';
  SShortDayNameMon = 'Mon';
  SShortDayNameTue = 'Tue';
  SShortDayNameWed = 'Wed';
  SShortDayNameThu = 'Thu';
  SShortDayNameFri = 'Fri';
  SShortDayNameSat = 'Sat';

  SLongDayNameSun = 'Sunday';
  SLongDayNameMon = 'Monday';
  SLongDayNameTue = 'Tuesday';
  SLongDayNameWed = 'Wednesday';
  SLongDayNameThu = 'Thursday';
  SLongDayNameFri = 'Friday';
  SLongDayNameSat = 'Saturday';

var
  DefShortMonthNames: array[1..12] of string = (SShortMonthNameJan,
    SShortMonthNameFeb, SShortMonthNameMar, SShortMonthNameApr,
    SShortMonthNameMay, SShortMonthNameJun, SShortMonthNameJul,
    SShortMonthNameAug, SShortMonthNameSep, SShortMonthNameOct,
    SShortMonthNameNov, SShortMonthNameDec);

  DefLongMonthNames: array[1..12] of string = (SLongMonthNameJan,
    SLongMonthNameFeb, SLongMonthNameMar, SLongMonthNameApr,
    SLongMonthNameMay, SLongMonthNameJun, SLongMonthNameJul,
    SLongMonthNameAug, SLongMonthNameSep, SLongMonthNameOct,
    SLongMonthNameNov, SLongMonthNameDec);

function StringToChar(const S: string; const Default: char): char;
function PadString(const S: string; Chr: char; Len: integer): string;
function Str2Char(const Str: string; Default: char): char;
function Char2Str(Chr: char): string;

{$IFDEF QI_UNICODE}
function QIAddQuote(const S, LeftQuote, RightQuote: WideString): WideString;
function QIRemoveQuote(const S, LeftQuote, RightQuote: WideString): WideString;
function QIUpperFirst(const S: WideString): WideString;
function QIUpperFirstWord(const S: WideString): WideString;
{$ELSE}
function QIAddQuote(const S, LeftQuote, RightQuote: string): string;
function QIRemoveQuote(const S, LeftQuote, RightQuote: string): string;
function QIUpperFirst(const S: string): string;
function QIUpperFirstWord(const S: string): string;
{$ENDIF}

{$IFDEF QI_UNICODE}
procedure CSVStringToStrings(
  const Str: WideString; Quote, Separator: Char; AStrings: TWideStrings);
{$ELSE}
procedure CSVStringToStrings(
  const Str: string; Quote, Separator: Char; AStrings: TStrings);
{$ENDIF}

procedure ReplaceTabs(var Str: {$IFDEF QI_UNICODE}WideString{$ELSE}string{$ENDIF});

// StringGrid routines
{$IFNDEF NOGUI}
procedure GridDrawCell(Grid: {$IFDEF QI_UNICODE}TEmsWideStringGrid{$ELSE}TStringGrid{$ENDIF};
  const SheetName: string; SheetNumber, ACol, ARow: integer; Rect: TRect;
  State: TGridDrawState; DefinedRanges: TMapRow; SkipCols, SkipRows: integer;
  IsEditing: boolean; Selection: TMapRow);
procedure GridMouseDown(Grid: {$IFDEF QI_UNICODE}TEmsWideStringGrid{$ELSE}TStringGrid{$ENDIF};
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer;  FirstCol, LastCol, FirstRow, LastRow,
  SkipRows, SkipCols: integer; var CurrSel: string);
procedure GridSelectCell(Grid: {$IFDEF QI_UNICODE}TEmsWideStringGrid{$ELSE}TStringGrid{$ENDIF};
  ACol, ARow: integer; Shift: TShiftState; var CurrSel: string);
procedure GridMoveCurrCell(Grid: {$IFDEF QI_UNICODE}TEmsWideStringGrid{$ELSE}TStringGrid{$ENDIF};
  ACol, ARow: integer);
procedure GridSelCell(Grid: {$IFDEF QI_UNICODE}TEmsWideStringGrid{$ELSE}TStringGrid{$ENDIF};
  RowNo, ColNo: integer; NeedClear: boolean; var CurrSel: string);
procedure GridSelRow(Grid: {$IFDEF QI_UNICODE}TEmsWideStringGrid{$ELSE}TStringGrid{$ENDIF};
  FirstCol, LastCol, RowNo, StartCol, SkipRows, SkipCols: integer;
  NeedClear: boolean; var CurrSel: string);
procedure GridSelCol(Grid: {$IFDEF QI_UNICODE}TEmsWideStringGrid{$ELSE}TStringGrid{$ENDIF};
  FirstRow, LastRow, ColNo, StartRow, SkipRows, SkipCols: integer;
  NeedClear: boolean; var CurrSel: string);
procedure GridFillFixedCells(Grid: {$IFDEF QI_UNICODE}TEmsWideStringGrid{$ELSE}TStringGrid{$ENDIF});
//procedure GridClearDataCell(Grid: TStringGrid);
{$ENDIF}

// ImportDestination routines
procedure QImportCheckDestination(IsCSV: boolean;
  ImportDestination: TQImportDestination; DataSet: TDataSet
  {$IFNDEF NOGUI}; DBGrid: TDBGrid;
 ListView: TListView;
  StringGrid: TStringGrid{$ENDIF});
function QImportIsDestinationActive(IsCSV: boolean;
  ImportDestination: TQImportDestination; DataSet: TDataSet
  {$IFNDEF NOGUI}; DBGrid: TDBGrid;
  ListView: TListView;
  StringGrid: TStringGrid{$ENDIF}): boolean;
procedure QImportIsDestinationOpen(IsCSV: boolean;
  ImportDestination: TQImportDestination; DataSet: TDataSet
  {$IFNDEF NOGUI}; DBGrid: TDBGrid;
 ListView: TListView;
  StringGrid: TStringGrid{$ENDIF});
procedure QImportIsDestinationClose(IsCSV: boolean;
  ImportDestination: TQImportDestination; DataSet: TDataSet
  {$IFNDEF NOGUI}; DBGrid: TDBGrid;
 ListView: TListView;
  StringGrid: TStringGrid{$ENDIF});
function QImportDestinationColCount(IsCSV: boolean;
  ImportDestination: TQImportDestination; DataSet: TDataSet
  {$IFNDEF NOGUI}; DBGrid: TDBGrid;
 ListView: TListView;
  StringGrid: TStringGrid{$ENDIF}): integer;
function QImportDestinationColName(IsCSV: boolean;
  ImportDestination: TQImportDestination; DataSet: TDataSet;
  {$IFNDEF NOGUI} DBGrid: TDBGrid;
 ListView: TListView;
  StringGrid: TStringGrid;
 GridCaptionRow,{$ENDIF} Index: integer): string;
function QImportDestinationAssigned(IsCSV: boolean;
  ImportDestination: TQImportDestination; DataSet: TDataSet
  {$IFNDEF NOGUI}; DBGrid: TDBGrid;
 ListView: TListView;
  StringGrid: TStringGrid{$ENDIF}): boolean;
function QImportDestinationFindColumn(IsCSV: boolean;
  ImportDestination: TQImportDestination; DataSet: TDataSet;
  {$IFNDEF NOGUI}DBGrid: TDBGrid;
 ListView: TListView;
  StringGrid: TStringGrid; GridCaptionRow: integer;
{$ENDIF}
  const ColName: string): integer;

function GetListSeparator: Char;
procedure ClearIniFile(IniFile: TIniFile);
function IncludePathDelimiter(const S: string): string;
function GetNumericString(const Str: string): string;
function TryStrToDateTime(const Str: string; var DateTime: TDateTime): Boolean;

{$IFNDEF VCL5}
type
  TReplaceFlags = set of (rfReplaceAll, rfIgnoreCase);

function StringReplace(const S, OldPattern, NewPattern: string;
  Flags: TReplaceFlags): string;
{$ENDIF}

function DirExists(const Directory: string): Boolean;

function FormatStrToDateTime(ADateTimeStr, AFormatStr: string): TDateTime;

function MinimizeName(const Filename: string; Canvas: TCanvas;
  MaxLen: Integer): string;

function GetColIdFromColIndex(ColIndex: string): Integer;

implementation

uses
  SysUtils, XLSUtils3, QImport3StrIDs, EmsWideStrUtils;

function GetColIdFromColIndex(ColIndex: string): Integer;
begin
  Result := 0;
  if ColIndex <> '' then
    case Length(ColIndex) of
      1: Result := Ord(ColIndex[1]) - 64;
      2: Result := (Ord(ColIndex[1]) - 64)*26 + (Ord(ColIndex[2]) - 64);
      3: Result := (Ord(ColIndex[1]) - 64)*676 + ((Ord(ColIndex[2]) - 64)*26 + Ord(ColIndex[3]) - 64);
    end;
end;

procedure GetMonthDayNames;
var
  I: Integer;
  DefaultLCID: LCID;

  function LocalGetLocaleStr(LocaleType, Index: Integer;
    const DefValues: array of string): string;
  begin
    Result := GetLocaleStr(DefaultLCID, LocaleType, '');
    if Result = '' then
      Result := DefValues[Index];
  end;

begin
  DefaultLCID := GetThreadLocale;
  for I := 1 to 12 do
  begin
    ShortMonthNames[I] := LocalGetLocaleStr(LOCALE_SABBREVMONTHNAME1 + I - 1,
      I - Low(DefShortMonthNames), DefShortMonthNames);
    LongMonthNames[I] := LocalGetLocaleStr(LOCALE_SMONTHNAME1 + I - 1,
      I - Low(DefLongMonthNames), DefLongMonthNames);
  end;
end;

function StringToChar(const S: string; const Default: char): char;
var
  i: integer;
  tmp: string;
begin
  Result := Default;
  if Length(S) = 1 then Result := S[1]
  else if (Length(S) > 1) and (S[1] = '#') then
  begin

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -