The app is not really very amazing, it's just a kanji database I put together off the free EDICT text from Monasch University.
the first char in the search text is check for kanji/hiragana/english and the search based on that. the code is a very simple example of SQLite without the wrappers. The zip file below the screenshot contains the exe, database and sqlite dll, just copy to a folder and run as is.

http://www.dwyer-family.net/download/kanji.zip
Source is below. Anyone have any improvements or suggestions (like, "don't update gui's from callbacks because it dangerous") please let me know, there's not a lot of error checking either.
Code: Select all
#SQLITE3_ISO8859 = 1 ;
#SQLITE3_OK = 0 ;'*/ Successful result */
#SQLITE3_ERROR = 1 ;'*/ SQL error or missing database */
#SQLITE3_INTERNAL = 2 ;'*/ An internal logic error in SQLite */
#SQLITE3_PERM = 3 ;'*/ Access permission denied */
#SQLITE3_ABORT = 4 ;'*/ Callback routine requested an abort */
#SQLITE3_BUSY = 5 ;'*/ The database file is locked */
#SQLITE3_LOCKED = 6 ;'*/ A table in the database is locked */
#SQLITE3_NOMEM = 7 ;'*/ A malloc() failed */
#SQLITE3_READONLY = 8 ;'*/ Attempt to write a readonly database */
#SQLITE3_INTERRUPT = 9 ;'*/ Operation terminated by sqlite3_interrupt() */
#SQLITE3_IOERR = 10 ;'*/ Some kind of disk I/O error occurred */
#SQLITE3_CORRUPT = 11 ;'*/ The database disk image is malformed */
#SQLITE3_NOTFOUND = 12 ;'*/ (Internal Only) Table or record not found */
#SQLITE3_FULL = 13 ;'*/ Insertion failed because database is full */
#SQLITE3_CANTOPEN = 14 ;'*/ Unable to open the database file */
#SQLITE3_PROTOCOL = 15 ;'*/ Database lock protocol error */
#SQLITE3_EMPTY = 16 ;'*/ (Internal Only) Database table is empty */
#SQLITE3_SCHEMA = 17 ;'*/ The database schema changed */
#SQLITE3_TOOBIG = 18 ;'*/ Too much data for one row of a table */
#SQLITE3_CONSTRAINT = 19 ;'*/ Abort due to contraint violation */
#SQLITE3_MISMATCH = 20 ;'*/ Data type mismatch */
#SQLITE3_MISUSE = 21 ;'*/ Library used incorrectly */
#SQLITE3_NOLFS = 22 ;'*/ Uses OS features not supported on host */
#SQLITE3_AUTH = 23 ;'*/ Authorization denied */
#SQLITE3_ROW = 100 ;'*/ sqlite3_step() has another row ready */
#SQLITE3_DONE = 101 ;'*/ sqlite3_step() has finished executing */
#SQL_LIB = 1 ; dll ID
;- Window Constants
Enumeration
#FrmMain
EndEnumeration
;- Gadget Constants
Enumeration
#String_0
#CMD_Search
#Listview_0
#CMD_Paste
#Chk_ExactSearch
#StatusBar_0
EndEnumeration
Enumeration
#English
#Kanji
#Hiragana
EndEnumeration
Declare ProcSQL(SQL.s)
Declare CallBack_ReturnRows(NullPtr.l,ArgCount.l,*Values.l, *ColNames.l)
Declare Open_FrmMain()
Declare CmdSearch(SearchType.l, Keyword.s, Exact.l)
Declare.l GetTextType(SearchText.s)
Global RowCount.l
Global FontID1
FontID1 = LoadFont(1, "MS Sans Serif", 11)
OpenLibrary(#SQL_LIB, "sqlite3.dll")
Open_FrmMain()
CloseLibrary(#SQL_LIB)
Procedure Open_FrmMain()
If OpenWindow(#FrmMain, 305, 168, 571, 445, "QuickSearch Kanji Dictionary", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget | #PB_Window_TitleBar )
CreateStatusBar(#StatusBar_0, WindowID(#FrmMain))
SetGadgetFont(#StatusBar_0, FontID1)
If CreateGadgetList(WindowID(#FrmMain))
StringGadget(#String_0, 3, 0, 100, 21, "")
;SetGadgetFont(#String_0, FontID1)
ButtonGadget(#CMD_Search, 105, 0, 54, 21, "Search")
SetGadgetFont(#CMD_Search, FontID1)
ListViewGadget(#Listview_0, 3, 24, 567, 400, #LBS_USETABSTOPS | #WS_HSCROLL | #WS_VSCROLL )
SetGadgetFont(#Listview_0, FontID1)
ButtonGadget(#CMD_Paste, 162, 0, 54, 21, "Paste")
SetGadgetFont(#CMD_Paste, FontID1)
CheckBoxGadget(#Chk_ExactSearch, 219, 0, 108, 21, "Exact Search")
SetGadgetFont(#Chk_ExactSearch, FontID1)
EndIf
EndIf
Dim tStop(1)
tstop(0) = 70
tstop(1) = 150
SendMessage_(GadgetID(#Listview_0), #LB_SETTABSTOPS, 2, @tStop(0))
SendMessage_(GadgetID(#Listview_0), #LB_SETHORIZONTALEXTENT, 2000,0)
Window_Icon.l=LoadImage_(GetModuleHandle_(0),"F:\Programming\PBasic\icons\Bookshelf.ico",#IMAGE_ICON,16,16,#LR_LOADFROMFILE)
SendMessage_(WindowID(#FrmMain), #WM_SETICON, 0, Window_Icon)
SearchText.s = ""
SearchTextType.l = 0
ExactSearch.l
Repeat
Event.l = WaitWindowEvent()
If Event
Select Event
Case #PB_Event_Gadget
Select EventGadget()
Case #CMD_Search
If GetGadgetText(#String_0) <> ""
RowCount = 0
ClearGadgetItemList(#Listview_0)
SearchText = GetGadgetText(#String_0)
ExactSearch = GetGadgetState(#Chk_ExactSearch)
SearchTextType = GetTextType(SearchText)
CMDSearch(SearchTextType, SearchText, ExactSearch)
EndIf
Case #CMD_Paste
SetGadgetText(#String_0,GetClipboardText())
EndSelect
Case #PB_Event_SizeWindow
ResizeGadget(#Listview_0, #PB_Ignore, #PB_Ignore, WindowWidth(#FrmMain) - 5, WindowHeight(#FrmMain) - 45)
EndSelect
EndIf
Until Event = #PB_Event_CloseWindow
EndProcedure
;==============================================================================
Procedure ProcSQL(SQL.s)
sDBFileName.s = "Kanji.db"
RetResult = CallCFunction(#SQL_LIB, "sqlite3_open" ,sDBFileName, @hDB)
Debug RetResult
;Send Query
QueryRet.l = CallCFunction(#SQL_LIB, "sqlite3_exec" ,hDB, SQL, @CallBack_ReturnRows() , #Null, @ReturnValue)
Debug QueryRet
If QueryRet
Debug "ret:" + PeekS(ReturnValue)
EndIf
RetResult = CallCFunction(#SQL_LIB, "sqlite3_close" ,@hDB)
;Debug retresult
EndProcedure
; ==========================================================
ProcedureC.l CallBack_ReturnRows(NullPtr.l,ArgCount.l,*Values.l, *ColNames.l) ;argcount = column count
Dim ValuePts.l(ArgCount)
Row.s = ""
For ValLoop.l = 0 To ArgCount -1
ValuePts(ValLoop) = PeekL(*Values + (ValLoop * 4))
Row = Row + PeekS(ValuePts(ValLoop) ) + #TAB$
Next
AddGadgetItem(#Listview_0, -1, Row)
RowCount + 1
StatusBarText(#StatusBar_0, 0, "Rows Found: " + Str(Rowcount))
ProcedureReturn 0 ;Proceed with next row
EndProcedure
;======================================================================================
Procedure CmdSearch(SearchType.l, Keyword.s, Exact.l)
SQL.s
keyword = Trim(keyword)
Select SearchType
Case #Kanji
If Exact = 1
SQL = "Select kanji, reading, meaning from kanji where kanji = '" + keyword + "' order by kanji"
Else
SQL = "Select kanji, reading, meaning from kanji where kanji like '%" + keyword + "%' order by kanji"
EndIf
Case #hiragana
If Exact = 1
SQL = "Select kanji, reading, meaning from kanji where reading = '" + keyword + "' order by kanji"
Else
SQL = "Select kanji, reading, meaning from kanji where reading like '%" + keyword + "%' order by kanji"
EndIf
Case #English
SQL = "Select kanji, reading, meaning from kanji where meaning like '%" + keyword + "%' order by kanji"
EndSelect
Debug sql
Debug "EX " + Str(exact)
ProcSQL(SQL)
EndProcedure
;======================================================================================
Procedure.l GetTextType(SearchText.s) ;Written for sjis, would need to change if DB changed ti UTF
FirstChar.l = Asc(Left(searchtext,1))
If firstchar < 129
ProcedureReturn #English
ElseIf firstchar > 135
ProcedureReturn #Kanji
Else
ProcedureReturn #Hiragana
EndIf
EndProcedure
;======================================================================================