|
Post by Rod on Feb 24, 2020 4:06:45 GMT -5
That works really well and shows the potential. I assume this is a list of completed tasks. So two things missing, a run button and a description of the task. Third thing to think through is how to show incomplete tasks.
What do you want to store locally? Since my internet access is fast I have no need. Provided RC is up I can grab whatever I want almost instantly.
If folks are on a slower download I assume you want to store the list, and downloaded info / code in a cache? Then your gui needs to check the cache or go for a download.
Don't know the answer to these questions or even if they are the right questions. If anyone has ideas about how the project should build speak now. A wish list if you will.
|
|
|
Post by metro on Feb 24, 2020 5:49:59 GMT -5
Thanks Rod,
All tasks completed or not are currently showing.
incomplete tasks ... at this stage I have just used a "Notice" to show no code returned I guess to find all tasks with no code I could scroll through all tasks and build a report. I will leave local storage alone for now. any other suggestions welcome. I have also just updated the code in my previous post rather than post here the program now downloads all languages and will find associated tasks once the language list is updated from the button click double click on your language of choice and then your task of choice to get stored code
|
|
|
Post by meerkat on Feb 24, 2020 10:39:57 GMT -5
g'day laurie.. Or as we say here in the west. Howdy Y'all!
Only has a little time to look at this so, not exactly sure what's needed here.
I hate to post RB code here, but it may be of some use. I wrote a program a long time ago in RB ,for my personal use, that may be doing some of what your's after.. It list all tasks even if none of the languages you selected have no code. You set the languages in the langs$ = section of the code below.
It produces a cross ref list of task and languages. You select any language from the list and it shows you the code for that task and language. Kinda crude since I only list the code at the end of the cross ref. I should put it in another browser tab. If anyone is interested I could do that.
For whatever it may be worth.. Here is the code:
sqliteconnect #mem, ":memory:"
mem$ = "CREATE TABLE lng (langNum int(2),lang text);CREATE UNIQUE INDEX lngNum ON lng(langNum);" #mem execute(mem$) mem$ = "CREATE TABLE tsk(taskNum int(4),task text);CREATE UNIQUE INDEX tskNum ON tsk(taskNum);" #mem execute(mem$) mem$ = "CREATE TABLE xref(taskNum int(1),langNum int(2));CREATE UNIQUE INDEX xrf ON xref(taskNum,langNum);" #mem execute(mem$)
bf$ = "<SPAN STYLE='font-family:Arial; font-weight:700; font-size:10pt'>" ' ==================== ' supply Languages ' must match names in [RC] ' ==============================" langs$ = "Liberty_BASIC|Run_BASIC|Visual_Basic_.NET|Visual_Basic|TI-83_BASIC|Basic|TI-89_BASIC|BBC_BASIC" for i = 1 to len(langs$) lang$ = word$(langs$,i,"|") if lang$ = "" then exit for numLang = i mem$ = "INSERT INTO lng VALUES(";i;",'";lang$;"')" print numLang;chr$(9);lang$ #mem execute(mem$) next i
' -------------------------------- ' find all task ' -------------------------------- print "============= Tasks ================" a$ = httpGet$("http://rosettacode.org/wiki/Category:Programming_Tasks") i = instr(a$,"<h2>Pages in category ";chr$(34);"Programming Tasks";chr$(34);"</h2>") srch$ = "<li><a href=";chr$(34);"/wiki/" ln = len(srch$) for nt = 1 to len(a$) i = instr(a$,srch$,i+1) if i = 0 then exit for x$ = mid$(a$,i+ln,100) thisTask$ = word$(x$,1,chr$(34)) mem$ = "INSERT into tsk VALUES(";nt;",'";thisTask$;"')" #mem execute(mem$) next nt
' ----------------------------------------- ' Find all task each language does ' ---------------------------------------- on error goto [nxtLang] ii = 1
[tryAgain] for i = ii to numLang lang$ = word$(langs$,i,"|") print "Finding Task for language:";lang$ hget$ = "http://rosettacode.org/wiki/Category:";lang$ a$ = httpGet$(hget$) mem$ = "SELECT * FROM tsk" #mem execute(mem$) WHILE #mem hasanswer() #mrow = #mem #nextrow() taskNum = #mrow taskNum() task$ = #mrow task$() if instr(a$,task$) > 0 then xref$ = xref$ + "(";taskNum;",";i;"),";chr$(13) WEND next i xref$ = left$(xref$,len(xref$)-2) mem$ = "INSERT INTO xref VALUES";xref$ #mem execute(mem$)
input "Return to continue";a$ cls html bf$;"<TABLE BORDER=1 CELLPADDING=0 CELLSPACING=0><TR BGCOLOR=silver align=center>" html "<TD>Num</TD><TD>Task</TD><TD>" hdr$ = strRep$(langs$,"_","<BR>") hdr$ = strRep$(hdr$,"|","</td><td>") html hdr$;"</td>"
preTaskNum = -1 mem$ = "SELECT tsk.taskNum as taskNum, tsk.task as task, xref.taskNum as xtaskNum, xref.langNum as xlangNum FROM tsk,xref WHERE xref.taskNum = tsk.taskNum ORDER BY tsk.task,xref.langNum" #mem execute(mem$) WHILE #mem hasanswer() #mrow = #mem #nextrow() taskNum = #mrow taskNum() task$ = #mrow task$() xtaskNum = #mrow xtaskNum() xlangNum = #mrow xlangNum() if preTaskNum <> taskNum then html "</TR><TR><TD align=right>";taskNum;"</TD><TD>";task$;"</TD>" ii = 2 end if for ii = ii to xlangNum html "<TD></TD>" next ii ii = xlangNum + 2 html "<TD align=center>" button #c, "X", [shoCode] #c setkey(str$(taskNum);"|";str$(xlangNum)) html "</TD>" preTaskNum = taskNum WEND html "</TR></TABLE>"
print "------- Thats all folks ---------" wait [shoCode] print EventKey$ taskNum$ = word$(EventKey$,1,"|") mem$ = "SELECT * FROM tsk WHERE taskNum = ";taskNum$;" LIMIT 1" #mem execute(mem$) WHILE #mem hasanswer() #mrow = #mem #nextrow() taskNum = #mrow taskNum() task$ = #mrow task$() langNum$ = word$(EventKey$,2,"|") langNum = val(langNum$) lang$ = word$(langs$,langNum,"|") print "WE HAVE:";taskNum;" ";task$;" ";lang$ a$ = httpGet$("http://rosettacode.org/wiki/";task$;"#";lang$) i = instr(a$,"<a href=";chr$(34);"#";lang$) i = i -10 i = instr(a$,"n-",i) x$ = mid$(a$,i+2,15) sect$ = word$(x$,1,chr$(34)) 'print i;" ";x$;"-->";sect$ a$ = httpGet$("http://rosettacode.org/mw/index.php?title=";task$;"&action=edit§ion=";sect$) 'print a$ print "============== Code for task ";task$;" language:";lang$;" ========================" a1$ = word$(a$,2,"<lang lb>") code$ = word$(a1$,1,"</lang>") print code$ WEND wait
' --------------------------------------------------- [nxtLang] print "No programs found for language:";lang$ ii = i + 1 goto [tryAgain]
' -------------------------------- ' 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
hope this helps.. Dan
|
|
|
Post by metro on Feb 24, 2020 19:03:32 GMT -5
Thanks Dan, some useful tips there, I appreciate it Y'all come back now ya hear! Laurie
|
|
|
Post by pierre on Mar 27, 2020 16:04:03 GMT -5
Re: Rosetta Code Aggregator, Last Edit: Feb 25, 2020 at 1:01am by metro
You should have kept the listbox instead of replacing it by a combobox.
in the GUI objects code: unquote the line listbox #main.combo1 allLangs$() quote the line Combobox #main.combo1 allLangs$()
in the SUB GETLANGS handle$ : unquote the line #main.combo1, "select ";"Liberty BASIC"
run the program: click on "update languages" The Liberty BASIC name comes up, already highlighted double click on it and here you are !
PS I found a strange bug in the httpget$ function: in the text of all the Rosetta code tasks, the character "<" (without the quotes) comes back in its HTLM form "<" (without the quotes). On the Rosetta Code site, it reads normally "<" (without the quotes).
|
|
|
Post by metro on Mar 27, 2020 20:21:17 GMT -5
Re: Rosetta Code Aggregator, Last Edit: Feb 25, 2020 at 1:01am by metro
You should have kept the listbox instead of replacing it by a combobox.
in the GUI objects code: unquote the line listbox #main.combo1 allLangs$() quote the line Combobox #main.combo1 allLangs$()
in the SUB GETLANGS handle$ : unquote the line #main.combo1, "select ";"Liberty BASIC" Call listbox2DoubleClick handle$ 'change made run the program: click on "update languages" The Liberty BASIC name comes up, already highlighted double click on it and here you are ! pierre, thank you for your observations. I did leave the code for both options but did not include a call to the LoadTasks Sub which is necessary if you don't want to initially be making the language choice twice. Because the pre-"select" option of LibertyBASIC does not trigger the combobox event. EDIT: changed code to call "listbox2DoubleClick " which is now a sub so the default choice of LibertyBASIC language will also load the associated tasks
|
|
|
Post by pierre on Mar 28, 2020 4:32:59 GMT -5
Thanks Metro. It works fine.
By the way, did you mention that unexpected behaviour of httpget$ ? You may verify it in the code of the 15_Puzzle_Game I just downloaded with the updated version of your program. The error is occurring 9 times in the code.
For example, in the function introAndLevel(), it reads : loop while (level < 1) or (level > 3).
On the Rosetta Code site, you can see the correct line : loop while (level < 1) or (level > 3). I found out that < is the HTLM code of the character < Strange, isn't it ?
|
|
|
Post by metro on Mar 28, 2020 6:00:33 GMT -5
Thanks Metro. It works fine.
By the way, did you mention that unexpected behaviour of httpget$ ? You may verify it in the code of the 15_Puzzle_Game I just downloaded with the updated version of your program. The error is occurring 9 times in the code.
For example, in the function introAndLevel(), it reads : loop while (level < 1) or (level > 3).
On the Rosetta Code site, you can see the correct line : loop while (level < 1) or (level > 3). I found out that < is the HTLM code of the character < Strange, isn't it ?
Yep, of course that's not where I'm getting the actual code from. So I may have to re-think how to tackle the issue of course if its the only anomaly I can just REPLSTR$() the characters!
The only way I found to get the LB code (well any language really) was to scrape the edit page, smarter people may have other ways
take a look at the source I get the code from (above link), you will see I get what is displayed there
so right click and view source of the above link... the problem is there...(Ctrl + F and search for MOD 4 ) maybe one of the HTML guru's can help me here
EDIT : fixed " I found out that < is the HTLM code of the character <" "using ..... GETCODE$= REPLSTR$(result$,"<","<") ' result$ not sure if that impacts other languages at this stage
|
|
|
Post by pierre on Mar 28, 2020 7:23:11 GMT -5
Yes, thanks metro.
following the link you provided I saw the edit page on the Rosetta Code site and the character < is displayed correctly there.
and yes, it seems to affect all languages, that is why I suspected httpget$.
Your fix works for all languages, so that is o.k.
|
|
|
Post by metro on Mar 28, 2020 17:55:48 GMT -5
following the link you provided I saw the edit page on the Rosetta Code site and the character < is displayed correctly there.
and yes, it seems to affect all languages, that is why I suspected httpget$.
I do have an innate propensity to misunderstand most things straight up so forgive me . If you right click on the page that displays the character correctly and view the source, which I understand I am getting with httpget$ you will see the source has in fact the HTML characters. So is the issue with Rosetta and the way code is stored?
Our browsers are displaying it correctly because they recognize the characters as <
|
|
|
Post by pierre on Mar 29, 2020 2:58:38 GMT -5
OK thanks. I didn't know that.
|
|