|
Post by mknarr on May 2, 2019 11:03:06 GMT -5
Weird. I have been using both version LB 4.5.0 and 4.5.1 and have finally decided to use only 4.5.1. There is a program called Simple Help written in 2016 by cundo that I use for programming help. I have it set up in 4.5.0 to run as an external program. I wanted to use it in 4.5.1 but I'm having issues. If I use it in 4.5.0 and do a search it works as expected. But if I try to use it in 4.5.1 the search function crashes. I have copied the Simple Help.bas to 4.5.1. created a new tkn . That crashes during the search function. If I try to run the simple help.tkn file in the 4.5.0 using 4.5.1 it crashes. If I run the tkn file in 4.5.1 using 4.5.0 it works.
The bottom line is the neither the tkn file or even the basic file can't be run by LB version 4.5.1 whether the files are in the 4.5.0 folder or the 4.5.1 folder. BTW, the folders where the files are located are in the AppData folders, not the program folders. I have even tried to copy the tkn file to the 4.5.1 program folder and it still crashes during the search function. Even if I run the tkn file in the 4.5.1 program folder using 4.5.0 it works. So why doesn't 4.5.1 run the search function no matter where the TKN or bas file is but LB version 4.5.0 does? Any ideas?
|
|
|
Post by Chris Iverson on May 2, 2019 11:44:10 GMT -5
Do you have a link to the program? I recall it, but I don't have a local copy of it to test.
|
|
|
Post by mknarr on May 2, 2019 15:03:12 GMT -5
Unfortunately I don't. What I get is a error message that I need to close #main and #atl. For some reason, it's easier for me to use Simple Help rather than LB's help. Using the debugger, It appears it can't find the search word and barfs. Sometimes it says error 53 can't find the file.
|
|
cundo
Full Member
Muchas Gracias!!
Posts: 146
|
Post by cundo on May 2, 2019 15:09:09 GMT -5
Hi mknarr, do you know the version? is there an about dialog? I think I have the code on my XP system, but I have hundreds of versions with and without the AtL control. Thanks for using my program BTW!
|
|
|
Post by mknarr on May 3, 2019 9:30:20 GMT -5
It's version 106+ATL control It almost seems like when perusing the html folder it runs out of files. But if that were the case, when I run the Simple Help.TKN or the .bas in program folder 4.5.0 using LB version 4.5.1, it should work but doesn't. It's not a crisis but for what ever reason I like the program when using help rather that the html version of LB.
Over the years, almost since the day the original forum was started, I've picked up and use a lot of programs and snips from the forum. Thanks to you and all the others that participate in the forum.
Unfortunately, I no longer have web space so I can no longer share all my freeware programs.
|
|
cundo
Full Member
Muchas Gracias!!
Posts: 146
|
Post by cundo on May 3, 2019 9:43:41 GMT -5
Mknarr, could you upload the bas file as an attachment here?
|
|
|
Post by mknarr on May 3, 2019 10:13:30 GMT -5
' (c) 2016 by cundo ' ToDo : add credits, about..., reduce code size, add file exist ' The ATL control code is based on code at http://lbpe.wikispaces.com/ATL+Tutorial ' Find updates and discussion at: libertybasic.conforums.com ' Credits: To the whole LB community. ' Some portions of code based on the work of StefanPendl Nomainwin if instr(Version$,"4.5.")=0 then notice "LB v4.5 required" : end appName$="Simple Help File System" appVersion$="<br>Version 106+ATL Control (by cundo).</br>";_ "<br>Find updates and more at: </br>";_ "<br><a href='http://libertybasic.conforums.com'>";_ "libertybasic.conforums.com</a></br>";_ "<br>Requires LibertyBASIC 4.5.0</br>" on error goto [ohno] Module$ = GetModuleFileName$() fullpath$ = word$( Module$ ,1,afterlast$( Module$ ,"\") ) global helpFilePath$,helpFileMenu$,ItemCount, atl, prevurl$ helpFilePath$ = fullpath$+"lb4help\LibertyBASIC_4_web\" helpFileMenu$ = helpFilePath$;"amber_menu.htm" open helpFileMenu$ for input as #g txt$ = input$(#g, lof(#g)) close #g 'uncomment next 2 lines to get only the Keywords (faster) 'limit1$="Keywords in Alphabetical Order" 'txt$ = word$(txt$,2,limit1$) txt$ = LowerTags$(txt$) dim ar$(520) ' aproximation, is faster this way dim sar$(333) ' Main Contents List (listbox #1=ar$()) Do pos1= instr(txt$,"href",pos4+5) ' these +5 are the lenght of the preious searched string, an aprox. value +1 If pos1=0 then Exit Do pos2=instr(txt$,".htm",pos1+5) pos3=instr(txt$,">",pos2+5) pos4=instr(txt$,"</a>",pos3+2) link$=mid$( txt$, pos1,pos2-pos1) nme$=trim$(mid$( txt$, pos3+1,pos4-pos3-1)) nme$=replstr$(nme$,"&";"quot;",chr$(34)) ' little fix ItemCount=ItemCount+1 if nme$<>"" Then u=u+1: ar$(u)=nme$; chr$(0); link$ Loop While pos4 WindowWidth = 640 : WindowHeight = DisplayHeight-72 UpperLeftX = INT((DisplayWidth-WindowWidth)/2) UpperLeftY = INT((DisplayHeight-WindowHeight)/2) ListboxColor$ = "White" stylebits #main.bt1, _BS_PUSHLIKE or _BS_LEFT, 0, 0, 0 radiobutton #main.bt1, "&Contents",check, check, 4, 30, 70, 28 stylebits #main.bt2, _BS_PUSHLIKE or _BS_LEFT, 0, 0, 0 radiobutton #main.bt2, "&Search", check, check, 74, 30, 70, 28 Stylebits #main.tb, 0,_WS_BORDER,0,0 graphicbox #main.tb 190,60,WindowWidth-200,WindowHeight-100 ' used to be a textbox Stylebits #main.list1,_WS_HSCROLL,0,0,0 listbox #main.list1, ar$(, listClick, 4, 60, 180, WindowHeight-100 Stylebits #main.searchtb, _ES_NOHIDESEL,0,0,0 textbox #main.searchtb 4,65,130,28 Stylebits #main.default,_BS_DEFPUSHBUTTON,0,0,0 button #main.default "&Go", search,ul, 134,65,41,28 listbox #main.list2, sar$(, listClick, 4, 60+40, 180, WindowHeight-100-100 button #main.b1 "&Quit", quit,ur,17,30,48,28 Open appName$ for window as #main #main "font Tahoma 10" #main "trapclose quit" #main.list2 "hide" #main.searchtb "!hide" : #main.default "!hide" #main.tb "font Courier_New 10 48" #main.tb "down;fill buttonface;flush" #main.bt1 "set" #main.list1 "reload" ' #main.list1 "selectindex 1" : call listClick "#main.list1" #main "resizehandler [resized]" '** old new stuff Message$ = "MSHTML:<html><head></head><body><center><h2>";_ "<br>";appName$;"</br>";_ appVersion$;_ "</h2></center></body></html>" atl= AtlAxWin( hwnd(#main.tb), Message$ )
wait [ohno] print Err,Err$ end [resized]
w=WindowWidth-200 h=WindowHeight-100 #main.tb "locate 190 60 ";w;" ";h
' Call DestroyATL ' atl= AtlAxWin( hwnd(#main.tb), "" ) '************CHANGED TO ADJUST THE ATL CONTROL******** calldll #user32, "MoveWindow",_ atl as ulong, _ 'window handle 0 as long,_ 'x location of gfx window 0 as long,_ 'y location of gfx window w as long,_ 'desired width of window h as long,_ 'desired height of window 1 as long,_ 'repaint flag,0=false,1=true ret as void 'nonzero=success
#main "refresh" wait
sub check handle$ whichOne= val(after$(handle$,"bt")) select case whichOne case 1 show$="#main.list";whichOne #show$ "show" hide$="#main.list";2 #hide$ "hide" #main.searchtb "!hide" : #main.default "!hide" case 2 show$="#main.list";whichOne #show$ "show" hide$="#main.list";1 #hide$ "hide" #main.searchtb "!show" : #main.default "!show" #main.searchtb "!setfocus" end select end sub sub search handle$ cursor hourglass #main.searchtb "!contents? txtboxcontents$" if txtboxcontents$<>"" Then
if len(txtboxcontents$)>1 Then #main.list2 "disable" #main.default "!disable" #main.searchtb "!disable" redim sar$(333) #main.list2 "reload" for i = 1 to ItemCount alreadyListed=instr(lower$(ar$(i)),txtboxcontents$) ' lets open only when needed if alreadyListed>0 then ' it's in the listed name already, not need to open the file. ' print "In the list",ar$(i) results= results+1 sar$(results)=ar$(i) else thisF$ = helpFilePath$;"html\";_ after$(word$( ar$(i),2,chr$(0) ),"/");".htm" f$=lower$( OpenTextFile$(thisF$) ) isThere = instr(f$,txtboxcontents$) if isThere>0 and mid$(f$,isThere-1,1)<>"<" then 'print "Not in the list",ar$(i) 'crude html filter results= results+1 sar$(results)=ar$(i) sort sar$()1,results #main.list2 "reload"
end if end if
next i sort sar$()1,results #main.list2 "reload" #main.list2 "enable" #main.default "!enable" #main.searchtb "!enable" end if end if #main.searchtb "!setfocus" : #main.searchtb "!selectall" cursor normal end sub sub listClick handle$ #handle$ "selectionindex? index" if instr(handle$,"2")>0 then array$= sar$(index) else array$= ar$(index) end if thisF$ = helpFilePath$;"html\";_ after$(word$( array$,2,chr$(0) ),"/");".htm" cursor hourglass #main.tb "cls" atl= AtlAxWin( hWnd(#main.tb), thisF$ ) #main.searchtb "!setfocus" cursor normal end sub function OpenTextFile$( fname$ ) open fname$ for input as #f full$ = input$(#f, lof(#f)) close #f OpenTextFile$=full$ end function sub quit handle$ '**********THE QUIT BRANCH is HERE********************** close #main Call DestroyATL end end sub ' borrowed from Stefan Pendl, ' and I borrowed it from alycesrestaurant.com function GetModuleFileName$() nSize = _MAX_PATH + 1 lpFilename$ = space$(nSize); CHR$(0) calldll #kernel32, "GetModuleFileNameA",_ hModule as uLong,_ lpFilename$ as ptr,_ nSize as uLong,_ result as uLong if result > 0 then GetModuleFileName$ = trim$(lpFilename$) end function Function LowerTags$( t$ ) tag$="HREF" t$=replstr$(t$,tag$,lower$(tag$)) tag$="</A>" t$=replstr$(t$,tag$,lower$(tag$)) LowerTags$= t$ End Function Function AtlAxWin( gbx, url$ ) if url$="" then url$=prevurl$ else prevurl$=url$ if url$="" then exit function hWndViewer = gbx Call DestroyATL ' will close the DLL also
Open "atl" For DLL As #atl CallDLL #atl, "AtlAxWinInit", Ret As long
struct Rect, x1 As Long, y1 As Long, x2 As Long, y2 As Long CallDLL #user32, "GetWindowRect",hWndViewer as uLong,Rect As struct, result As void x2 = Rect.x2.struct - Rect.x1.struct y2 = Rect.y2.struct - Rect.y1.struct CallDLL #user32, "GetWindowLongA", _ hWndViewer As ulong, _ 'handle of graphicbox _GWL_HINSTANCE As long, _ 'flag to get instance handle hInst As ulong 'returns instance handle of graphicbox
style = _WS_CHILD or _WS_VISIBLE or _WS_VSCROLL or _WS_HSCROLL exStyle = _WS_EX_CLIENTEDGE or _WS_EX_TOPMOST
CallDLL #user32, "CreateWindowExA", _ exStyle As long, _ 'extended type "AtlAxWin" As ptr, _ 'class name url$ As ptr, _ 'URL, or progID or CLSID style As long, _ 'window style 0 As long, _ 'left x pos 0 As long, _ 'top y pos x2 As long, _ 'width y2 As long, _ 'height hWndViewer As ulong, _ 'handle of parent = graphicbox 100 As long, _ 'handle to menu or child window ID hInst As ulong, _ 'parent instance handle 0 As long, _ 'window creation data hATL As ulong 'handle of active template library control AtlAxWin = hATL End Function
Sub DestroyATL if atl then ' the next api seems to fix the "screen doesn't stay" bug... calldll #user32, "DestroyWindow", _ atl As uLong,r as long close #atl 'close DLL after closing window atl=0 print r end if end Sub
|
|
|
Post by Chris Iverson on May 3, 2019 12:24:27 GMT -5
Figured part of the issue out:
Calling OpenTextFile$ - C:\Program Files (x86)\Liberty BASIC Pro v4.5.1\lb4help\LibertyBASIC_4_web\html\idecode451.htm fname$ value - C:\Program Files (x86)\Liberty BASIC Pro v4.5.1\lb4help\LibertyBASIC_4_web\html\idecode451.htm
If you actually look there, there is no file "idecode451.htm". It's "idecode451.html". The code is chopping the 'L' off the end.
Looking back, it looks like previous versions of LB didn't have any files named *.html in the help section, just *.htm.
Don't know the code well enough to know how to fix it, but this should give an idea of where to look.
|
|
cundo
Full Member
Muchas Gracias!!
Posts: 146
|
Post by cundo on May 3, 2019 15:43:04 GMT -5
OK, I can't remember why... but I have a newer version V108, is the "metro" edition.
' (c) 2016 - 2018 by cundo ' Made with LB version 4.5.1 ' Check For File existance - done ' ToDo : add credits, about..., reduce code size, add file exist ' The ATL control code is based on code at http://lbpe.wikispaces.com/ATL+Tutorial ' Find updates and discussion at: libertybasiccom.proboards.com ' Credits: To the whole LB community. ' Some portions of code based on the work of StefanPendl ' CHANGES: ATL dll managed differently. Nomainwin if instr(Version$,"4.5.")=0 then notice "LB v4.5 or better required" : end Open "atl" For DLL As #atl CallDLL #atl, "AtlAxWinInit", ATLOK As long IF ATLOK = 0 Then notice "Could not load the ATL library!" : end
appName$="Simple Help File System" appVersion$="<br>Version 108+ATL Control (by cundo).</br>";_ "<br>Find updates and more at: </br>";_ "<br><a href='http://libertybasiccom.proboards.com'>";_ "libertybasiccom.proboards.com</a></br>";_ "<br>Requires LibertyBASIC 4.5.1</br>" on error goto [ohno] Module$ = GetModuleFileName$() fullpath$ = word$( Module$ ,1,afterlast$( Module$ ,"\") ) global helpFilePath$,helpFileMenu$,ItemCount, atl, ATLOK helpFilePath$ = fullpath$+"lb4help\LibertyBASIC_4_web\" helpFileMenu$ = helpFilePath$;"amber_menu.htm" open helpFileMenu$ for input as #g txt$ = input$(#g, lof(#g)) close #g 'uncomment next 2 lines to get only the Keywords (faster) 'limit1$="Keywords in Alphabetical Order" 'txt$ = word$(txt$,2,limit1$) txt$ = LowerTags$(txt$) dim ar$(520) ' aproximation, is faster this way dim sar$(333) ' Main Contents List (listbox #1=ar$()) Do pos1= instr(txt$,"href",pos4+5) ' these +5 are the lenght of the preious searched string, an aprox. value +1 If pos1=0 then Exit Do pos2=instr(txt$,".htm",pos1+5) pos3=instr(txt$,">",pos2+5) pos4=instr(txt$,"</a>",pos3+2) link$=mid$( txt$, pos1,pos2-pos1) nme$=trim$(mid$( txt$, pos3+1,pos4-pos3-1)) nme$=replstr$(nme$,"&";"quot;",chr$(34)) ' little fix ItemCount=ItemCount+1 if nme$<>"" Then u=u+1: ar$(u)=nme$; chr$(0); link$ Loop While pos4 WindowWidth = 640 : WindowHeight = DisplayHeight-72 UpperLeftX = INT((DisplayWidth-WindowWidth)/2) UpperLeftY = INT((DisplayHeight-WindowHeight)/2) ListboxColor$ = "White" stylebits #main.bt1, _BS_PUSHLIKE or _BS_LEFT, 0, 0, 0 radiobutton #main.bt1, "&Contents",check, check, 4, 30, 70, 28 stylebits #main.bt2, _BS_PUSHLIKE or _BS_LEFT, 0, 0, 0 radiobutton #main.bt2, "&Search", check, check, 74, 30, 70, 28 Stylebits #main.tb, 0,_WS_BORDER,0,0 graphicbox #main.tb 190,60,WindowWidth-208,WindowHeight-102 ' used to be a textbox Stylebits #main.list1,_WS_HSCROLL,0,0,0 listbox #main.list1, ar$(, listClick, 4, 60, 180, WindowHeight-100 Stylebits #main.searchtb, _ES_NOHIDESEL,0,0,0 textbox #main.searchtb 4,65,130,28 Stylebits #main.default,_BS_DEFPUSHBUTTON,0,0,0 button #main.default "&Go", search,ul, 134,65,41,28 listbox #main.list2, sar$(, listClick, 4, 60+40, 180, WindowHeight-100-100 button #main.b1 "&Quit", quit,ur,17,30,48,28 Open appName$ for window as #main #main "font Tahoma 10" #main "trapclose quit" #main.list2 "hide" #main.searchtb "!hide" : #main.default "!hide" #main.tb "font Courier_New 10 48" #main.tb "down;fill buttonface;flush" #main.bt1 "set" #main.list1 "reload" ' #main.list1 "selectindex 1" : call listClick "#main.list1" #main "resizehandler [resized]" '** old new stuff Message$ = "MSHTML:<html><head></head><body><center><h2>";_ "<br>";appName$;"</br>";_ appVersion$;_ "</h2></center></body></html>" atl= AtlAxWin( hwnd(#main.tb), Message$ )
wait [ohno] print Err,Err$ end [resized]
w=WindowWidth-200 h=WindowHeight-100 #main.tb "locate 190 60 ";w;" ";h
' Call DestroyATL ' atl= AtlAxWin( hwnd(#main.tb), "" ) '************CHANGED TO ADJUST THE ATL CONTROL******** calldll #user32, "MoveWindow",_ atl as ulong, _ 'window handle 0 as long,_ 'x location of gfx window 0 as long,_ 'y location of gfx window w as long,_ 'desired width of window h as long,_ 'desired height of window 1 as long,_ 'repaint flag,0=false,1=true ret as void 'nonzero=success
#main "refresh" wait
sub check handle$ whichOne= val(after$(handle$,"bt")) select case whichOne case 1 show$="#main.list";whichOne #show$ "show" hide$="#main.list";2 #hide$ "hide" #main.searchtb "!hide" : #main.default "!hide" case 2 show$="#main.list";whichOne #show$ "show" hide$="#main.list";1 #hide$ "hide" #main.searchtb "!show" : #main.default "!show" #main.searchtb "!setfocus" end select end sub sub search handle$ cursor hourglass #main.searchtb "!contents? txtboxcontents$" if txtboxcontents$<>"" Then
if len(txtboxcontents$)>1 Then #main.list2 "disable" #main.default "!disable" #main.searchtb "!disable" redim sar$(333) #main.list2 "reload" for i = 1 to ItemCount alreadyListed=instr(lower$(ar$(i)),txtboxcontents$) ' lets open only when needed if alreadyListed>0 then ' it's in the listed name already, not need to open the file. ' print "In the list",ar$(i) results= results+1 sar$(results)=ar$(i) else thisF$ = helpFilePath$;"html\";_ after$(word$( ar$(i),2,chr$(0) ),"/");".htm" f$=lower$( OpenTextFile$(thisF$) ) isThere = instr(f$,txtboxcontents$) if isThere>0 and mid$(f$,isThere-1,1)<>"<" then 'print "Not in the list",ar$(i) results= results+1 sar$(results)=ar$(i) sort sar$()1,results #main.list2 "reload"
end if end if
next i sort sar$()1,results #main.list2 "reload" #main.list2 "enable" #main.default "!enable" #main.searchtb "!enable" end if end if #main.searchtb "!setfocus" : #main.searchtb "!selectall" cursor normal end sub sub listClick handle$ #handle$ "selectionindex? index" if instr(handle$,"2")>0 then array$= sar$(index) else array$= ar$(index) end if thisF$ = helpFilePath$;"html\";_ after$(word$( array$,2,chr$(0) ),"/");".htm" cursor hourglass '#main.tb "cls" atl= AtlAxWin( hWnd(#main.tb), thisF$ ) #main.searchtb "!setfocus" cursor normal end sub function OpenTextFile$( fname$ ) If fileExists( fname$ ) then open fname$ for input as #f full$ = input$(#f, lof(#f)) close #f OpenTextFile$=full$ End if end function sub quit handle$ '**********THE QUIT BRANCH is HERE********************** close #main Call DestroyATL close #atl 'close DLL after closing window end end sub ' borrowed from Stefan Pendl, ' and I borrowed it from alycesrestaurant.com function GetModuleFileName$() nSize = _MAX_PATH + 1 lpFilename$ = space$(nSize); CHR$(0) calldll #kernel32, "GetModuleFileNameA",_ hModule as uLong,_ lpFilename$ as ptr,_ nSize as uLong,_ result as uLong if result > 0 then GetModuleFileName$ = trim$(lpFilename$) end function Function LowerTags$( t$ ) tag$="HREF" t$=replstr$(t$,tag$,lower$(tag$)) tag$="</A>" t$=replstr$(t$,tag$,lower$(tag$)) LowerTags$= t$ End Function Function AtlAxWin( hWndViewer, url$ ) if url$="" then exit function Call DestroyATL ' doesn't close the dll now
struct Rect, x1 As Long, y1 As Long, x2 As Long, y2 As Long CallDLL #user32, "GetWindowRect",hWndViewer as uLong,Rect As struct, result As void x2 = Rect.x2.struct - Rect.x1.struct y2 = Rect.y2.struct - Rect.y1.struct CallDLL #user32, "GetWindowLongA", _ hWndViewer As ulong, _ 'handle of graphicbox _GWL_HINSTANCE As long, _ 'flag to get instance handle hInst As ulong 'returns instance handle of graphicbox
style = _WS_CHILD or _WS_VISIBLE or _WS_VSCROLL or _WS_HSCROLL exStyle = _WS_EX_CLIENTEDGE or _WS_EX_TOPMOST
CallDLL #user32, "CreateWindowExA", _ exStyle As long, _ 'extended type "AtlAxWin" As ptr, _ 'class name url$ As ptr, _ 'URL, or progID or CLSID style As long, _ 'window style 0 As long, _ 'left x pos 0 As long, _ 'top y pos x2 As long, _ 'width y2 As long, _ 'height hWndViewer As ulong, _ 'handle of parent = graphicbox 100 As long, _ 'handle to menu or child window ID hInst As ulong, _ 'parent instance handle 0 As long, _ 'window creation data hATL As ulong 'handle of active template library control AtlAxWin = hATL End Function
Sub DestroyATL if atl then ' the next api seems to fix the "screen doesn't stay" bug... calldll #user32, "DestroyWindow", _ atl As uLong,r as long atl=0 end if end Sub
function fileExists(pathAndfilename$) filename$ = afterlast$(pathAndfilename$,"\") path$ = upto$(pathAndfilename$,filename$ ) dim fileInfo$(10,10) files path$, filename$, fileInfo$() fileExists = val(fileInfo$(0, 0)) 'non zero is true end function
|
|
|
Post by mknarr on May 3, 2019 18:10:55 GMT -5
Thank you, that works.
|
|
|
Post by metro on May 3, 2019 19:04:27 GMT -5
OK, I can't remember why... but I have a newer version V108, is the "metro" edition.
the "metro edition" was for me as your original code did not work for me using Linux/Wine combo
|
|
cundo
Full Member
Muchas Gracias!!
Posts: 146
|
Post by cundo on May 3, 2019 19:31:30 GMT -5
Yes metro! I named it after you! the other one is the "old-school first edition V105" XD. But I think I updated the metro edition because of this very same problem (files not found), I can't remember haha.
|
|
|
Post by mknarr on May 4, 2019 13:30:51 GMT -5
Ha. At the age of 80 I'm just glad I can remember my name.
|
|
|
Post by mknarr on May 10, 2019 9:25:16 GMT -5
cundo. Not only does the new version work great, but this version can stay open while I type in the LB IDE. The version I had, had to be closed before I could type in the IDE. I believe I can even copy and paste. Since I abandoned my commercial program I haven't coded for a while and often I have to refer to the Help file to remember semantics. Thanks for the update.
|
|