Depends on what "shell". Even in ancient of days Bourne shell (something you'll still find on many Solaris hosts), you can always think of an array as:
varname_${index1}_${index2}
If you just had to. In other words, you can use variable values to create unique variable names... and thus get an array effect.
bash and ksh have arrays, new editions of korn shell (and bash as well) support single dimension indexed as well as associative arrays. You can exploit associative arrays to do quasi-multi dimensional array indexing using a similar technique to what I described for bourne shell... e.g varname["${index1} ${index2}"]
So assignment isn't necessarily hard in the bourne shell case... but evaluating requires an extra level of evaluation to be performed, so you have to do some extra escaping.
Korn/bash won't have this extra eval requirement. So you can just do (in bash):
(I realize I'm not being consistent... the underscore is a requirement in the bourne shell case, since it's just named variables really, and I'm using space as the separator between the indices in the korn/bash associative array case)
Hope that helps get you on your way!!
Last edited by cjcox; 09-22-2011 at 05:06 PM..
Reason: forgot braces on associative array, added more data and formatting.
I have a file that's logically in the form of a multidimensional array with an unknown number of records in the file. The file looks like this:
name1
data1
name2
data2
name3
data3
...
nameN
dataN
How do I load this file into an array for processing, while... (2 Replies)
i'm trying to open a file with three or more columns and an undetermined, but finite number of rows. I want to define an array for each row with each element of the row as a sub array. The columns are separated by tabs or spaces.
Here's the file:
12x3.12z34b.342sd3.sds 454.23.23.232 ... (9 Replies)
Hi! I need to make dynamic multidimensional arrays using the vector class. I found in this page How to dynamically create a two dimensional array? - Microsoft: Visual C++ FAQ - Tek-Tips the way to do it in 2D, and now i'm trying to expand it to 3D but i don't understand how is the operator working,... (0 Replies)
i'm trying to use awk to count a listing similar to the following and get a report of the listing similar to the one below it.
y,pizza
n,pizza
y,pizza
y,pizza
n,tomato
n,tomato
y,cheese
y,cheese
n,cheese
report
----
pizza,3,1
tomato,0,2
cheese,2,1 (1 Reply)
Hi, I hope the title does not scare people to look into this thread but it describes roughly what I'm trying to do. I need a solution in PHP.
I'm a programming beginner, so it might be that the approach to solve this, might be easier to solve with an other approach of someone else, so if you... (0 Replies)
Hi,
I was trying to process a file with the help of awk. I want to first display all the rows that contains 01 and at the end of processing I have to print some portion of all the lines. like below.
Output expected: (2 Replies)
My language is C++. I have a multidimensional vector that I would like to sort by a specific "cell" or "field" within the main vector. Does anyone have any information on how to do this? I have searched all over the internet and every reference manual I can find. So far I have found very little to... (2 Replies)
if i declare both but don't input any variables what values will the int array and file pointer array have on default, and if i want to reset any of the elements of both arrays to default, should i just set it to 0 or NULL or what? (1 Reply)
I have two files:
file-1 is a list of number of interfaces in the switch and file-2 have VLAN-ID , VLAN-NAME , Interface belong to that VLAN like this:
file-1:
1/1
1/2
1/3
1/4
1/5
.
.
file-2:
1,"vlan-wifi",1/1,1/7,1/8 (9 Replies)
I am learning about bash system variables, such as $ , @ and #.
I have this piece of script implementing an array and it is doing its job just fine.
This is not the only array I will be using.
Just for ease of maintenance and more coding I would like to have the arrays in two dimensional... (4 Replies)
Discussion started by: annacreek
4 Replies
LEARN ABOUT SUSE
genlib_place_on
GENLIB_PLACE_ON.3(October 1, 1997) GENLIB_PLACE_ON.3(October 1, 1997)
NAME
GENLIB_PLACE_ON - place a physical instance in the current figure matching connectors
SYNOPSYS
#include <genlib.h>
void GENLIB_PLACE_ON(figname,ins1,con1,index1,symetry,ins2,con2,index2)
char *figname, *ins1, *con1, *ins2, *con2;
char symetry;
long index1, index2;
ORIGIN
This software belongs to the ALLIANCE CAD SYSTEM developed by the ASIM team at LIP6 laboratory of Universite Pierre et Marie CURIE, in
Paris, France.
Web : http://asim.lip6.fr/recherche/alliance/
E-mail : alliance-users@asim.lip6.fr
PARAMETERS
figname Name of the layout figure to be instanciated
ins1 Name to be given to the instance in the model
con1 Name of the connector of the instance to be used for placement
index1 Index of the connector, or reference, con1 of the model to be used for placement
symetry Geometrical operation to be performed on the instance before beeing placed
ins2 Name of the instance to be used for relative placement
con2 Name of the connector of the instance ins2 on which the placement will take place
index2 Index of the connector con2 of the instance to be used for relative placement
DESCRIPTION
PLACE_ON add an instance in the current layout cell. The bottom left corner of the instance of the model modelname is placed, after beeing
symetrized and/or rotated, at (x, y) coordinates. The placed instance becomes the new "reference instance", used in the relative placement
functions.
The insname is the name given to the instance and must be unique at a given hierarchy level.
The symetry argument can take eight legal values :
NOSYM no geometrical operation is performed
SYM_Y Y becomes -Y, that means toward X axe symetry
SYM_X X becomes -X, that means toward Y axe symetry
SYMXY X becomes -X, Y becomes -Y
ROT_P a positive 90 degrees rotation take place
ROT_M a negative 90 degrees rotation take place
SY_RP Y becomes -Y, and then a positive 90 degrees rotation take place
SY_RM Y becomes -Y, and then a negative 90 degrees rotation take place
The model of the figure to be placed must be available, on disk or in memory. The path to the library is specified in the MBK_CATA_LIB (1)
and MBK_WORK_LIB (1) environment variables, and its format is given by the MBK_IN_PH (1) environment variable.
ERRORS
"GENLIB_PLACE_ON impossible : missing GENLIB_DEF_PHFIG"
No figure has been yet specified by a call to DEF_PHFIG. So it isn't possible to place an instance inside it. you must call
DEF_PHFIG before any other layout action.
"illegal addphins : transformation is x in insname"
The symetry parameter is not one of the define given, but has the integer value x.
EXAMPLE
#include <genlib.h>
main()
{
/* Create a figure to work on */
GENLIB_DEF_PHFIG("cell");
/* Place two instances */
GENLIB_PLACE_ON("gapg0_b","ins1", NOSYM, 0L, 0L);
GENLIB_PLACE_ON("gapg8_b","ins2", SYM_X, 80L, 100L);
/* Save all that on disk */
GENLIB_SAVE_PHFIG();
}
SEE ALSO genlib(1), GENLIB_DEF_PHFIG(3), GENLIB_SAVE_PHFIG(3), GENLIB_PLACE_TOP(3), GENLIB_PLACE_BOTTOM(3), GENLIB_PLACE_LEFT(3), GEN-
LIB_PLACE_RIGHT(3), MBK_CATA_LIB(1), MBK_WORK_LIB(1), MBK_IN_PH(1).
BUG REPORT
This tool is under development at the ASIM department of the LIP6 laboratory.
We need your feedback to improve documentation and tools.
PROCEDURAL GENERATION LANGUAGE ASIM/LIP6 GENLIB_PLACE_ON.3(October 1, 1997)