Skriptovací jazyk - příklady
Z K.A.P.
Skočit na navigaciSkočit na vyhledáváníPříklad skriptu v syntaxi Pascal:
var i: integer; s: String; begin s:=IniReadString('ScriptTest', 1, True, _AktualniSklad_, '5'); ShowMessage(Settings.Values['INI.FirmaJmeno']+chr(13)+Settings.Values['USER.JmenoUziv']+chr(13)+_KonfigDir_); LogWrite('Direktivy:'+_Direktivy_); if s <> '' then i := StrToInt(s)+1 else i := -10; if not IniWriteInteger('ScriptTest', 1, True, _AktualniSklad_, i) then ShowMessage('V IniWriteInteger se vyskytla chyba'); end.
var s: String; d1, d2: TDateTime; DD, MM, YY : word; begin DecodeDate(Date, YY, MM, DD); if MM=1 then begin // Zjisteni predchoziho mesice MM := 12; YY := YY - 1; end else MM := MM - 1; D1 := EncodeDate(YY, MM, 1); D2 := EncodeDate(YY, MM, DaysInMonth(YY, MM)); S := GSRunReport(6, 1, 'KFG_Datum1='+StrDate(D1)+chr(13)+ 'KFG_Datum='+StrDate(D2)+chr(13)+ 'INI_Jmeno=Pokusný sklad'); //S := GSRunReportV(6, 1, ['KFG_Datum1', 'KFG_Datum', 'INI_Jmeno'],[StrDate(D1), StrDate(D2), 'Pokusný sklad']); ShowMessage(s); end.
var s: String; begin //From, SendTo, FileAttach, Subject, SMTPServer, SMTPSenderName, SMTPPassword, BodyString, ErrMessage if SendMailBySMTP('odesilatel@posta.cz', 'prijemce@mail.com', 'UZIV\SESTAVA1.SLK'#9'UZIV\SESTAVA2.SES'#13'UZIV\vystup.pdf', 'Test scriptu', 'smtp.posta.cz', 'SMTPjmeno', 'SMTPheslo', 'Testovaci email.'#13'Konec', s) then ShowMessage('OK '+ s) else ShowMessage('CHYBA '+ s); end.
var MOSCommunicator: TMOSCommunicator; begin MOSCommunicator := TMOSCommunicator.Create('MOS.bin', '', '', '', 0); if MOSCommunicator.SendFile('C:\DIR\DATA1.xml', 'DATA1.XML', '', '', '', True) then LogWrite('Prenos OK') else LogWrite(MOSCommunicator.ErrMessage); MOSCommunicator.Free; end.
var MOSCommunicator: TMOSCommunicator; Info: String; Velikost: Extended; Cas: TDateTime; begin MOSCommunicator := TMOSCommunicator.Create('', '192.168.17.1', 'MOSuser', 'MOSpswd', 1); try if MOSCommunicator.Connect then begin // pokud se připojím, pak se vše realizuje // v rámci jednoho připojení // ShowMessage('Pripojeno'); if MOSCommunicator.Connected then begin // test navic if MOSCommunicator.SendSMS('111222333','Pokus o poslani SMS') then ShowMessage('SMS odeslana.') else ShowMessage('Chyba pri odesilani SMS:'#13+MOSCommunicator.ErrMessage); if MOSCommunicator.SendFile('C:\DIR\DATA1.xml', 'DATA1.XML', '', '', '', False) then begin ShowMessage('Prenos OK'); if MOSCommunicator.GetFileInfo('Sklad6DOC', 'Stavy.xml', Info, Velikost, Cas) then begin ShowMessage('GetFileInfo:'#13 + Info+ #13 + FloatToStr(Velikost) + #13 + DateTimeToStr(Cas)); if not MOSCommunicator.GetFile('C:\DIR\Stavy2.XML', 'Podslozka\Stavy.xml', 'Sklad6DOC') then ShowMessage('GetFile:'#13+MOSCommunicator.ErrMessage); end else ShowMessage('GetFileInfo:'#13+MOSCommunicator.ErrMessage); end else ShowMessage('SendFile'#13+MOSCommunicator.ErrMessage); MOSCommunicator.Disconnect; end else ShowMessage(MOSCommunicator.ErrMessage); end else ShowMessage(MOSCommunicator.ErrMessage); finally MOSCommunicator.Free; end; end.
var t: TKAPBtrTable; f: TForm; DBGr: TDBGrid; ds: TDataSource; begin f := nil; DBGr := nil; ds := nil; t := TKAPBtrTable.Create; try t.TableName := 'CISELNIK.btr'; t.IndexFieldNames := 'TypCis;Klic1'; t.Open; f := TForm.Create(Application); f.Caption := 'Zobrazení ' + t.TableName; f.Position := poDefault; DBGr:= TDBGrid.Create(f); DBGr.Parent := f; DBGr.Align := alClient; ds:= TDataSource.Create(f); DBGr.DataSource := ds; ds.DataSet := t; f.ShowModal; finally t.Free; if ds <> nil then ds.Free; if F <> nil then F.Free; end; end.