Following last weeks announcement in the media that the discovery of new elements has been confirmed, I thought I would make a simple periodic table. This one fits on one page, unlike some that need scrolling. And it works on the Android emulation.
There is some limited interaction, but the user interface does need more work.
Code:
//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}
};
EXPORT Z_ELEMENTNAMES:={
{ 1,"H", "hydrogen"},
{ 2,"He", "helium"},
{ 3,"Li", "lithium"},
{ 4,"Be", "beryllium"},
{ 5,"B", "boron"},
{ 6,"C", "carbon"},
{ 7,"N", "nitrogen"},
{ 8,"O", "oxygen"},
{ 9,"F", "fluorine"},
{ 10,"Ne", "neon"},
{ 11,"Na", "sodium"},
{ 12,"Mg", "magnesium"},
{ 13,"Al", "aluminium"},
{ 14,"Si", "silicon"},
{ 15,"P", "phosphorus"},
{ 16,"S", "sulfur"},
{ 17,"Cl", "chlorine"},
{ 18,"Ar", "argon"},
{ 19,"K", "potassium"},
{ 20,"Ca", "calcium"},
{ 21,"Sc", "scandium"},
{ 22,"Ti", "titanium"},
{ 23,"V", "vanadium"},
{ 24,"Cr", "chromium"},
{ 25,"Mn", "manganese"},
{ 26,"Fe", "iron"},
{ 27,"Co", "cobalt"},
{ 28,"Ni", "nickel"},
{ 29,"Cu", "copper"},
{ 30,"Zn", "zinc"},
{ 31,"Ga", "gallium"},
{ 32,"Ge", "germanium"},
{ 33,"As", "arsenic"},
{ 34,"Se", "selenium"},
{ 35,"Br", "bromine"},
{ 36,"Kr", "krypton"},
{ 37,"Rb", "rubidium"},
{ 38,"Sr", "strontium"},
{ 39,"Y", "yttrium"},
{ 40,"Zr", "zirconium"},
{ 41,"Nb", "niobium"},
{ 42,"Mo", "molybdenum"},
{ 43,"Tc", "technetium"},
{ 44,"Ru", "ruthenium"},
{ 45,"Rh", "rhodium"},
{ 46,"Pd", "palladium"},
{ 47,"Ag", "silver"},
{ 48,"Cd", "cadmium"},
{ 49,"In", "indium"},
{ 50,"Sn", "tin"},
{ 51,"Sb", "antimony"},
{ 52,"Te", "tellurium"},
{ 53,"I", "iodine"},
{ 54,"Xe", "xenon"},
{ 55,"Cs", "caesium"},
{ 56,"Ba", "barium"},
{ 57,"La", "lanthanum"},
{ 58,"Ce", "cerium"},
{ 59,"Pr", "praseodymium"},
{ 60,"Nd", "neodymium"},
{ 61,"Pm", "promethium"},
{ 62,"Sm", "samarium"},
{ 63,"Eu", "europium"},
{ 64,"Gd", "gadolinium"},
{ 65,"Tb", "terbium"},
{ 66,"Dy", "dysprosium"},
{ 67,"Ho", "holmium"},
{ 68,"Er", "erbium"},
{ 69,"Tm", "thulium"},
{ 70,"Yb", "ytterbium"},
{ 71,"Lu", "lutetium"},
{ 72,"Hf", "hafnium"},
{ 73,"Ta", "tantalum"},
{ 74,"W", "tungsten"},
{ 75,"Re", "rhenium"},
{ 76,"Os", "osmium"},
{ 77,"Ir", "iridium"},
{ 78,"Pt", "platinum"},
{ 79,"Au", "gold"},
{ 80,"Hg", "mercury"},
{ 81,"Ti", "thallium"},
{ 82,"Pb", "lead"},
{ 83,"Bi", "bismuth"},
{ 84,"Po", "polonium"},
{ 85,"At", "astatine"},
{ 86,"Rn", "radon"},
{ 87,"Fr", "francium"},
{ 88,"Ra", "radium"},
{ 89,"Ac", "actinium"},
{ 90,"Th", "thorium"},
{ 91,"Pa", "protactinium"},
{ 92,"U", "uranium"},
{ 93,"Np", "neptunium"},
{ 94,"Pu", "plutonium"},
{ 95,"Am", "americium"},
{ 96,"Cm", "curium"},
{ 97,"Bk", "berkelium"},
{ 98,"Cf", "californium"},
{ 99,"Es", "einsteinium"},
{100,"Fm", "fermium"},
{101,"Md", "mendelevium"},
{102,"No", "nobelium"},
{103,"Lr", "lawrencium"},
{104,"Rf", "rutherfordium"},
{105,"Db", "dubnium"},
{106,"Sg", "seaborgium"},
{107,"Bh", "bohrium"},
{108,"Hs", "hassium"},
{109,"Mt", "meitnerium"},
{110,"Ds", "darmstadtium"},
{111,"Rg", "roentgenium"},
{112,"Cn", "copernicium"},
{113,"Uut","ununtrium"},
{114,"Fl", "flerovium"},
{115,"Uue","ununpentium"},
{116,"Lv", "livermorium"},
{117,"Uus","ununseptium"},
{118,"Uuo","ununoctium"}
};
LOCAL SHO_P:=0;
LOCAL NELE:=SIZE(Z_ELEMENTS);
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 MNU:={"Symb","Enter","Num"};
LOCAL EL,ELSYM,APRD,DPRD,LGRP,DGRP;
LOCAL II,KK,ML;
LOCAL BOXED;
LOCAL LSYM,LELE;
LOCAL SY:="";
MSNK()
BEGIN
LOCAL SNK:=MOUSE();
END;
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);
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,3*COLSZ,3*ROWSZ,7);
END;
EXPORT Z_PERIODIC_TABLE()
BEGIN
RECT();
BOXED:=0;
DRW_ELE_BOX({0,0},"Software by StephenG1CMZ 2016. Any work?","");
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();
//DIAGNOSTIC:LONGEST NAME FOR DISPLAY SIZING
//FOR II FROM 1 TO NELE DO
// ML:=MAX(ML,DIM(Z_ELEMENTNAMES(II,3)));
//END;
//PRINT("LONGESTNAME LENGTH:"+ML);
//TEXTOUT_P(Z_ELEMENTNAMES(104,3),0,220,FONTSZ);//13CH
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;
DRAWMENU(MNU);
REPEAT
MSNK();
KK:=WAIT(−1);
IF TYPE(KK)==0 AND 0 THEN //DIAGNOSTIC
MSGBOX({TYPE(KK)+","+KK});//WHAT KEY
END;
MSNK();
CASE
IF TYPE(KK)≠0 THEN
MSGBOX("PLEASE USE KEYPAD");
KK:=0;
END;
IF KK==1 THEN //SYMBOL
LSYM:={};
FOR EL FROM 1 TO NELE DO
LSYM:=CONCAT(LSYM,EL+" "+Z_ELEMENTNAMES(EL,2));
END;
ML:=CHOOSE(EL,"Symb",LSYM);
END;
IF KK==11 THEN //NUM
LSYM:={};
FOR EL FROM 1 TO NELE DO
LSYM:=CONCAT(LSYM,EL+" "+Z_ELEMENTNAMES(EL,2)+" "+Z_ELEMENTNAMES(EL,3))
END;
ML:=CHOOSE(EL,"Num",LSYM);
END;
DEFAULT
END;
IF KK==30 THEN //ENTER
ML:=INPUT(SY,"Enter element name or Symb");
IF ML THEN
FOR EL FROM 1 TO NELE DO
IF SY==Z_ELEMENTNAMES(EL,2) OR SY==Z_ELEMENTNAMES(EL,3) THEN
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;
END;
END;
END;
IF ML THEN
RECT_P(0,0,320,220);
TEXTOUT_P("More: use keys:",0,0,FONTSZ);
TEXTOUT_P(MNU,320/4,0);
//BOXED:=0;
//TEXTOUT_P(Z_ELEMENTNAMES(EL,3),3*COLSZ,3*ROWSZ,7);
DRWNAME(Z_ELEMENTNAMES(EL,3));
//BOXED:=1;
DRW_ELE_BOX(POS_ELE_BOX(EL),EL,Z_ELEMENTNAMES(EL,2));
//ELSE
END;
UNTIL KK==4;//ESC
//PRINT();
//PRINT("BYE");
FREEZE;
END;