Можно так: Add(MainForm,7851702,217,224) { Width=764 Height=207 Point(onClose) link(onCreate,11491245:doOpen,[]) link(onClose,11491245:doClose,[]) } Add(SQLite_DB,11491245,266,238) { FileName="notebook.db" link(onOpen,10758059:doQuery,[]) link(onError,14399684:doMessage,[(312,251)(312,300)]) } Add(SQLite_Query,34590,532,252) { link(onQuery,9854747:doAdd,[]) link(onError,3817780:doMessage,[(576,272)(576,314)]) link(dbHandle,4851005:Var3,[(538,219)]) } Add(Hub,10580939,504,245) { link(onEvent1,9854747:doClear,[(572,251)(572,265)]) link(onEvent2,34590:doQuery,[]) } Add(FormatStr,12755171,462,245) { DataCount=1 Mask="SELECT gf2 FROM note WHERE substr(gf2,1,1)='%1' ORDER BY gf2;" link(onFString,10580939:doEvent1,[]) } Add(Message,14399684,343,294) { Caption="1 опс" } Add(Message,3817780,581,308) { Caption="2 опс" } Add(ComboBox,9854747,581,252) { Left=140 Top=15 Width=595 Height=21 DropDownCount=30 } Add(ComboBox,12721352,406,238) { Left=70 Top=15 Height=21 DataType=1 link(onClick,12755171:doString,[]) } Add(Label,11543057,217,294) { Left=10 Top=10 Height=30 Caption="Первая\r\nбуква:" AutoSize=1 Alignment=1 } Add(SQLite_Query,10758059,343,238) { SQL="SELECT DISTINCT substr(gf2,1,1) AS a FROM note ORDER BY a;" link(onQuery,12721352:doAdd,[]) link(dbHandle,4851005:Var2,[]) } Add(GetDataEx,4851005,343,214) { Angle=3 link(Data,11491245:dbHandle,[(323,219)(323,283)(272,283)]) }
или так: Add(MainForm,7851702,217,224) { Width=764 Height=207 Point(onClose) link(onCreate,11491245:doOpen,[]) link(onClose,11491245:doClose,[]) } Add(SQLite_DB,11491245,266,238) { FileName="notebook.db" link(onOpen,2573979:doEvent1,[]) link(onError,14399684:doMessage,[(312,251)(312,300)]) } Add(SQLite_Query,34590,546,259) { link(onQuery,9854747:doAdd,[]) link(onError,3817780:doMessage,[(590,279)(590,321)]) link(dbHandle,11491245:dbHandle,[(552,219)(316,219)(316,277)(272,277)]) } Add(Hub,10580939,518,252) { link(onEvent1,9854747:doClear,[(601,258)(601,272)]) link(onEvent2,34590:doQuery,[]) } Add(FormatStr,12755171,476,252) { DataCount=1 Mask="SELECT gf2 FROM note WHERE substr(gf2,1,pos(' ',gf2))='%1' ORDER BY gf2;" link(onFString,10580939:doEvent1,[]) } Add(Message,14399684,357,294) { Caption="1 опс" } Add(Message,3817780,616,315) { Caption="2 опс" } Add(ComboBox,9854747,616,259) { Left=205 Top=15 Width=530 Height=21 Text="" DropDownCount=30 } Add(ComboBox,12721352,420,245) { Left=70 Top=15 Width=125 Height=21 Text="" DataType=1 DropDownCount=30 link(onClick,12755171:doString,[]) } Add(Label,11543057,217,294) { Left=10 Top=10 Height=30 Caption="Первое\r\nслово:" AutoSize=1 Alignment=1 } Add(SQLite_Query,10758059,357,245) { SQL="SELECT DISTINCT substr(gf2,1,pos(' ',gf2)) AS a FROM note ORDER BY a;" link(onQuery,12721352:doAdd,[]) } Add(InlineCode,11586007,357,175) { @Hint=#5:Pos()| WorkPoints=#11:addFunction| DataPoints=#8:dbHandle| Code=#15:unit HiAsmUnit;|0:|9:interface|0:|52:uses kol,Share,Debug,Windows,SQLite3Api,hiSQLite_DB;|0:|4:type|28: THiAsmClass = class(TDebug)|9: public|24: dbHandle : THI_Event;|52: procedure addFunction(var _Data:TData; idx:word);|5: end;|46:type arr = array[0..1] of PValue; parr = ^arr;|14:implementation|66:procedure MyFunc(ctx:pointer; nArg:integer; data:ppvalue); cdecl;|19:var s, ss : string;|16: i : integer;|5:begin|43: s := sqlite3_value_text(parr(data)[0]);|48: ss := sqlite3_value_text(parr(data)[1])+'.';|19: i := pos(s,ss);|32: sqlite3_result_int(ctx,i); |4:end;|0:|34:procedure THiAsmClass.addFunction;|13:var dt:TData;|13: s:string;|5:begin|37: dt := ReadData(_Data,dbHandle,nil);|41: if _IsObject(dt,SQLite_GUID) then begin|86: sqlite3_create_function(ToObject(dt),PChar('POS'),2,SQLITE_ANY,nil,@myFunc,nil,nil);|6: end;|4:end;|0:|4:end.|1:{|45:function sqlite3_create_collation(db:pointer;|14: zName:pchar;|19: eTextRep:integer;|19: userData:pointer;|38: func:TUserCollation):integer; cdecl;|1:}| AddHint(-17,-29,39,13,@Hint) } Add(Hub,2573979,322,238) { link(onEvent1,11586007:addFunction,[(350,244)(350,181)]) link(onEvent2,10758059:doQuery,[]) }
Если используется последняя версия sqlite3.dll, то вместо доморощенной функции Pos() используется instr(). Редактировалось 3 раз(а), последний 2017-01-25 15:14:03
|