|
Post by David Drake on Feb 18, 2020 7:08:22 GMT -5
Very happy for others to edit them.... it's a shame that a new user looking at code on RC may get landed with these small number of errors. It would help if anyone altering or adding to Rosetta Code put a note on this board. Those who don't observe this nicety- they know who they are, and are visible on the 'history of edits' page- are muddying the water. In the last couple of weeks I have made several new additions to "tasks not implemented in Liberty BASIC." You appear to be suggesting that we note that on this discussion board. Should we have a thread just for that? I have added the following: - Calendar (http://rosettacode.org/wiki/Calendar) - Grayscale image (http://rosettacode.org/wiki/Grayscale_image) - Magic 8-ball (http://rosettacode.org/wiki/Magic_8-Ball) - Number names (http://rosettacode.org/wiki/Number_names) - Word frequency (http://rosettacode.org/wiki/Word_frequency) - Zero to the zero power (http://rosettacode.org/wiki/Zero_to_the_zero_power) Didn't intend to "muddy the water+ - just to help raise our profile.
|
|
|
Post by tenochtitlanuk on Feb 18, 2020 11:07:42 GMT -5
David- Sorry- I seem to have missed your earlier notifications- although I follow LB and JB boards pretty much very day. Since LB v1.4!!
I posted links to the additions I made to Rosetta Code on a different thread earlier.
Please keep further solutions coming! They'll attract new and old LB users if posted here, as either suggested solutions or links to ones you've added.
JohnF
|
|
|
Post by sarossell on Feb 18, 2020 15:16:45 GMT -5
Agreed. That would be a pain in the backside for what would eventually be of little real use outside of maybe teaching small snippets of code, which begs the need for such a thing in the first place. But..it..would..be SO COOL!
I'll just reserve this kind of goofy stuff to my version of Heaven. In the meantime, thanks for all your hard work on this! I think it's very telling that of all the languages featured on Rosetta, only six have even attempted an aggregator and TWO of them (LB and Run) are Carl's!
:@)
|
|
|
Post by meerkat on Feb 18, 2020 18:25:27 GMT -5
How many programs are there? I think I'm missing some? I get a count of 350 with this code:
a$ = httpGet$("http://rosettacode.org/wiki/Category:Liberty_BASIC") ' get LB tasks from [RC] a1$ = word$(a$,2,"Pages in category ";chr$(34);"Liberty BASIC") a1$ = word$(a1$,1,"</tr></table>") i = 2 a2$ = word$(a1$,i,"<li><a href=";chr$(34);"/wiki/")
print "------------ LB List -----------------" while a2$ <> "" a2$ = left$(a2$,instr(a2$,chr$(34))-1) a2$ = strRep$(a2$,"%2B","+") a2$ = strRep$(a2$,"%27","'") print using("####",i-1);" ";a2$ i = i + 1 a2$ = word$(a1$,i,"<li><a href=";chr$(34);"/wiki/") wend print "------------ End ---------------------" end
' -------------------------------- ' string replace rep str with ' -------------------------------- FUNCTION strRep$(str$,rep$,with$) ln = len(rep$) ln1 = ln - 1 i = 1 while i <= len(str$) if mid$(str$,i,ln) = rep$ then strRep$ = strRep$ + with$ i = i + ln1 else strRep$ = strRep$ + mid$(str$,i,1) end if i = i + 1 WEND END FUNCTION
|
|
|
Post by Rod on Feb 19, 2020 4:57:11 GMT -5
That's what I am getting, I was going to get the complete list of tasks and try to show what we have done and what is still to do. Not yet sure what presentation might be best. A list box...… ugh But a page formatted as the RC index page with two color text for done and not done? But that would require me to learn HTML and code a browser popup window!
|
|
|
Post by meerkat on Feb 19, 2020 6:06:35 GMT -5
Thanks Rod.. I know HTML, but can LB display in a browser?
Being new to LB I just found out about the replace string (replstr$) So the code without the strRep$ function..
I'll see if I can speed it up.. Right now it takes a couple seconds before it starts to print.
It would only take a few lines of code to display the LB code next to the list box for selected items. But doubt there would be any interest.
Probably should put it into memory SQLite with some buttons to look up, sort, or whatever. Probably not a good idea since it would probably double the code
a$ = httpGet$("http://rosettacode.org/wiki/Category:Liberty_BASIC") ' get LB tasks from [RC] a1$ = word$(a$,2,"Pages in category ";chr$(34);"Liberty BASIC") a1$ = word$(a1$,1,"</tr></table>") print "------------ LB List -----------------" for i = 2 to len(a1$) a2$ = word$(a1$,i,"<li><a href=";chr$(34);"/wiki/") if trim$(a2$) = "" then exit for a2$ = left$(a2$,instr(a2$,chr$(34))-1) a2$ = replstr$(a2$,"%2B","+") a2$ = replstr$(a2$,"%27","'") print using("####",i-1);" ";a2$ next i print "------------ End ---------------------" end
|
|
|
Post by Rod on Feb 19, 2020 7:09:03 GMT -5
Well we can have a browser control in a window. Alyce showed us how. I have only played with it a little. alycesrestaurant.com/lbpe/ATL%20Tutorial.htmlThe alternative would be to draw it as a list of text in a graphicbox which would allow user interaction.
|
|
|
Post by Brandon Parker on Feb 19, 2020 9:46:29 GMT -5
Very happy for others to edit them.... it's a shame that a new user looking at code on RC may get landed with these small number of errors. It would help if anyone altering or adding to Rosetta Code put a note on this board. Those who don't observe this nicety- they know who they are, and are visible on the 'history of edits' page- are muddying the water. In the last couple of weeks I have made several new additions to "tasks not implemented in Liberty BASIC." You appear to be suggesting that we note that on this discussion board. Should we have a thread just for that? I have added the following: - Calendar (http://rosettacode.org/wiki/Calendar) - Grayscale image (http://rosettacode.org/wiki/Grayscale_image) - Magic 8-ball (http://rosettacode.org/wiki/Magic_8-Ball) - Number names (http://rosettacode.org/wiki/Number_names) - Word frequency (http://rosettacode.org/wiki/Word_frequency) - Zero to the zero power (http://rosettacode.org/wiki/Zero_to_the_zero_power) Didn't intend to "muddy the water+ - just to help raise our profile. On the old forum, we had a dedicated board where anyone could take a Rosetta Code task and post it. After review by the community, there would be a consensus formed on code that would be posted to the Rosetta Code site. This posting was normally done by Chris Iverson. This was done to ensure that the tasks being completed conformed to requirements and gave people on the forum quite a bit to discuss. I personally like this approach since we, as a community, can police what is going up on Rosetta Code pertaining to Liberty BASIC. {:0) Brandon Parker
|
|
|
Post by metro on Feb 21, 2020 19:00:31 GMT -5
Scratching my head again.... am I doing something wrong or is there an issue with httpget$
global urlfile$
a$ = httpGet$("http://rosettacode.org/wiki/Category:Liberty_BASIC") ' get RB tasks from [RC] a1$ = word$(a$,2,"Pages in category ";chr$(34);"Liberty BASIC") a1$ = word$(a1$,1,"</tr></table>") i = 2 a2$ = word$(a1$,i,"<li><a href=";chr$(34);"/wiki/") ' ' Create a drop down window for selection of a task ' print "------------ LB List -----------------" while a2$ <> "" a2$ = left$(a2$,instr(a2$,chr$(34))-1) a2$ = strRep$(a2$,"%2B","+") a2$ = strRep$(a2$,"%27","'") print using("####",i-1);" ";a2$
urlfile$= "http://rosettacode.org/wiki/" + a2$ + "#Liberty_BASIC" 'localfile$="RosettaPage.txt" 'result = DownloadToFile(urlfile$, localfile$) CALL GETCODE a2$
if i=2 then ' LIMIT Reps exit while ' CALL GETCODE a2$ end if i = i + 1 a2$ = word$(a1$,i,"<li><a href=";chr$(34);"/wiki/") wend
print "------------ End ---------------------" end
' -------------------------------- ' string replace rep str with ' -------------------------------- FUNCTION strRep$(str$,rep$,with$) ln = len(rep$) ln1 = ln - 1 i = 1 while i <= len(str$) if mid$(str$,i,ln) = rep$ then strRep$ = strRep$ + with$ i = i + ln1 else strRep$ = strRep$ + mid$(str$,i,1) end if i = i + 1 WEND END FUNCTION
SUB GETCODE a2$ Url2get$= "http://rosettacode.org/wiki/" + a2$ + "#Liberty_BASIC"
print " Both Methods seem to be using the same url" print "Using DownloadToFile$ "; urlfile$ print "Using httpget$ "; Url2get$ print : print PRINT "ERROR USING HTTPGET$ " print
result$=httpget$(Url2get$) print result$ 'ERROR THROWN" 'result$=after$(result$,"Category:Liberty BASIC") 'print result$ 'result$=UPTO$(result$,"title=") 'print result$ END SUB
Function DownloadToFile(urlfile$, localfile$) print urlfile$ open "URLmon" for dll as #url calldll #url, "URLDownloadToFileA",_ 0 as long,_ 'null urlfile$ as ptr,_ 'url to download localfile$ as ptr,_ 'save file name 0 as long,_ 'reserved, must be 0 0 as long,_ 'callback address, can be 0 DownloadToFile as ulong '0=success close #url End Function
I get an error:
------------ LB List ----------------- 1 100_doors Both Methods seem to be using the same url Using DownloadToFile$ http://rosettacode.org/wiki/100_doors#Liberty_BASIC Using httpget$ http://rosettacode.org/wiki/100_doors#Liberty_BASIC
ERROR USING HTTPGET$
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head> <title>400 Bad Request</title> <script src="/cdn-cgi/apps/head/7qaJovFEYxjqsAZAxmfekTkNrFg.js"></script></head><body> <h1>Bad Request</h1> <p>Your browser sent a request that this server could not understand.<br /> </p> </body></html> ------------ End ---------------------
|
|
|
Post by sarossell on Feb 21, 2020 20:00:57 GMT -5
Perhaps replace "#" with "%35"? (i.e. httpget$("http://rosettacode.org/wiki/100_doors%35Liberty_BASIC")
I know it doesn't work properly, but it does something more than an error. {shrug}
:@)
[UPDATE]: This is a crap answer. Sorry. I'm still workin' on it though.
[UPDATE]: Oops, the % indicator is looking for a hex value, not a decimal value. So, I tried %23 instead of %35. It just downloaded the entire page though. }:@( Grr.
|
|
|
Post by metro on Feb 21, 2020 20:54:27 GMT -5
[UPDATE]: This is a crap answer. Sorry. I'm still workin' on it though.
I thought I was the only one to master that feat
I'm avoiding using httpget$ for the moment , only using DownloadToFile$ function
|
|
|
Post by sarossell on Feb 21, 2020 21:18:28 GMT -5
LOL. I see a challenge, and my OCD just takes over. If you wanna have a contest for the dumbest answer yet, I got game, Bro! }:@\
|
|
|
Post by sarossell on Feb 21, 2020 21:25:47 GMT -5
|
|
|
Post by sarossell on Feb 21, 2020 21:29:54 GMT -5
If it's any consolation, LB Booster's httpget$ replacement function chokes on it as well. It's using the WININET.DLL.
|
|
|
Post by metro on Feb 21, 2020 21:50:45 GMT -5
So, it appears that using httpget$ might only be able to crab the entire page and then it's up to you to search for the content you're looking for. Probably by looking for id="Liberty_BASIC" or class="lb highlighted_source". :@) httpget$ seems to be choking fullstop using the same link that DownloadTofile$ is using BUT URLmon works. Then I search for some key phrases to find the correct section, from there I can find the LB code. More capable coders will point out my follies and show me a better way. (I hope) I have limited the loop through because of the time it takes to retrieve each page. (it's a start)
global urlfile$
a$ = httpGet$("http://rosettacode.org/wiki/Category:Liberty_BASIC") ' get RB tasks from [RC] a1$ = word$(a$,2,"Pages in category ";chr$(34);"Liberty BASIC") a1$ = word$(a1$,1,"</tr></table>") i = 2 a2$ = word$(a1$,i,"<li><a href=";chr$(34);"/wiki/") ' ' Create a drop down window for selection of a task ' print "------------ LB List -----------------" while a2$ <> "" a2$ = left$(a2$,instr(a2$,chr$(34))-1) a2$ = strRep$(a2$,"%2B","+") a2$ = strRep$(a2$,"%27","'") print using("####",i-1);" ";a2$
urlfile$= "http://rosettacode.org/wiki/" + a2$ + "#Liberty_BASIC" localfile$="RosettaPage.txt" result = DownloadToFile(urlfile$, localfile$) editSection$= GetEditSection$(localfile$) call GETCODE a2$ , editSection$ 'print editSection$
if i=3 then ' LIMIT Reps exit while end if
i = i + 1 a2$ = word$(a1$,i,"<li><a href=";chr$(34);"/wiki/") wend
print "------------ End ---------------------" end
FUNCTION GetEditSection$(localfile$) 'print localfile$ open localfile$ for input as #g alltext$ = input$(#g, lof(#g)) close #g alltext$=after$(alltext$,"Liberty BASIC</a></span>") alltext$=after$(alltext$,"section=") alltext$=upto$(alltext$,"Edit section:") alltext$=upto$(alltext$,chr$(34)) GetEditSection$ = alltext$ END FUNCTION
' -------------------------------- ' string replace rep str with ' -------------------------------- FUNCTION strRep$(str$,rep$,with$) ln = len(rep$) ln1 = ln - 1 i = 1 while i <= len(str$) if mid$(str$,i,ln) = rep$ then strRep$ = strRep$ + with$ i = i + ln1 else strRep$ = strRep$ + mid$(str$,i,1) end if i = i + 1 WEND END FUNCTION
SUB GETCODE a2$ , editSection$ ' checkit$="http://rosettacode.org/mw/index.php?title=100_doors&action=edit§ion=187" 'print checkit$ Url2get$="http://rosettacode.org/mw/index.php?title=";a2$;"&action=edit§ion=";editSection$ result$=httpget$(Url2get$) result$=after$(result$,"lang lb>") result$=upto$(result$,"</lang>") print print result$ END SUB
Function DownloadToFile(urlfile$, localfile$) print urlfile$ open "URLmon" for dll as #url calldll #url, "URLDownloadToFileA",_ 0 as long,_ 'null urlfile$ as ptr,_ 'url to download localfile$ as ptr,_ 'save file name 0 as long,_ 'reserved, must be 0 0 as long,_ 'callback address, can be 0 DownloadToFile as ulong '0=success close #url End Function
|
|