1 /*
2 
3 GNU GENERAL PUBLIC LICENSE
4 **************************
5 
6 
7      Copyright (C) 1999 Todd Martin Miller
8      tmiller@toddmiller.com
9 
10      Everyone is permitted to copy and distribute verbatim copies
11      of this license document, but changing it is not allowed.
12 
13 Preamble
14 ========
15 
16    The licenses for most software are designed to take away your
17 freedom to share and change it.  By contrast, the GNU General Public
18 License is intended to guarantee your freedom to share and change free
19 software--to make sure the software is free for all its users.
20 
21    When we speak of free software, we are referring to freedom, not
22 price.  Our General Public Licenses are designed to make sure that you
23 have the freedom to distribute copies of free software (and charge for
24 this service if you wish), that you receive source code or can get it
25 if you want it, that you can change the software or use pieces of it in
26 new free programs; and that you know you can do these things.
27 
28    To protect your rights, we need to make restrictions that forbid
29 anyone to deny you these rights or to ask you to surrender the rights.
30 These restrictions translate to certain responsibilities for you if you
31 distribute copies of the software, or if you modify it.
32 
33    For example, if you distribute copies of such a program, whether
34 gratis or for a fee, you must give the recipients all the rights that
35 you have.  You must make sure that they, too, receive or can get the
36 source code.  And you must show them these terms so they know their
37 rights.
38 
39    We protect your rights with two steps: (1) copyright the software,
40 and (2) offer you this license which gives you legal permission to copy,
41 distribute and/or modify the software.
42 
43    Also, for each author's protection and ours, we want to make certain
44 that everyone understands that there is no warranty for this free
45 software.  If the software is modified by someone else and passed on, we
46 want its recipients to know that what they have is not the original, so
47 that any problems introduced by others will not reflect on the original
48 authors' reputations.
49 
50    Finally, any free program is threatened constantly by software
51 patents.  We wish to avoid the danger that redistributors of a free
52 program will individually obtain patent licenses, in effect making the
53 program proprietary.  To prevent this, we have made it clear that any
54 patent must be licensed for everyone's free use or not licensed at all.
55 
56    The precise terms and conditions for copying, distribution and
57 modification follow.
58 
59     TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
60 
61   0. This License applies to any program or other work which contains a
62      notice placed by the copyright holder saying it may be distributed
63      under the terms of this General Public License.  The "Program",
64      below, refers to any such program or work, and a "work based on
65      the Program" means either the Program or any derivative work under
66      copyright law: that is to say, a work containing the Program or a
67      portion of it, either verbatim or with modifications and/or
68      translated into another language.  (Hereinafter, translation is
69      included without limitation in the term "modification".)  Each
70      licensee is addressed as "you".
71 
72      Activities other than copying, distribution and modification are
73      not covered by this License; they are outside its scope.  The act
74      of running the Program is not restricted, and the output from the
75      Program is covered only if its contents constitute a work based on
76      the Program (independent of having been made by running the
77      Program).  Whether that is true depends on what the Program does.
78 
79   1. You may copy and distribute verbatim copies of the Program's
80      source code as you receive it, in any medium, provided that you
81      conspicuously and appropriately publish on each copy an appropriate
82      copyright notice and disclaimer of warranty; keep intact all the
83      notices that refer to this License and to the absence of any
84      warranty; and give any other recipients of the Program a copy of
85      this License along with the Program.
86 
87      You may charge a fee for the physical act of transferring a copy,
88      and you may at your option offer warranty protection in exchange
89      for a fee.
90 
91   2. You may modify your copy or copies of the Program or any portion
92      of it, thus forming a work based on the Program, and copy and
93      distribute such modifications or work under the terms of Section 1
94      above, provided that you also meet all of these conditions:
95 
96        a. You must cause the modified files to carry prominent notices
97           stating that you changed the files and the date of any change.
98 
99        b. You must cause any work that you distribute or publish, that
100           in whole or in part contains or is derived from the Program
101           or any part thereof, to be licensed as a whole at no charge
102           to all third parties under the terms of this License.
103 
104        c. If the modified program normally reads commands interactively
105           when run, you must cause it, when started running for such
106           interactive use in the most ordinary way, to print or display
107           an announcement including an appropriate copyright notice and
108           a notice that there is no warranty (or else, saying that you
109           provide a warranty) and that users may redistribute the
110           program under these conditions, and telling the user how to
111           view a copy of this License.  (Exception: if the Program
112           itself is interactive but does not normally print such an
113           announcement, your work based on the Program is not required
114           to print an announcement.)
115 
116      These requirements apply to the modified work as a whole.  If
117      identifiable sections of that work are not derived from the
118      Program, and can be reasonably considered independent and separate
119      works in themselves, then this License, and its terms, do not
120      apply to those sections when you distribute them as separate
121      works.  But when you distribute the same sections as part of a
122      whole which is a work based on the Program, the distribution of
123      the whole must be on the terms of this License, whose permissions
124      for other licensees extend to the entire whole, and thus to each
125      and every part regardless of who wrote it.
126 
127      Thus, it is not the intent of this section to claim rights or
128      contest your rights to work written entirely by you; rather, the
129      intent is to exercise the right to control the distribution of
130      derivative or collective works based on the Program.
131 
132      In addition, mere aggregation of another work not based on the
133      Program with the Program (or with a work based on the Program) on
134      a volume of a storage or distribution medium does not bring the
135      other work under the scope of this License.
136 
137   3. You may copy and distribute the Program (or a work based on it,
138      under Section 2) in object code or executable form under the terms
139      of Sections 1 and 2 above provided that you also do one of the
140      following:
141 
142        a. Accompany it with the complete corresponding machine-readable
143           source code, which must be distributed under the terms of
144           Sections 1 and 2 above on a medium customarily used for
145           software interchange; or,
146 
147        b. Accompany it with a written offer, valid for at least three
148           years, to give any third party, for a charge no more than your
149           cost of physically performing source distribution, a complete
150           machine-readable copy of the corresponding source code, to be
151           distributed under the terms of Sections 1 and 2 above on a
152           medium customarily used for software interchange; or,
153 
154        c. Accompany it with the information you received as to the offer
155           to distribute corresponding source code.  (This alternative is
156           allowed only for noncommercial distribution and only if you
157           received the program in object code or executable form with
158           such an offer, in accord with Subsection b above.)
159 
160      The source code for a work means the preferred form of the work for
161      making modifications to it.  For an executable work, complete
162      source code means all the source code for all modules it contains,
163      plus any associated interface definition files, plus the scripts
164      used to control compilation and installation of the executable.
165      However, as a special exception, the source code distributed need
166      not include anything that is normally distributed (in either
167      source or binary form) with the major components (compiler,
168      kernel, and so on) of the operating system on which the executable
169      runs, unless that component itself accompanies the executable.
170 
171      If distribution of executable or object code is made by offering
172      access to copy from a designated place, then offering equivalent
173      access to copy the source code from the same place counts as
174      distribution of the source code, even though third parties are not
175      compelled to copy the source along with the object code.
176 
177   4. You may not copy, modify, sublicense, or distribute the Program
178      except as expressly provided under this License.  Any attempt
179      otherwise to copy, modify, sublicense or distribute the Program is
180      void, and will automatically terminate your rights under this
181      License.  However, parties who have received copies, or rights,
182      from you under this License will not have their licenses
183      terminated so long as such parties remain in full compliance.
184 
185   5. You are not required to accept this License, since you have not
186      signed it.  However, nothing else grants you permission to modify
187      or distribute the Program or its derivative works.  These actions
188      are prohibited by law if you do not accept this License.
189      Therefore, by modifying or distributing the Program (or any work
190      based on the Program), you indicate your acceptance of this
191      License to do so, and all its terms and conditions for copying,
192      distributing or modifying the Program or works based on it.
193 
194   6. Each time you redistribute the Program (or any work based on the
195      Program), the recipient automatically receives a license from the
196      original licensor to copy, distribute or modify the Program
197      subject to these terms and conditions.  You may not impose any
198      further restrictions on the recipients' exercise of the rights
199      granted herein.  You are not responsible for enforcing compliance
200      by third parties to this License.
201 
202   7. If, as a consequence of a court judgment or allegation of patent
203      infringement or for any other reason (not limited to patent
204      issues), conditions are imposed on you (whether by court order,
205      agreement or otherwise) that contradict the conditions of this
206      License, they do not excuse you from the conditions of this
207      License.  If you cannot distribute so as to satisfy simultaneously
208      your obligations under this License and any other pertinent
209      obligations, then as a consequence you may not distribute the
210      Program at all.  For example, if a patent license would not permit
211      royalty-free redistribution of the Program by all those who
212      receive copies directly or indirectly through you, then the only
213      way you could satisfy both it and this License would be to refrain
214      entirely from distribution of the Program.
215 
216      If any portion of this section is held invalid or unenforceable
217      under any particular circumstance, the balance of the section is
218      intended to apply and the section as a whole is intended to apply
219      in other circumstances.
220 
221      It is not the purpose of this section to induce you to infringe any
222      patents or other property right claims or to contest validity of
223      any such claims; this section has the sole purpose of protecting
224      the integrity of the free software distribution system, which is
225      implemented by public license practices.  Many people have made
226      generous contributions to the wide range of software distributed
227      through that system in reliance on consistent application of that
228      system; it is up to the author/donor to decide if he or she is
229      willing to distribute software through any other system and a
230      licensee cannot impose that choice.
231 
232      This section is intended to make thoroughly clear what is believed
233      to be a consequence of the rest of this License.
234 
235   8. If the distribution and/or use of the Program is restricted in
236      certain countries either by patents or by copyrighted interfaces,
237      the original copyright holder who places the Program under this
238      License may add an explicit geographical distribution limitation
239      excluding those countries, so that distribution is permitted only
240      in or among countries not thus excluded.  In such case, this
241      License incorporates the limitation as if written in the body of
242      this License.
243 
244   9. The Free Software Foundation may publish revised and/or new
245      versions of the General Public License from time to time.  Such
246      new versions will be similar in spirit to the present version, but
247      may differ in detail to address new problems or concerns.
248 
249      Each version is given a distinguishing version number.  If the
250      Program specifies a version number of this License which applies
251      to it and "any later version", you have the option of following
252      the terms and conditions either of that version or of any later
253      version published by the Free Software Foundation.  If the Program
254      does not specify a version number of this License, you may choose
255      any version ever published by the Free Software Foundation.
256 
257  10. If you wish to incorporate parts of the Program into other free
258      programs whose distribution conditions are different, write to the
259      author to ask for permission.  For software which is copyrighted
260      by the Free Software Foundation, write to the Free Software
261      Foundation; we sometimes make exceptions for this.  Our decision
262      will be guided by the two goals of preserving the free status of
263      all derivatives of our free software and of promoting the sharing
264      and reuse of software generally.
265 
266 
267                                 NO WARRANTY
268 
269  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO
270      WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE
271      LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
272      HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT
273      WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT
274      NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
275      FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS TO THE
276      QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
277      PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY
278      SERVICING, REPAIR OR CORRECTION.
279 
280  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
281      WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY
282      MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE
283      LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL,
284      INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR
285      INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
286      DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU
287      OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY
288      OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN
289      ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
290 
291 */
292 
293 #include <string.h>
294 
295 #include "periodic.h"
296 #include "info.h"
297 #include "text.h"
298 
299 extern struct info elements[TotStructs];
300 
301 struct Element_Information Display_Screen[25][80];
302 
303 
fill_information(int element)304 void fill_information (int element)
305 {
306 
307   int line, i, j;
308   int key;
309 
310   for (line = 0; line <24; line++) {
311     for (i = 0; i < 80; i++) {
312       Display_Screen[line][i].y = line;
313       Display_Screen[line][i].x = i;
314       Display_Screen[line][i].status = NODATA;
315       Display_Screen[line][i].value_speak = 0;
316       Display_Screen[line][i].data_label[0] = 0;
317     }
318   }
319 
320  getkey:
321   clear();
322 
323   Display_Screen[1][32].data_label[0] = 0;
324   Display_Screen[1][32].value_character = elements[element].Name;
325   Display_Screen[1][32].status = DATACHAR;
326   Display_Screen[1][32].value_speak;
327 
328   strcpy(Display_Screen[2][0].data_label,"Atomic Symbol :");
329   Display_Screen[2][0].status = DATALABEL;
330   Display_Screen[2][17].value_character = elements[element].Symbol;
331   Display_Screen[2][17].status = DATACHAR;
332 
333   strcpy(Display_Screen[3][0].data_label,"Atomic Number :");
334   Display_Screen[3][0].status = DATALABEL;
335   Display_Screen[3][17].value_integer = elements[element].Number;
336   Display_Screen[3][17].status = DATAINT;
337 
338   strcpy(Display_Screen[4][0].data_label,"Melting Point :");
339   Display_Screen[4][0].status = DATALABEL;
340   Display_Screen[4][17].value_character = elements[element].Meltingpt;
341   Display_Screen[4][17].status = DATACHAR;
342   i = 17 + 1 + strlen(elements[element].Meltingpt);
343   strcpy(Display_Screen[4][i].data_label,"K");
344   Display_Screen[4][i].status = DATALABEL;
345 
346   strcpy(Display_Screen[5][0].data_label,"Boiling Point :");
347   Display_Screen[5][0].status = DATALABEL;
348   Display_Screen[5][17].value_character = elements[element].Boilingpt;
349   Display_Screen[5][17].status = DATACHAR;
350   i = 17 + 1 + strlen(elements[element].Boilingpt);
351   strcpy(Display_Screen[5][i].data_label,"K");
352   Display_Screen[5][i].status = DATALABEL;
353 
354   strcpy(Display_Screen[6][0].data_label,"Covalent Rad. :");
355   Display_Screen[6][0].status = DATALABEL;
356   Display_Screen[6][17].value_character = elements[element].Covalent_radius;
357   Display_Screen[6][17].status = DATACHAR;
358 
359   strcpy(Display_Screen[7][0].data_label,"Cryst. Struct.:");
360   Display_Screen[7][0].status = DATALABEL;
361   Display_Screen[7][17].value_character = elements[element].crystr;
362   Display_Screen[7][17].status = DATACHAR;
363 
364   strcpy(Display_Screen[2][40].data_label,"Atomic Weight    :");
365   Display_Screen[2][40].status = DATALABEL;
366   Display_Screen[2][60].value_character = elements[element].AtmWeight;
367   Display_Screen[2][60].status = DATACHAR;
368   i = 60 + 1 + strlen(elements[element].AtmWeight);
369   strcpy(Display_Screen[2][i].data_label,"a.m.u.");
370   Display_Screen[2][i].status = DATALABEL;
371 
372   strcpy(Display_Screen[3][40].data_label,"Natural State    :");
373   Display_Screen[3][40].status = DATALABEL;
374   Display_Screen[3][60].value_character = elements[element].State;
375   Display_Screen[3][60].status = DATACHAR;
376 
377 
378   strcpy(Display_Screen[4][40].data_label,"Density          :");
379   Display_Screen[4][40].status = DATALABEL;
380   Display_Screen[4][60].value_character = elements[element].Density;
381   Display_Screen[4][60].status = DATACHAR;
382   i = 60 + 1 + strlen(elements[element].Density);
383   strcpy(Display_Screen[4][i].data_label,"kg/l");
384   Display_Screen[4][i].status = DATALABEL;
385 
386   strcpy(Display_Screen[5][40].data_label,"Ionization Energy:");
387   Display_Screen[5][40].status = DATALABEL;
388   Display_Screen[5][60].value_character = elements[element].IonizationE;
389   Display_Screen[5][60].status = DATACHAR;
390   i = 60 + 1 + strlen(elements[element].IonizationE);
391   strcpy(Display_Screen[5][i].data_label,"volts");
392   Display_Screen[5][i].status = DATALABEL;
393 
394   strcpy(Display_Screen[6][40].data_label,"Specific Heat    :");
395   Display_Screen[6][40].status = DATALABEL;
396   Display_Screen[6][60].value_character = elements[element].SpecHeat;
397   Display_Screen[6][60].status = DATACHAR;
398   i = 60 + 1 + strlen(elements[element].SpecHeat);
399   strcpy(Display_Screen[6][i].data_label,"cal/gm K");
400   Display_Screen[6][i].status = DATALABEL;
401 
402   strcpy(Display_Screen[7][40].data_label,"Nat. Rel. Abund. :");
403   Display_Screen[7][40].status = DATALABEL;
404   Display_Screen[7][60].value_double = elements[element].Abundance;
405   Display_Screen[7][60].status = DATADOUBLE;
406   i = 60 + 1 + 7;
407   strcpy(Display_Screen[7][i].data_label,"\%");
408   Display_Screen[7][i].status = DATALABEL;
409 
410   strcpy(Display_Screen[8][0].data_label,"Electron Configuration:");
411   Display_Screen[8][0].status = DATALABEL;
412 
413   Display_Screen[9][0].value_character = elements[element].e_config;
414   Display_Screen[9][0].status = DATACHAR;
415 
416   /* Isotope Header Label */
417   if(elements[element].Isotopes > 1) {
418     strcpy(Display_Screen[11][1].data_label,"There are ");
419     Display_Screen[11][1].status = DATALABEL;
420     Display_Screen[11][11].value_integer = elements[element].Isotopes;
421     Display_Screen[11][11].status = DATAINT;
422     strcpy(Display_Screen[11][14].data_label,
423 	   "naturally occuring isotopes:");
424     Display_Screen[11][14].status = DATALABEL;
425   } else if(elements[element].Isotopes == 1) {
426     strcpy(Display_Screen[11][1].data_label,
427 	   "There is 1 naturally occuring isotope:");
428     Display_Screen[11][1].status = DATALABEL;
429   } else {
430     strcpy(Display_Screen[11][1].data_label,
431 	   "There are no naturally occuring isotopes.");
432     Display_Screen[11][1].status = DATALABEL;
433   }
434 
435   /* Isotope List */
436   line = 12;
437   if(elements[element].Isotopes >= 1) {
438     for(i=0; i < elements[element].Isotopes; i++) {
439       j = 0;
440       Display_Screen[line+i][j].value_character =
441 	elements[element].MassPerc[i];
442       Display_Screen[line+i][j].status = DATACHAR;
443       j = strlen(elements[element].MassPerc[i]);
444       strcpy(Display_Screen[line+i][++j].data_label,
445 	     "percent of isotope mass:");
446       Display_Screen[line+i][j].status = DATALABEL;
447       j+=25;
448       Display_Screen[line+i][j].value_character = elements[element].Masswt[i];
449       Display_Screen[line+i][j].status = DATACHAR;
450       j += strlen(elements[element].Masswt[i]);
451       strcpy(Display_Screen[line+i][++j].data_label,"(a.m.u.)");
452       Display_Screen[line+i][j].status = DATALABEL;
453     }
454     line += elements[element].Isotopes;
455   }
456 
457   /* Common Oxidation States Header */
458   if(elements[element].OxidNrs > 1) {
459     j = 0;
460     strcpy(Display_Screen[line][j].data_label,elements[element].Name);
461     Display_Screen[line][j].status = DATALABEL;
462     j += strlen(elements[element].Name);
463     strcat(Display_Screen[line][++j].data_label,"has");
464     Display_Screen[line][j].status = DATALABEL;
465     j += 1+strlen("has")+1;
466     Display_Screen[line][j].value_integer = elements[element].OxidNrs;
467     Display_Screen[line][j].status = DATAINT;
468     if(elements[element].OxidNrs > 10)
469       j += 3;
470     else
471       j += 2;
472     strcat(Display_Screen[line][j].data_label,"common oxidation states:");
473     Display_Screen[line][j].status = DATALABEL;
474   } else if (elements[element].OxidNrs == 1) {
475     j = 0;
476     strcpy(Display_Screen[line][j].data_label,elements[element].Name);
477     Display_Screen[line][j].status = DATALABEL;
478     j += strlen(elements[element].Name) + 1;
479     strcat(Display_Screen[line][j].data_label,"has");
480     Display_Screen[line][j].status=DATALABEL;
481     j += 4;
482     Display_Screen[line][j].value_integer = 1;
483     Display_Screen[line][j].status = DATAINT;
484     j += 2;
485     strcat(Display_Screen[line][j].data_label,"common oxidation state:");
486     Display_Screen[line][j].status = DATALABEL;
487   }
488   line++;
489   j= 0;
490   for(i=0; i < elements[element].OxidNrs; i++) {
491     Display_Screen[line][j].value_integer = elements[element].Oxidstate[i];
492     Display_Screen[line][j++].status = DATAINT;
493     if (i < (elements[element].OxidNrs-1)) {
494       strcpy(Display_Screen[line][++j].data_label,",");
495       Display_Screen[line][j].status = DATALABEL;
496       j+=2;
497     }
498   }
499   line = 11;
500   /* Text Description of element */
501   for(i=0; i < TextLinesPerDescriptor; i++) {
502     Display_Screen[line+i][50].value_character =
503       TextDesc[(element-1)][i].line;
504     Display_Screen[line+i][50].status = DATACHAR; /* Not useful for reading */
505   }
506   return;
507 }
508 
509 
510