Version 2.1 has been rewritten to use CHOOSE lists rather than keypad menus...
This seems both easier and the program a little more reliable.
The element names are in English, francais and Polskie, but menus have yet to be internationalised.
Code:
LOCAL VERNUM:=2.1;
LOCAL PT:={"Periodic Table V","Okresowy Pierwiastków V","Tableau Périodique V"};
LOCAL SL:=1;
LOCAL LANGS:={"English","Polskie","Français"};
//LOCAL CRID:=PT(SL)+VERNUM+" 2016 StephenG1CMZ ";
LOCAL CRID,PNAME;
LOCAL NL:=CHAR(10);
//LOCAL USEKEYPAD:=PT+NL+"USE KEYPAD, NOT MENU OR TOUCHSCREEN";
//PERIODIC TABLE 02
//FW8151 FW10077
LOCAL HLPTXT;
LOCAL STATNUM:={"Atomic Number","Liczbie atomowe","Les numéro atomique"};
LOCAL STPERIOD:=" P";
LOCAL STGROUP:={"Group","Grupa","Groupe"};
LOCAL STSYMBOL:={"Symbol","symbole","les symboles"};
//PERIODS
//LOCAL APERIODS:={1,3,11,19,37,55,87};
//ELEMENT DATA AND POSITION
//ATOM: 1..118 = LIST POS
//GROUP/COL: 1..18 OR NONE(<0:ARBITRARY FOR DISPLAY ONLY)
//PERIOD/ROW: 1..7
EXPORT Z_ELEMENTS:={
{ 1, 1, 1},
{ 2, 18, 1},
{ 3, 1, 2},
{ 4, 2, 2},
{ 5, 13, 2},
{ 6, 14, 2},
{ 7, 15, 2},
{ 8, 16, 2},
{ 9, 17, 2},
{ 10, 18, 2},
{ 11, 1, 3},
{ 12, 2, 3},
{ 13, 13, 3},
{ 14, 14, 3},
{ 15, 15, 3},
{ 16, 16, 3},
{ 17, 17, 3},
{ 18, 18, 3},
{ 19, 1, 4},
{ 20, 2, 4},
{ 21, 3, 4},
{ 22, 4, 4},
{ 23, 5, 4},
{ 24, 6, 4},
{ 25, 7, 4},
{ 26, 8, 4},
{ 27, 9, 4},
{ 28, 10, 4},
{ 29, 11, 4},
{ 30, 12, 4},
{ 31, 13, 4},
{ 32, 14, 4},
{ 33, 15, 4},
{ 34, 16, 4},
{ 35, 17, 4},
{ 36, 18, 4},
{ 37, 1, 5},
{ 38, 2, 5},
{ 39, 3, 5},
{ 40, 4, 5},
{ 41, 5, 5},
{ 42, 6, 5},
{ 43, 7, 5},
{ 44, 8, 5},
{ 45, 9, 5},
{ 46, 10, 5},
{ 47, 11, 5},
{ 48, 12, 5},
{ 49, 13, 5},
{ 50, 14, 5},
{ 51, 15, 5},
{ 52, 16, 5},
{ 53, 17, 5},
{ 54, 18, 5},
{ 55, 1, 6},
{ 56, 2, 6},
{ 57, −3, 6},
{ 58, −4, 6},
{ 59, −5, 6},
{ 60, −6, 6},
{ 61, −7, 6},
{ 62, −8, 6},
{ 63, −9, 6},
{ 64,−10, 6},
{ 65,−11, 6},
{ 66,−12, 6},
{ 67,−13, 6},
{ 68,−14, 6},
{ 69,−15, 6},
{ 70,−16, 6},
{ 71,−17, 6},
{ 72, 4, 6},
{ 73, 5, 6},
{ 74, 6, 6},
{ 75, 7, 6},
{ 76, 8, 6},
{ 77, 9, 6},
{ 78, 10, 6},
{ 79, 11, 6},
{ 80, 12, 6},
{ 81, 13, 6},
{ 82, 14, 6},
{ 83, 15, 6},
{ 84, 16, 6},
{ 85, 17, 6},
{ 86, 18, 6},
{ 87, 1, 7},
{ 88, 2, 7},
{ 89, −3, 7},
{ 90, −4, 7},
{ 91, −5, 7},
{ 92, −6, 7},
{ 93, −7, 7},
{ 94, −8, 7},
{ 95, −9, 7},
{ 96,−10, 7},
{ 97,−11, 7},
{ 98,−12, 7},
{ 99,−13, 7},
{100,−14, 7},
{101,−15, 7},
{102,−16, 7},
{103,−17, 7},
{104, 4, 7},
{105, 5, 7},
{106, 6, 7},
{107, 7, 7},
{108, 8, 7},
{109, 9, 7},
{110, 10, 7},
{111, 11, 7},
{112, 12, 7},
{113, 13, 7},
{114, 14, 7},
{115, 15, 7},
{116, 16, 7},
{117, 17, 7},
{118, 18, 7},
{119, 3, 3}
};
EXPORT Z_ELEMENTNAMES:={
{ 1,"H", "hydrogen","wodór","hydrogène"},
{ 2,"He", "helium","hel","hélium"},
{ 3,"Li", "lithium","lit","lithium"},
{ 4,"Be", "beryllium","beryl","béryllium"},
{ 5,"B", "boron","bor","boron"},
{ 6,"C", "carbon","węgiel","carbone"},
{ 7,"N", "nitrogen","azot","azote"},
{ 8,"O", "oxygen","tlen","oxygène"},
{ 9,"F", "fluorine","fluor","fluor"},
{ 10,"Ne", "neon","neon","néon"},
{ 11,"Na", "sodium","sód","sodium"},
{ 12,"Mg", "magnesium","magnez","magnésium"},
{ 13,"Al", "aluminium","glin","aluminium"},
{ 14,"Si", "silicon","krzem","silicium"},
{ 15,"P", "phosphorus","fosfor","phosphore"},
{ 16,"S", "sulfur","siarka","soufre"},
{ 17,"Cl", "chlorine","chlore","chlore"},
{ 18,"Ar", "argon","argon","argon"},
{ 19,"K", "potassium","potas","potassium"},
{ 20,"Ca", "calcium","wapń","calcium"},
{ 21,"Sc", "scandium","skand","scandium"},
{ 22,"Ti", "titanium","tytan","titane"},
{ 23,"V", "vanadium","wanad","vanadium"},
{ 24,"Cr", "chromium","chrom","chrome"},
{ 25,"Mn", "manganese","mangan","manganèse"},
{ 26,"Fe", "iron","zelazo","fer"},
{ 27,"Co", "cobalt","kobalt","cobalt"},
{ 28,"Ni", "nickel","nikiel","nickel"},
{ 29,"Cu", "copper","miedź","cuivre"},
{ 30,"Zn", "zinc","cynk","zinc"},
{ 31,"Ga", "gallium","gal","gallium"},
{ 32,"Ge", "germanium","german","germanium"},
{ 33,"As", "arsenic","arsen","arsenic"},
{ 34,"Se", "selenium","selen","sélénium"},
{ 35,"Br", "bromine","brom","brome"},
{ 36,"Kr", "krypton","krypton","krypton"},
{ 37,"Rb", "rubidium","rubid","rubidium"},
{ 38,"Sr", "strontium","stront","strontium"},
{ 39,"Y", "yttrium","itr","yttrium"},
{ 40,"Zr", "zirconium","cyrkon","zirconium"},
{ 41,"Nb", "niobium","niob","niobium"},
{ 42,"Mo", "molybdenum","molibden","molybd=ne"},
{ 43,"Tc", "technetium","technet","technétium"},
{ 44,"Ru", "ruthenium","ruten","ruthénium"},
{ 45,"Rh", "rhodium","rod","rhodium"},
{ 46,"Pd", "palladium","pallad","palladium"},
{ 47,"Ag", "silver","srebro","argent"},
{ 48,"Cd", "cadmium","kadm","cadmium"},
{ 49,"In", "indium","ind","indium"},
{ 50,"Sn", "tin","cyna","étain"},
{ 51,"Sb", "antimony","antymon","antimoine"},
{ 52,"Te", "tellurium","tellur","tellure"},
{ 53,"I", "iodine","jod","iode"},
{ 54,"Xe", "xenon","ksenon","xénon"},
{ 55,"Cs", "caesium","cez","césium"},
{ 56,"Ba", "barium","bar","baryum"},
{ 57,"La", "lanthanum","lantan","lanthane"},
{ 58,"Ce", "cerium","cer","cérium"},
{ 59,"Pr", "praseodymium","prazeodym","praséodyne"},
{ 60,"Nd", "neodymium","neodym","néodyme"},
{ 61,"Pm", "promethium","promet","prométhium"},
{ 62,"Sm", "samarium","samar","samarium"},
{ 63,"Eu", "europium","europ","europium"},
{ 64,"Gd", "gadolinium","gadolin","gadolinium"},
{ 65,"Tb", "terbium","terb","terbium"},
{ 66,"Dy", "dysprosium","dyspoz","dysprosium"},
{ 67,"Ho", "holmium","holm","holmium"},
{ 68,"Er", "erbium","erb","erbium"},
{ 69,"Tm", "thulium","tul","thulium"},
{ 70,"Yb", "ytterbium","iterb","ytterbium"},
{ 71,"Lu", "lutetium","lutet","lutécium"},
{ 72,"Hf", "hafnium","hafn","hafnium"},
{ 73,"Ta", "tantalum","tantal","tantale"},
{ 74,"W", "tungsten","wolfram","tungstène"},
{ 75,"Re", "rhenium","ren","rhénium"},
{ 76,"Os", "osmium","osm","osmium"},
{ 77,"Ir", "iridium","iryd","iridium"},
{ 78,"Pt", "platinum","platyna","platine"},
{ 79,"Au", "gold","zloto","or"},
{ 80,"Hg", "mercury","rtęć","mercure"},
{ 81,"Ti", "thallium","tal","thallium"},
{ 82,"Pb", "lead","ołów","plomb"},
{ 83,"Bi", "bismuth","bizmut","bismuth"},
{ 84,"Po", "polonium","polon","polonium"},
{ 85,"At", "astatine","astat","astate"},
{ 86,"Rn", "radon","radon","radon"},
{ 87,"Fr", "francium","frans","francium"},
{ 88,"Ra", "radium","rad","radium"},
{ 89,"Ac", "actinium","aktyn","actinium"},
{ 90,"Th", "thorium","tor","thorium"},
{ 91,"Pa", "protactinium","proaktyn","protactinium"},
{ 92,"U", "uranium","uran","uranium"},
{ 93,"Np", "neptunium","neptun","neptunium"},
{ 94,"Pu", "plutonium","pluton","plutonium"},
{ 95,"Am", "americium","ameryk","américum"},
{ 96,"Cm", "curium","kiur","curium"},
{ 97,"Bk", "berkelium","bekerel","berkélium"},
{ 98,"Cf", "californium","kaliforn","californium"},
{ 99,"Es", "einsteinium","einstein","einsteinium"},
{100,"Fm", "fermium","ferm","fermium"},
{101,"Md", "mendelevium","mendelew","mendélévium"},
{102,"No", "nobelium","nobel","nobelium"},
{103,"Lr", "lawrencium","lorens","lawrencium"},
{104,"Rf", "rutherfordium","rutherford","rutherforium"},
{105,"Db", "dubnium","dubn","dubnium"},
{106,"Sg", "seaborgium","seaborg","seaborgium"},
{107,"Bh", "bohrium","bohr","bohrium"},
{108,"Hs", "hassium","has","hassium"},
{109,"Mt", "meitnerium","meitner","meitnérium"},
{110,"Ds", "darmstadtium","darmsztadt","darmstadtium"},
{111,"Rg", "roentgenium","roentgen","roentgenium"},
{112,"Cn", "copernicium","kopernik","copernicium"},
{113,"Uut","ununtrium","ununtrium","ununtrium"},
{114,"Fl", "flerovium","flerovium","flerovium"},
{115,"Uue","ununpentium","ununpentium","ununpentium"},
{116,"Lv", "livermorium","livermorium","livermorium"},
{117,"Uus","ununseptium","ununseptium","ununseptium"},
{118,"Uuo","ununoctium","ununoctium","ununoctium"},
{119,"**", "NOT FOUND","nie znaleziono","PAS TROUVÉ"}
};
LOCAL OFFSETL:=2;
LOCAL SHO_P:=0;
LOCAL NELE:=SIZE(Z_ELEMENTS)-1;
LOCAL NGRPS:=18;//MAX(GROUPS)
LOCAL NPRDS:= 7;//MAX(PERIODS)
LOCAL NCOLS:=NGRPS+SHO_P;
LOCAL NROWS:=NPRDS+2+1;//2 EXTRA ROWS
LOCAL COLSZ:=IP(320/NCOLS);
LOCAL ROWSZ:=IP(220/NROWS/2);//2 LINES PER ROW
LOCAL FONTSZ:=1;//1..7 1..2
LOCAL MNUTXT,MNUACT;
LOCAL EL,ELSYM,APRD,DPRD,LGRP,DGRP;
LOCAL II,KK,ML,LOC;
LOCAL BOXED;
LOCAL LSYM,LELE;
LOCAL SY:="";
LOCAL CHS;
MSNK()
BEGIN
LOCAL SNK:=MOUSE();
END;//NOT IN USE
DRW_ELE_BOX(LPOS,ONE,TWO)
BEGIN
LOCAL LMG:=6;//
LOCAL LW:=1;//LINEWIDTH:KEEP TEXT OFF BOXLINE
LOCAL DGRP:=MAX(LPOS(1)-1,0);//TRY
LOCAL DPRD:=LPOS(2);
LOCAL XX:=IP(DGRP*COLSZ)+LMG;
LOCAL YY:=IP(2*DPRD*ROWSZ);
//OMIT U ON SMALL SCREENS)
LOCAL THREE:=IFTE(DIM(TWO)==3 AND GROBW_P()<640,MID(TWO,2),TWO);
IF BOXED THEN
RECT_P(XX,YY,XX+COLSZ,YY+2*ROWSZ,#0,#EEEEEE);//BLACK EDGE GREY FILL
END;
//LINES 1 AND 2
TEXTOUT_P(ONE,XX,YY+LW,FONTSZ);
//RECT_P(0,2*8*ROWSZ,2*COLSZ+LMG,240,#0,#FF);
TEXTOUT_P(THREE,XX+LW,IP((2*DPRD+1)*ROWSZ)+LW,FONTSZ);
//AND CORNER BIGGER
RECT_P(LMG,2*8*ROWSZ+LW,2*COLSZ+LMG-LW,GROBH_P()-20);
TEXTOUT_P(ONE,LMG,2*8*ROWSZ+LW,3);
TEXTOUT_P(TWO,LMG,(2*9)*ROWSZ+LW,3);///THIS
END;
POS_ELE_BOX(EL)
BEGIN
LOCAL LGRP:=Z_ELEMENTS(EL,2);
LOCAL DGRP:=ABS(LGRP);
LOCAL APRD:=Z_ELEMENTS(EL,3);
LOCAL DPRD:=IFTE(LGRP<0,APRD+2,APRD);//8 AND 9 ARE 2 BELOW W AND 7
RETURN {DGRP,DPRD};
END;
DRWNAME(ST)
BEGIN
TEXTOUT_P(ST,2*COLSZ,2*ROWSZ,7);
END;
DrawPeriodicTable()
BEGIN
RECT();
BOXED:=0;
TEXTOUT_P(PNAME+CRID,5,2,FONTSZ);//DRW_ELE_BOX({0,0},CRID,"");
FOR II FROM 1 TO NGRPS DO
DRW_ELE_BOX({II,0},"",II);
END;
FOR II FROM 1 TO NPRDS DO
DRW_ELE_BOX({0,II},"","P"+II);
END;
//THESE NAMES WONT BE SEEN WITHOUT ADDING A DELAY OR REPOSITIONING
DRW_ELE_BOX({4,8},"lanthanoids","");
DRW_ELE_BOX({4,9},"actinoids","");
ML:=0;PRINT();
DRW_ELE_BOX({3,7}," ⇊","");
BOXED:=1;
FOR EL FROM 1 TO NELE DO
//GETSYMBOL:LONGER NAMES LOSE THE "U" ON SMALL SCREEN
ELSYM:=Z_ELEMENTNAMES(EL,2);
//DRAW
DRW_ELE_BOX(POS_ELE_BOX(EL),EL,ELSYM);
END;
END;
DRAW_AN_ELE()
BEGIN
//IF ML THEN
RECT_P(0,0,320,220);
//IF ML THEN
//TEXTOUT_P("More: use keys:",0,0,FONTSZ);
//TEXTOUT_P(MNU,320/4,0);
IF ML THEN
//BOXED:=0;
//TEXTOUT_P(Z_ELEMENTNAMES(EL,3),3*COLSZ,3*ROWSZ,7);
//BOXED:=1;
LOC:="";
IF EL≤NELE THEN //IF FOUND
LOC:=STPERIOD+Z_ELEMENTS(EL,3);
LOC:=IFTE(Z_ELEMENTS(EL,2)>0,STGROUP(SL)+Z_ELEMENTS(EL,2)+","+LOC,LOC);
LOC:="("+LOC+")";
DRW_ELE_BOX(POS_ELE_BOX(EL),EL,Z_ELEMENTNAMES(EL,2));
END;
DRWNAME(Z_ELEMENTNAMES(EL,OFFSETL+SL)+LOC);
ELSE
DRWNAME(Z_ELEMENTNAMES(NELE+1,OFFSETL+SL));
END;
END;
ENTER_ELE_SYM()
BEGIN
ML:=INPUT({{SY,[2]}},"Enter element name or Symbol");//FW8151 AND FW10077
// THANKS TYANN AND SALVOMIC. 2==STRINGTYPE
//
IF ML THEN
EL:=1;
WHILE EL≤NELE AND SY≠Z_ELEMENTNAMES(EL,2) AND SY≠Z_ELEMENTNAMES(EL,OFFSETL+SL) DO
EL:=EL+1;
END;//WHILE
//RECT_P(0,0,320,220);
//DRW_ELE_BOX(POS_ELE_BOX(EL),EL,Z_ELEMENTNAMES(EL,2));
//DRWNAME(Z_ELEMENTNAMES(EL,3));
//WAIT;
//END;
DRAW_AN_ELE();
END;//IF
END;
ListSymbols()
BEGIN
LSYM:={};
FOR EL FROM 1 TO NELE DO
LSYM:=CONCAT(LSYM,EL+" "+Z_ELEMENTNAMES(EL,2));
END;
EL:=1;
ML:=CHOOSE(EL,STSYMBOL(SL),LSYM);
DRAW_AN_ELE();
END;
ListAtomicNumbers()
BEGIN
LSYM:={};
FOR EL FROM 1 TO NELE DO
LSYM:=CONCAT(LSYM,EL+" "+Z_ELEMENTNAMES(EL,2)+" "+Z_ELEMENTNAMES(EL,OFFSETL+SL));
END;
EL:=1;
ML:=CHOOSE(EL,STATNUM(SL),LSYM);
DRAW_AN_ELE();
END;
LITTLE()
BEGIN
//PRINT();
//DIAGNOSTIC:LONGEST NAME FOR DISPLAY SIZING
ML:=0;
FOR II FROM 1 TO NELE DO
ML:=MAX(ML,DIM(Z_ELEMENTNAMES(II,2+SL)));
END;
MSGBOX("LONGEST NAME LENGTH:"+ML);
FOR II FROM 1 TO NELE DO
IF ML==SIZE(Z_ELEMENTNAMES(II,2+SL)) THEN
//PRINT(Z_ELEMENTNAMES(II,2+SL));
EL:=II;
DRAW_AN_ELE();
END;
END;
//TEXTOUT_P(Z_ELEMENTNAMES(104,3),0,220,FONTSZ);//13CH
WAIT;
END;
TITLES()
BEGIN
PNAME:=PT(SL)+VERNUM;
CRID:=" 2016 StephenG1CMZ";
HLPTXT:=PNAME+NL+CRID+NL+"THANKS SALVOMIC AND TYANN";
END;
Lang()
BEGIN
ML:=CHOOSE(SL,STRING(LANGS),LANGS);
IF ML THEN
MSGBOX(LANGS(SL));
END;
END;
INTRO()
BEGIN
DrawPeriodicTable();
//TEXTOUT_P("ANY",0,320-20,2);
WAIT;
END;
CHOOSER()
BEGIN
LOCAL TTL;
LOCAL MNU:={"HELP()","DrawPeriodicTable()","ENTER_ELE_SYM()","ListAtomicNumbers()","ListSymbols()","LITTLE()","Lang()"};
LOCAL MNUACT:=MNU;
LOCAL MNUTXT:=MNU;
REPEAT
TITLES();
TTL:=PNAME;
ML:=CHOOSE(CHS,TTL,MNUTXT);
IF ML THEN
EXPR(MNUACT(CHS));
WAIT;
END;
UNTIL ML==0;
END;
HELP()
BEGIN
MSGBOX(HLPTXT);
END;
EXPORT Z_PERIODIC_TABLE02_1()
BEGIN
TITLES();
INTRO();
CHOOSER();
//DRAWMENU(MNU);
//PRINT("BYE");
//NOTE:THE ALTERNATIVE OF SHOWING 3CHAR SYMBOLS BY
//BLITTING THE LOWERLEFT BOX IS MUCH LESS LEGIBLE THN
//OMITTING THE 1ST U
FREEZE;
// TBD
// LIST BY ELEMENT NAME
// LIST SEARCH IN ANY LANG NOT 1BY1
// PARTIAL MATCHES
END;