4x4 Array in csh scripting


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting 4x4 Array in csh scripting
# 1  
Old 09-20-2011
4x4 Array in csh scripting

I am trying to code a 4 by 4 array. However the naming convention is diffrent.
Please refer the image below
Image

I want to name them in order :
from 0 to 3 --> (0,0) cell to (0,3)
from 4 to 7 --> (1,0) cell to (1,3)
and so on

This is what i have coded:
Code:
if ($cell_index == 0) then
              set mc_index = 00
          else if ($cell_index == 1) then
              set mc_index = 01
          else if ($cell_index == 2) then
              set mc_index = 02
          else if ($cell_index == 3) then
              set mc_index = 03
          else if ($cell_index == 4) then
              set mc_index = 10
          else if ($cell_index == 5) then
              set mc_index = 11
          else if ($cell_index == 6) then
              set mc_index = 12
          else if ($cell_index == 7) then
              set mc_index = 13
          else if ($cell_index == 8) then
              set mc_index = 20
          else if ($cell_index == 9) then
              set mc_index = 21
          else if ($cell_index == 10) then
              set mc_index = 22
          else if ($cell_index == 11) then
              set mc_index = 23
          else if ($cell_index == 12) then
              set mc_index = 30
          else if ($cell_index == 13) then
              set mc_index = 31
          else if ($cell_index == 14) then
              set mc_index = 32
          else if ($cell_index == 15) then
              set mc_index = 33
          endif

What I need to know is, is there any better way to do this? may be involving less lines of codes.

Please prompt me if any further inputs required.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Simple 4x4 matrix

I am trying to make a 4x4 matrix and I would greatly appreciate any help. I have 4 text files and I want to do the following. I want to concatenate them and gzip them. Then I want to find the file size of the concatenated file and subtract the value of file A. Finally, I want to output this final... (1 Reply)
Discussion started by: sdw8253
1 Replies

2. Shell Programming and Scripting

Regarding c-shell (csh) scripting

Hi, I'm reading a csh setup script, and came across these lines: ################################ if (! $?PROJECT_ROOT) then setenv PROJECT_ROOT /proj/proj_123 endif ################################ Does the if endif command means, "if there is no variable named "PROJECT_ROOT",... (3 Replies)
Discussion started by: mar85
3 Replies

3. UNIX for Dummies Questions & Answers

Problem with simple csh scripting

I found my answer... (2 Replies)
Discussion started by: sjung9442
2 Replies

4. Shell Programming and Scripting

ksh scripting- array format

Hi Everyone, I have a ksh script that queries a database. The query output looks like this: $queryResult = echo ${queryResult} = name1 echo ${queryResult} = age1 echo ${queryResult} = name2 echo ${queryResult} = age2 ... I need to insert those values into a new array that would... (2 Replies)
Discussion started by: practitioner
2 Replies

5. Shell Programming and Scripting

csh array missing some elements

I'm having a problem with this bit of my script. '/tmp/data' contains the output of 'ls -l', and I'm assigning a couple of the columns to an array. The problem is that it line starts on the third line of 'ls -l' rather than the first one. @ count = 7 set line = `cat /tmp/data` while ($count... (1 Reply)
Discussion started by: tkirk
1 Replies

6. Shell Programming and Scripting

Scripting array issue

Hi guys, I'm a scripting noob in need of some help :) I am creating a script that checks the filesystems and will alert based upon if the percent full is greater than the threshold set. The problem that I am having is that when I set the 'filesystem' variable, all of the output is treated as... (12 Replies)
Discussion started by: tank126
12 Replies

7. Shell Programming and Scripting

Array problems in CSH

Hi all, I want to use some commands and I wrap them into an array, like follows: set ALIAS_AR = ( "ls -ltr|wc -l" \ "ps -ef|grep -v grep |grep tty|wc -l" \ "who|wc -l" ) Then I use a while loop to call every step: set no = 1... (3 Replies)
Discussion started by: tpltp
3 Replies

8. Shell Programming and Scripting

csh array help!!

I'm trying call the first item in the array then put it in a loop to call the next items in order. set $p = (port-1, port-2, port-3, port-4, exit) <sourcePort>daughtercard:$P</sourcePort> if ($p == "exit") then break else ($p >> 1) I know the above code isn't correct. I'm... (1 Reply)
Discussion started by: drkelly76
1 Replies

9. Shell Programming and Scripting

How to define array in Bourne shell , csh & ksh

Dear friends... Kindly if any one can help me to know the differences in definning & retreiving data from arrays in the sh,csh & ksh. I always facing problems in this issue. thanks...:) BR (3 Replies)
Discussion started by: ahmad.diab
3 Replies

10. UNIX for Dummies Questions & Answers

Simple Array in Ksh Scripting

Ksh Scripting Can some one give me a simple example of array operations using ksh. For Ex: week_array = {Sunday Monday Tuesday Wednesday Thursday Friday Saturday} I want to assign and retrieve and print them along with their index. I am looking for the o/p like: 0 Sunday 1 Monday ... (2 Replies)
Discussion started by: ravikirankethe
2 Replies
Login or Register to Ask a Question