FastScript脚本使用说明白皮书.doc_第1页
FastScript脚本使用说明白皮书.doc_第2页
FastScript脚本使用说明白皮书.doc_第3页
FastScript脚本使用说明白皮书.doc_第4页
FastScript脚本使用说明白皮书.doc_第5页
已阅读5页,还剩12页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

FastScript脚本使用白皮书(Ver1.0)作者:袁锋QQ:11442361Email:1. 可以使用的对象如下:1.1. 原始类: Tobject, TPersistent ,TList, TStrings, TStringList, TStream, TFileStream, TMemoryStream, TComponent, TfsXMLItem, TfsXMLDocument.A) Tobject: 方法: constructor Create Free function ClassName: StringB) TPersistent :class(Tobject);方法: procedure Assign(Source: TPersistent)C) TList :class (TObject)方法: function Add(Item: TObject): Integer procedure Clear, CallMethod); procedure Delete(Index: Integer) function IndexOf(Item: TObject) procedure Insert(Index: Integer; Item: TObject) function Remove(Item: TObject): Integer 属性: Count: Integer Itemsi: Integer: TObjectD) TStrings: class(TPersistent) function Add(const S: string): Integer function AddObject(const S: string; AObject: TObject): Integer procedure Clear, CallMethod); procedure Delete(Index: Integer), CallMethod); function IndexOf(const S: string): Integer, CallMethod); function IndexOfName(const Name: string): Integer function IndexOfObject(AObject: TObject): Integer procedure Insert(Index: Integer; const S: string) procedure InsertObject(Index: Integer; const S: string; AObject: TObject) procedure LoadFromFile(const FileName: string) procedure LoadFromStream(Stream: TStream) procedure SaveToFile(const FileName: string) procedure SaveToStream(Stream: TStream) 属性: CommaText:stringCount:Integer Names, Integer, string, CallMethod, True); Objects, Integer, TObject,; Values, String, string,; Stringsi: Integer, string, Text, string, GetProp, SetProp);end;E) TStringList: class(TStrings)方法: function Find(s: String; var Index: Integer): Boolean procedure Sort, CallMethod) 属性: Duplicates: TDuplicates Sorted:BooleanF) TStream:class(TObject) 方法:function Read(Buffer: string; Count: Longint): Longint function Write(Buffer: string; Count: Longint): Longint function Seek(Offset: Longint; Origin: Word): Longint function CopyFrom(Source: TStream; Count: Longint): Longint 属性: Position:Longint Size:LongintG) TFileStream:class(TStream) constructor Create(Filename: String; Mode: Word)H) TMemoryStream:class(TStream) procedure Clear, CallMethod); procedure LoadFromStream(Stream: TStream) procedure LoadFromFile(Filename: String) procedure SaveToStream(Stream: TStream) procedure SaveToFile(Filename: String)I) TComponent:class(TPersistent) 方法:constructor Create(AOwner: TComponent) 属性:Owner:ComponentJ) TfsXMLItem:=class(TObject) 方法: constructor Create procedure AddItem(Item: TfsXMLItem) procedure Clear, CallMethod) procedure InsertItem(Index: Integer; Item: TfsXMLItem) function Add: TfsXMLItem function Find(const Name: String): Integer function FindItem(const Name: String): function Prop(const Name: String): String function Root: TfsXMLItem 属性: Data:Integer Count:Integer Itemsi: Integer: TfsXMLItem Name:String Parent:TfsXMLItem Text:String K) TfsXMLDocument:=class(TObject)方法: constructor Create procedure SaveToStream(Stream: TStream) procedure LoadFromStream(Stream: TStream) procedure SaveToFile(const FileName: String) procedure LoadFromFile(const FileName: String) 属性:Root:fsXMLItem-1.2. 常用类:(如果需要使用此类控件需要加fsFormsRTTI1控件) 控件:TWinControl类(TWinControl: Class(Tcontrol))TEdit,TMemo,Tmaskedit,TCombobox,TCheckBox,TRadioButton,TBitbtn, TListBox,TForm, TTScrollBox TControl类(TControl: Class(TComponent))TSpeedbutton ,Ttoolbar ,Tpanel ,Tbitbtn,TLabel ,TGroupBox ,TImage,TShape,TToolbarTComponent 类 TDataModule -说明:对于TControl有方法:procedure Hide procedure Show procedure SetBounds(ALeft, ATop, AWidth, AHeight: Integer), CallMethod); 事件: OnCanResize OnClick OnDblClick OnMouseDown OnMouseMove OnMouseUp OnResize对于TWinControl除了有上面TControl的方法和事件外,还有:方法: procedure SetFocus 事件:OnEnter OnExit OnKeyDown OnKeyPress OnKeyUp对于TCombobox还有如下事件:OnChange OnDropDown OnCloseUp 除了有Published属性外还有如下属性: DroppedDown:Boolean ItemIndex:Integer对于TEdit,TMemo还有如下方法: procedure CopyToClipboard procedure CutToClipboard procedure PasteFromClipboard 对于TlistBox除了有Published属性外还有如下属性: ItemIndex:Integer SelCount:integer SelectedIndex: Integer: Boolean 对于Form类还有: 方法:procedure Close procedure Hide procedure Show function ShowModal: Integer事件: OnActivate OnClose OnCloseQuery OnCreate OnDestroy OnDeactivate OnHide OnPaint OnShow 除了有Published属性外还有如下属性:Canvas ModalResult -1.3. 数据敏感类:(如果需要使用此类控件需要加fsDBCtrlRTTI1控件) 控件: TWinControl类TDBEdit,TDBComboBox,TDBImage,TDBCheckBox,TDBListBox,TDBMemo,TDBNavigator,TDBRadioGroup,TDBLookupControl,TDBLookupListBox,TDBLookupComboBox,TDBGridTGraphicControl(在fsFormsRTTI1里定义 AddClass(TGraphicControl, TControl)TDBTextTPersistent类:TColumnTitle,TColumn,TDBGridColumns 说明:对于TDBCheckBox除了有Published属性外还有如下属性: Checked:Boolean对于TDBComboBox除了有Published属性外还有如下属性: Text:String DroppedDown:Boolean ItemIndex:Integer除了Twincontrol事件外,还有如下事件: OnChange OnDropDown OnCloseUp对于TDBListBox除了有Published属性外还有如下属性: ItemIndex:Integer SelCount:integer SelectedIndex: Integer: Boolean 对于TDBRadioGroup除了有Published属性外还有如下属性: ItemIndex:Integer Value:String对于TDBLookupListBox除了有Published属性外还有如下属性: KeyValue:Variant SelectedItem:String对于TDBLookupComboBox除了有Published属性外还有如下属性: KeyValue:Variant Text:String对于TDBGridColumns除了有Published属性外还有如下属性: Itemsi:Integer:Tcolumn 方法: function Add: TColumn function Count: Integer procedure RebuildColumns procedure RestoreDefaults1.4. 字段和数据集类:( 如果需要使用此类控件需要加fsDBRTTI1控件)A) TField: class(TComponent)属性: AsBoolean:Boolean AsCurrency:Currency AsDateTime:TDateTime AsFloat:Double AsInteger:Integer AsString:String AsVariant:Variant DataType:TFieldType DisplayName:String DisplayText:String IsNull:Boolean Size:Integer Value:VariantB) TFields:class(TObject)属性:Fieldsi: Integer:TFieldC) TStringField: class(TField)D) TNumericField: class(TField)E) TIntegerField: class(TNumericField)F) TSmallIntField: class(TIntegerField)G) TWordField: class(TIntegerField)H) TAutoIncField: class(TIntegerField)I) TFloatField: class(TNumericField)J) TCurrencyField: class(TFloatField)K) TBooleanField: class(TField)L) TDateTimeField: class(TField)M) TDateField: class(TDateTimeField)N) TTimeField: class(TDateTimeField)O) TBinaryField: class(TField)P) TBytesField : class(TBinaryField)Q) TVarBytesField: class(TBinaryField)R) TBCDField: class(TNumericField)S) TBlobField: class(TField) 方法: procedure LoadFromFile(const FileName: String) procedure LoadFromStream(Stream: TStream) procedure SaveToFile(const FileName: String) procedure SaveToStream(Stream: TStream)T) TMemoField:class(TBlobField)U) TGraphicField: (TBlobField)V) TFieldDef: class(TPersistent)W) TFieldDefs: class(TObject) function AddFieldDef: TFieldDef, CallMethod); function Find(const Name: string): TFieldDef, CallMethod); procedure Add(const Name: string; DataType: TFieldType; Size: Word; Required: Boolean) procedure Clear procedure Update属性: Itemsi:Integer :TFieldDefX) TDataSource: class(TComponent)Y) TDataSet: TComponent 方法: procedure Open procedure Close procedure First procedure Last procedure Next procedure Prior procedure Cancel procedure Delete procedure Post procedure Append procedure Insert procedure Editfunction FieldByName(const FieldName: string): TField procedure GetFieldNames(List: TStrings) function FindFirst: Boolean function FindLast: Boolean function FindNext: Boolean function FindPrior: Boolean, CallMethod); procedure FreeBookmark(Bookmark: TBookmark) function GetBookmark: TBookmark procedure GotoBookmark(Bookmark: TBookmark), CallMethod); function Locate(const KeyFields: string; const KeyValues: Variant; + Options: TLocateOptions): Boolean function IsEmpty: Boolean 属性: Bof:Boolean Eof:Boolean fieldCount:Integer RecordCount:Integer FieldDefs:TFieldDefs Fields:TFields Filter:string Filtered:Boolean FilterOptions:TFilterOptions Active:Boolean事件:BeforeOpen AfterOpen; BeforeClose AfterClose BeforeInsert AfterInsert BeforeEdit AfterEdit BeforePost AfterPost BeforeCancel AfterCancel BeforeDelete AfterDelete BeforeScroll AfterScroll OnCalcFields OnFilterRecord OnNewRecordZ) TParam:class(TPersistent)方法: procedure Clear 属性: AsBoolean:Boolean AsCurrency:Currency AsDateTime:TDateTime AsFloat:Double AsInteger:Integer AsDate:TDate AsTime:TTime AsString:String Bound:Boolean IsNull:Boolean Text:StringAA) TParams:class(TPersistent) 方法:function ParamByName(const Value: string): TParam事件:function FindParam(const Value: string): TParam属性:Itemi: Integer:TParam1.5. ADO类:( 如果需要使用此类控件需要加fsADORTTI1控件)TDataBase,TDataSource,TDataSet,TAdoconnection,TAdoDataSet,TAdoquery,TAdoTable,TAdoStoredProc,TClientDataSetA) TADOConnection:TComponentB) TParameter:TPersistent 属性:Itemsi:Integer:TParameterC) TCustomADODataSet: class(TDataSet)D) TADODataSet:class(TCustomADODataSet)E) TCustomClientDataSet:class(TDataSet) F) TADOTable:class(TCustomADODataSet);G) TADOQuery:class(TCustomADODataSet) do 方法:procedure ExecSQLH) TADOStoredProc:TCustomADODataSet 方法:procedure ExecProcI) TClientDataSet: class(TCustomClientDataSet 方法: procedure Excute1.6. BDE类:(如果需要使用此类控件需要加fsBDERTTI1控件) TTable,Tquery,TDataBase,TStoreProc,TSession对于TDataBase可以使用如下方法: procedure Open 对于TTable可以使用如下方法: procedure CreateTable procedure DeleteTable; procedure EmptyTable; function FindKey(const KeyValues: array): Boolean; procedure FindNearest(const KeyValues: array); procedure RenameTable(const NewTableName: string); 对于TQuery可以使用如下方法: procedure ExecSQL function ParamByName(const Value: string): TParam procedure Prepare ParamCount 对于TStoredProc可以使用如下方法: procedure ExecProc function ParamByName(const Value: string): TParam procedure Prepare ParamCount1.7. 对话类:(如果需要使用此类控件需要加fsDialogRTTI1控件)TOpenDialog、TSaveDialog、TColorDialog 、TFontDialog、TPrintDialog、TPrinterSetupDialog function InputBox(ACaption, APrompt, ADefault: string): string function InputQuery(ACaption, APrompt: string; var Value: string): Boolean1.8. 图像类:控件:TFont,TPen,TBrush,TCanvas,TGraphic,TMetafile,Timage,TMetafileCanvas,TBitmap对于TCanvas: TPersistent,除了TPersistent的方法外还有如下方法:procedure Draw(X, Y: Integer; Graphic: TGraphic) procedure Ellipse(X1, Y1, X2, Y2: Integer) procedure LineTo(X, Y: Integer) procedure MoveTo(X, Y: Integer) procedure Rectangle(X1, Y1, X2, Y2: Integer) procedure RoundRect(X1, Y1, X2, Y2, X3, Y3: Integer) procedure StretchDraw(X1, Y1, X2, Y2: Integer; Graphic: TGraphic) function TextHeight(const Text: string):Integer procedure TextOut(X, Y: Integer; const Text: string) function TextWidth(const Text: string):Integer Pixels(X, Y: Integer;):TColor对于TGraphic= class(TPersistent)除了TPersistent的方法外,还有如下方法: procedure LoadFromFile(const Filename: string), CallMethod); procedure SaveToFile(const Filename: string), CallMethod);属性:Height:Integer Width:Integer对于TBitmap: TGraphic 除了TPersistent的属性外,还有如下属性: Canvas: TCanvas2. 常用函数:(系统默认可以使用下列函数)转换类: IntToStr(i: Integer): StringFloatToStr(e: Extended): StringDateToStr(e: Extended): StringTimeToStr(e: Extended): StringDateTimeToStr(e: Extended): StringVarToStr(v: variant): StringStrToInt(s: String): IntegerStrToFloat(s : String): FloatStrToDate(s: String): TDateStrToTime(s: String): TTimeStrToDateTime(s:String): TDateTime格式化类: Format(Fmt: String; Args: array): String FormatFloat(Fmt: String; Value: Extended): String FormatDateTime(Fmt: String; DateTime: TDateTime): String FormatMaskText(EditMask: String; Value: String): String时间类: function EncodeDate(Year, Month, Day: Word): TDateTime procedure DecodeDate(Date: TDateTime; var Year, Month, Day: Word) function EncodeTime(Hour, Min, Sec, MSec: Word): TDateTime procedure DecodeTime(Time: TDateTime; var Hour, Min, Sec, MSec: Word) function Date: TDateTimefunction Time: TDateTimefunction Now: TDateTime function DayOfWeek(aDate: DateTime): Integer function IsLeapYear(Year: Word): Booleanfunction DaysInMonth(nYear, nMonth: Integer): Integer字符串类:function Length(s: String): Integer function Copy(s: String; from, count: Integer): String function Pos(substr, s: String): Integer procedure Delete(var s: String; from, count: Integer): String procedure Insert(s: String; var s2: String; pos: Integer): String function Uppercase(s: String): String function Lowercase(s: String): String function Trim(s: String): String function NameCase(s: String): String function CompareText(s, s1: String): Integer function Chr(i: Integer): Char function Ord(ch: Char): Integerprocedure SetLength(var S: String; L: Integer)数学类:function Round(e: Extended): Integer function Trunc(e: Extended): Integer function Int(e: Extended): Integer function Frac(X: Extended): Extended function Sqrt(e: Extended): Extended function Abs(e: Extended): Extended function Sin(e: Extended): Extended function Cos(e: Extended): Extended function ArcTan(X: Extended): Extended function Tan(X: Extended): Extended function Exp(X: Extended): Extended function Ln(X: Extended): Extendedfunction Pi: Extended其他:procedure Inc(var i: Integer; incr: Integer = 1) procedure Dec(var i: Integer; decr: Integer = 1) procedure RaiseException(Param: String) procedure ShowMessage(Msg: Variant) procedure Randomize function Random: Extended function ValidInt(cInt: String): Boolean function ValidFloat(cFlt: String): Booleanfunction ValidDate(cDate: String): Boolean说明:由于FastScript解释执行脚本,所以很多对象或者对象的属性都没有包括,也就是在Delphi中有的对象或属性、方法等在脚本里面可能不能用,以上面所述为准。但是对于大多数情况下,FastScript能满足,且能较方便地进行扩展。1在FastScript中,任何类都能用属于Published的属性,如果又加了属性,则也可以用。2子类继承父类的所有方法和属性。也就是子类可以使用父类的所有方法和属性。如果有加了方法和事件,也一样可以用编者:袁锋日期:2004-06-05附:A关于如何使用第三方控件,增加方法、属性、事件)举例如下: 如:有一控件为edtbutton:TedtButton,我们需要在动态脚本中使用该控件。我们采用如下方法:我们可以把该控件申明在fs_iformsrtti单元里面(当然也可以申明在其他的单元如fs_idbrtti里面,但是遵守一个原则是尽量使得功能相似的控件放在同一个单元里面,这样只需要把该单元所对应的控件拖动到form上即可,提高系统运行效率)如:fs_iformsrtti单元对应控件板上的fsiformsrtti。以此类推 AddClass(TedtButton, TControl); 对于增加方法:请看如下例子:如需要增加Tedit类的CopyToClipboard、CutToClipboard、PasteFromClipboard方法。则代码如下所示:with AddClass(TEdit, TWinControl) do begin AddMethod(procedure CopyToClipboard, CallMethod); AddMethod(procedure CutToClipboard, CallMethod); AddMethod(procedure PasteFromClipboard, CallMethod); end;在 CallMethod中需要增加相应方法的实现。function TFunctions.CallMethod(Instance: TObject; ClassType: TClass; const MethodName: String; var Params: Variant): Variant;var Form: TCustomForm;begin Result := 0; if ClassType = TControl then begin if MethodName = HIDE then TControl(Instance).Hide else if MethodName = SHOW then TControl(Instance).Show else if MethodName = SETBOUNDS then TControl(Instance).SetBounds(Params0, Params1, Params2, Params3) end else if ClassType = TWinControl then begin if MethodName = SETFOCUS then TWinControl(Instance).SetFocus end else if ClassType = TEdit then /需要增加的实现(只是对于Tedit); begin if MethodName = uppercase(CopyToClipboard) then Tedit(Instance).CopyToClipboard ; if MethodName = uppercase(CutToClipboard) then Tedit(Instance).CutToClipboard ; if MethodName = uppercase(PasteFromClipboard) then Tedit(Instance).PasteFromClipboard ; end End对于增加属性:请看如下例子:如需要增加TdataSet的RecordCount属性,则代码如下所示: with AddClass(TDataSet, TComponent) do begin AddMethod(procedure Open, CallMethod); AddProperty(FieldCount, Integer, GetProp, nil); AddProperty(RecordCount, Integer,GetProp,nil); 因为R

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论