LB Booster
« LB 4.5 is underwhelming »

Welcome Guest. Please Login or Register.
Jun 22nd, 2017, 4:38pm


Speed up Liberty BASIC programs by up to ten times!
Compile Liberty BASIC programs to compact, standalone executables!
Overcome many of Liberty BASIC's bugs and limitations!
LB Booster Resources
LB Booster documentation
LB Booster Home Page
LB Booster technical Wiki
Just BASIC forum
LB Umbrella forum
Liberty BASIC forum (the original)

« Previous Topic | Next Topic »
Pages: 1 2  Notify Send Topic Print
 hotthread  Author  Topic: LB 4.5 is underwhelming  (Read 1905 times)
Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1190
xx Re: LB 4.5 is underwhelming
« Reply #15 on: Aug 21st, 2015, 09:41am »

Now that LB 4.5.0 is officially released I thought it appropriate to list once again a library for LBB which supports the new string functions: after$, afterlast$, remchar$, replstr$, upto$ and httpget$ (I've also included the endswith function although I can't find it mentioned anywhere in the LB 4.5.0 help file!).

To ensure that a program using one or more of these functions is fully compatible with both LBB and LB 4.5.0 you should save the code listed below to a file (called lb45func.bas or something like that). Then add this command at the very end of your program:

Code:
'include lb45func.bas 
(must start in the first column and end with a newline).

Because this command is ignored by LB the native functions will be called when running in LB 4.5.0 and the library functions when running in LBB.

Here is the library:

Code:
' LB 4.5.0 function library for LB Booster
' by Richard Russell, http://lbbooster.com

function after$(source$, match$)
i = instr(source$, match$)
if i then after$ = mid$(source$,i+len(match$))
end function

function afterlast$(source$, match$)
do : i = j
  j = instr(source$, match$, j+1)
loop until j = 0
if i then afterlast$ = mid$(source$,i+len(match$))
end function

function endswith(source$, match$)
endswith = right$(source$,len(match$)) = match$
end function

function remchar$(source$, charset$)
for i = 1 to len(charset$)
  do
    j = instr(source$, mid$(charset$,i,1))
    if j then source$ = left$(source$,j-1);mid$(source$,j+1)
  loop until j = 0
next
remchar$ = source$
end function

function replstr$(source$, old$, new$)
do
  i = instr(source$, old$, i+1)
  if i then
    source$ = left$(source$,i-1);new$;mid$(source$,i+len(old$))
    i = i + len(new$) - 1
  end if
loop until i = 0
replstr$ = source$
end function

function upto$(source$, match$)
i = instr(source$, match$)
if i then upto$=left$(source$,i-1) else upto$=source$
end function

function httpget$(url$)
open "WININET.DLL" for dll as #net
calldll #net, "InternetOpenA", "LB Booster" as ptr, 0 as long, _
  0 as long, 0 as long, 0 as long, hnet as ulong
calldll #net, "InternetOpenUrlA", hnet as ulong, url$ as ptr, _
  "" as ptr, 0 as long, 0 as long, 0 as long, hurl as ulong
buffer$ = space$(1000)
struct httpget, nread as long
do
  buflen = len(buffer$)
  calldll #net, "InternetReadFile", hurl as ulong, _
buffer$ as ptr, buflen as long, httpget as struct, res as long
  httpget$ = httpget$ + left$(buffer$, httpget.nread.struct)
loop until httpget.nread.struct = 0
calldll #net, "InternetCloseHandle", hurl as ulong, res as long
calldll #net, "InternetCloseHandle", hnet as ulong, res as long
close #net
end function 

Richard.
« Last Edit: Aug 21st, 2015, 12:58pm by Richard Russell » User IP Logged

Pages: 1 2  Notify Send Topic Print
« Previous Topic | Next Topic »

Donate $6.99 for 50,000 Ad-Free Pageviews!


This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls