======Part 1====== =====Entries===== ====Entry 1: August 30, 2012==== **Mercurial/hg/Repository** * On this date, the class was first taught how to use Mercurial through linux, which will be used as revision control. * This will allow the class to create and upload files into a database that can be updated at any time. It also allows the class to revisit a previously saved version of a file, and retrieve that file. * I used revision control in a class before (Structured and Object Oriented Problem Solving) with Joe, but he used www.bitbucket.org, which wasn't the easiest thing to mess with. * I find that using Mercurial through linux is much easier than in Windows and that unforgiving website, but, overall, revision control is a huge part of programming and is very, very important! ====Entry 2: September 4, 2012==== **Truth Table** * On this day, we learned about the Truth Table. * This showed me what each of the possibilities are and what they are represented by. * I learned about this a little in SOOPS and Computer Essentials, but the new names for each of the different combinations is a first for me. * I still need to understand what each of those new terms mean and what they represent, as well as memorize most to all of the Truth Table. ====Entry 3: September 12, 2012==== * We learned how to use VI/VIM in UNIX/Linux. * VI (Visual) and VIM (Visual Improved) are both text editors available on UNIX. * They are very useful because they have many different settings for modifying a file without actually typing in words. The possibilities are ENDLESS! * With all of the different commands to edit the files through VI/VIM, I am having a difficult time learning and remembering all of the commands and their purposes. I need to practice it more, sometimes I have to resort to using nano, which works for the time being, but VI is so much better! ====Entry 4: September 19, 2012==== * In data, I first grasped the concept of Linked Nodes and the program created the previous class. * The Linked Nodes concept is very similar to the concept of arrays. It takes multiple values and stores them in the order they were input. Linked Nodes just take more to program and make one think more about it. It requires structs, renaming of variables, all sorts of things I wasn't very familiar with before. * By working on this, I have become more familiar with structs, renaming of variables, and the way that Linked Nodes works in general. * The nodes themselves can have both a "name" and value or just a value. They could just have a "name", but what is the point of that when inserting a value and that value actually having meaning? Know what I mean? Anyway, the big understanding I had with the Linked Node program was appending and removing nodes from the list. =====Keywords===== {{page>datapart1&nofooter}} {{page>discretepart1&nofooter}} {{page>unixpart1&nofooter}} =====Experiment 1===== ====Question==== Arrays in Shell Script: Fact or Fiction? (Are they different from arrays in C/C++?) ====Resources==== * According to http://www.tldp.org/LDP/abs/html/arrays.html, arrays are created in the same way that they are created in C/C++ programming: **array[##]** * It also tells me that it can first introduce an array by the **declare -a variable** statement. * To dereference an array, just use curly brackets: **${array[##]}** * Left in the comments were a few pointers (see what I did there?) about arrays: 1) The members of arrays don't need to be consecutive or contiguous. 2) Not all of the members of an array need to be initialized. 3) It is alright to leave gaps in the array (spaces of memory without values). ====Hypothesis==== From the information I have collected, arrays are possible and very similar to arrays in C/C++. ====Experiment==== I will create a shell script that will basically perform the same process as the **Pointer Assignment Demonstration** (http://lab46.corning-cc.edu/opus/fall2012/jcavalu3/part1?#phase_2), and compare the two. This will, hopefully, confirm my hypothesis and allow me to know and understand how arrays work in shell script as well as C/C++ (Nothing wrong with more refreshers!). ====Data==== The following is the shell script program I created and the results: 1 #!/bin/bash 2 # 3 # You know, just a shell script file for my experiment in opus1 4 # 5 # I will create an identical file as the one I used in the pointer 6 # assignment and check to see if I get the same result. 7 # 8 # ONWARD! 9 10 for((i=0;i<4;i++)); do 11 echo -n "Enter a value (0-9): " 12 read array1[i] 13 echo -n "Enter a zero: " 14 read array2[i] 15 done 16 echo "Array1:" 17 for((i=0;i<4;i++)); do 18 echo "${array1[i]}" 19 done 20 echo "Array2: " 21 for((i=0;i<4;i++)); do 22 echo "${array2[i]}" 23 done 24 for((i=0;i<4;i++)); do 25 array2[i]=${array1[i]} 26 done 27 echo "Array1:" 28 for((i=0;i<4;i++)); do 29 echo "${array1[i]}" 30 done 31 echo "Array2: " 32 for((i=0;i<4;i++)); do 33 echo "${array2[i]}" 34 done 35 echo "Thank you for your time." 36 exit 0 lab46:~/src/opus/opus1/experiment$ ./array.sh Enter a value (0-9): 1 Enter a zero: 0 Enter a value (0-9): 2 Enter a zero: 0 Enter a value (0-9): 3 Enter a zero: 0 Enter a value (0-9): 4 Enter a zero: 0 Array1: 1 2 3 4 Array2: 0 0 0 0 Array1: 1 2 3 4 Array2: 1 2 3 4 Thank you for your time. Now, the results from the **Pointer Assignment Demonstration**: lab46:~/src/opus/opus1$ ./pa Please input four values for the first array 1 2 3 4 Here are the values in both arrays: Array1: 1 2 3 4 Array2: 0 0 0 0 Here are the results after setting 'array2' = to 'array1': Array1: 1 2 3 4 Array2: 1 2 3 4 Thank you for your time. lab46:~/src/opus/opus1$ ====Analysis==== Based on the data collected: * My hypothesis was correct, I was able to create a program in shell script that performed the same operations that the original **Pointer Assignment** program did. * The hypothesis was, indeed, applicable. * The hypothesis was basically straightforward. Of course, it usually isn't the idea or concept that is different, it is the implementation that is different. * In the experiment, the shell script was much more difficult to create the same output as the original program created. I was unsure of how to actually have it print each value out in a row, to make it look like it was one large number, as I did in the original. Also, I couldn't just point one array to another and say "You hold the same values as this array now!" I had to dereference the first array to allow the second to take the value that the specific space of memory was holding. If I didn't do that, it would just say "array2[i] = array1[i]." That just isn't what I wanted! * Shortcomings... are non-existent... in this experiment... Everything went well! I now understand how to declare arrays in shell script, how to dereference them, and how to use pointer assignments in shell script. SUCCESS! http://beastkong.com/wp-content/uploads/2012/05/success-baby.jpg ====Conclusions==== What can you ascertain based on the experiment performed and data collected? Document your findings here; make a statement as to any discoveries you've made.