Τρίτη 31 Μαρτίου 2020

Revision 17, Version 9.9

From revision 18 change the file. slight. Instead of use of "'" now use "!" for accurate search operation.  Inside info there is a module name MAKEHELP with the updated version.
Also there is an EXPORTHELPNEW which export Greek or English help (ask to press G pr E). First import to a 2D array and make a sort on columns using first key on groups and second key on identifiers.

The mEditor in Info which is a GUI editor for M2000 programs, use two EditBoxes, one for editing the code and another for viewing topics from help.So the program updated to use either of help files, mdb and dat (the dat file is a text file in UTF8 format, where the memo field is one line using escape codes like \c\n for CRLF)


New Help File. (Not used any more, see above)
 greek$="\"+ALL(i)#val$(0)+"'"+str$(ALL(i)#val(3),"")+
 english$="\"+ALL(i)#val$(2)+"'"+str$(ALL(i)#val(3),"")+
change to that (check the ! char)
 greek$="\"+ALL(i)#val$(0)+"!"+str$(ALL(i)#val(3),"")+
 english$="\"+ALL(i)#val$(2)+"!"+str$(ALL(i)#val(3),"")+


We can use the mdb (Access 2007 file)  using switch "+mdb". By default now Interpreter use a dat file, A utf8 file including all help base, only for reading.

We can make the dat file from mdb using this program. To work this program we have to copy Help2000.mdb ro user folder (open with the statement Win Dir$) We get the export to the same folder


Module MakeHelp {
 pen 14 : cls 5
 flush
 \\DIR APPDIR$ \\  from installation folder use this
 Retrieve "HELP2000","GROUP", 1,"",""
 Read many
 Flush
 Dim Labels$(1 to 25), ser(1 to many)
 For i=1 to many
 Retrieve "HELP2000","GROUP", i,"",""
 drop
 Read where, Labels$(where)
 ser(i)=where
 flush
 next i
 Retrieve  "HELP2000", "SELECT * FROM COMMANDS",1,"",""
 Read many
 dim ALL(1 to many)
 Document infoGr$, Info$, greek$, english$
 br$={__<ENG>__
 }
 nl$=string$({
 } as json )
 p1=1
 for i=1 to many
 Retrieve  "HELP2000", "SELECT * FROM COMMANDS",i,"",""
 drop
 ALL(i)=Array([])
 Print ALL(i)#val$(2), rightpart$(Labels$(ALL(i)#val(3)), ","+chr$(160))
 Print ALL(i)#val$(0), leftpart$(Labels$(ALL(i)#val(3)), ","+chr$(160))
 greek$="\"+ALL(i)#val$(0)+"'"+str$(ALL(i)#val(3),"")+{
 }
 english$="\"+ALL(i)#val$(2)+"'"+str$(ALL(i)#val(3),"")+"-"+Str$(i)
 if i<many then
  english$={
  }
 end if
 infoone$="GR:"+ALL(i)#val$(0)+nl$+string$(rightpart$(ALL(i)#val$(1), br$) as json)
 info$=infoone$+{
 }
 infoone$="EN:"+ALL(i)#val$(2)+nl$+string$(leftpart$(ALL(i)#val$(1), br$) as json)
 infoGR$=infoone$+{
 }
 next
 Method english$, "SetLocaleCompare", 1033
 Method english$, "SetBinaryCompare"
 Sort english$
 Dir User   \\ open this using Win Dir$
 open "Help2000.dat" for wide output as #k
 Print #k, Len(Labels$())
 for i=1 to len(Labels$())
  Print #k, Labels$(i)
 next i
 Print #k, Many
 Print #k, infoGr$;info$;greek$;english$
 close #k
 clear
 Document ALL$, all1$
 Load.doc ALL$, "help2000.dat"
 print filelen("help2000.dat")
 save.doc all$,"help2000utf8.dat", 2   ' utf-9
 print filelen("help2000utf8.dat")
}
MakeHelp


We can also read the file using M2000 code

also here change
   Print leftpart$(Ret$,"'")
   lbl=Val(Rightpart$(Ret$,"'"))
to

   Print leftpart$(Ret$,"!")
   lbl=Val(Rightpart$(Ret$,"!"))

The search is serial but very fast. We can find with little letters. eg THR  return THREAD. We can use it for Greek and English identifiers. Write ALL to get all the identifiers.

Module ReadHelp {
 flush
 Document ALL$
 Load.doc ALL$, "help2000utf8.dat"
 A=Val(paragraph$(ALL$, 1))
 B=Val(paragraph$(ALL$, 2+A))
 Find ALL$, paragraph$(ALL$,2+A+1+2*B)
 Read where, no_par, bb
 Find ALL$, paragraph$(ALL$,2+A+1+3*B), where
 drop : read no_par2
 flush
 do
  Input "give a name OR - TO EXIT:", aName$
  if aName$="-" then exit
  if aName$="" then continue
  Find ALL$, "\"+ucase$(aName$), where
  Read Where1
  if Where1>0 then
   read  There : drop
   Ret$=mid$( Paragraph$(ALL$, There), 2)
   Print Ret$
   Print leftpart$(Ret$,"'")
   lbl=Val(Rightpart$(Ret$,"'"))
   info=Val(Rightpart$(Ret$,"-"))
   if info=0 then
    Print lbl
    Print LeftPart$(Paragraph$(All$,lbl+1), ", ")
    Report format$(paragraph$(ALL$,2+A+1+There-no_par))
   else
    Print lbl, info
    Print RightPart$(Paragraph$(All$,lbl+1), ", ")
    Report format$(paragraph$(ALL$,2+A+B+info))
   end if
  end if
  flush
 Always
}
ReadHelp

Installation file now has this file help2000utf8.dat and not Help2000.mdb. You can find mdb file in Github here https://github.com/M2000Interpreter/Version9/blob/master/help2000.mdb

Δεν υπάρχουν σχόλια:

Δημοσίευση σχολίου

You can feel free to write any suggestion, or idea on the subject.