Array problem


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Array problem
# 1  
Old 05-27-2008
Array problem

I am using /bin/ksh for this problem.

I have created some arrays with variable names as the array names:

cnt=1
{ while read myline; do
tempmeas="${meas%%;*}"
cto="${meas#*;}"
tempstream=$stream

# wholemeas holds the name of the array
# each array name will look like MEAS1, MEAS2, MEAS3....
# and the data goes into each array correctly
wholemeas=`eval echo \`echo "MEAS"$cnt\``
eval $wholemeas[1]="\$tempmeas"
eval $wholemeas[2]="\$cto"
eval $wholemeas[3]="\$stream"
((cnt=cnt+1))
done } < $dspbfile

Now, I am trying to get the information back out of the arrays. I can get it out if I specify the name directly:

echo ${MEAS1[1]}

This give me the correct answer I am looking for. Now, when I do this:

cnt=1
wholemeas=`echo "MEAS"$cnt`

I do get wholemeas=MEAS1[1]. Then when I try to get the value from that position in the array:

echo ${$wholemeas[1]}

I get this error:

./PDSBatch.ksh[341]: ${$wholemeas[1]}: bad substitution

I have tried eval, echo, quotes, back quotes and all the other combinations I can think of. Does anyone know how I can get the values from the arrays while using the wholemeas method of specifying the array names? Thanks.

Allyson
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Loop and array problem

Hi, I have the following problem that is beyond what I can currently do with bash scripting. In file 1, I have ~ 2500000 values. Note this file is not sorted. 3 19 LABEL_A 3 37 LABEL_B 2 12 LABEL_C 1 15 LABEL_D I have a list of values in "file 2" ~ 25000 unique lines: Note -... (6 Replies)
Discussion started by: hubleo
6 Replies

2. Shell Programming and Scripting

Using awk array problem

I am trying to map values in the input file, where 2nd column depends on the specific value in the 1st column. When 1st column is A place 1 into 2nd column, when it is B, place 2, when C place 3, otherwise no change. My input: U |100|MAIN ST |CLMN1|1 A |200|GREEN LN |CLMN2|2 1 |12... (4 Replies)
Discussion started by: migurus
4 Replies

3. Shell Programming and Scripting

Array and Loop Problem

I've got this problem, if I modify an array in the loop and print it, everything is fine as long as I stay in the loop. But, when I print it outside the loop, nothing happens... How can I solve this problem? Here I prepared a sample for you to see my problem; zgrw@Rain:~$ cat test asd 123... (4 Replies)
Discussion started by: zgrw
4 Replies

4. Emergency UNIX and Linux Support

Problem with Array in Script

Below is my script. This script is getting an error code such as this one. fileListener.bat: entityArray=craig.uss@pnc.com: not found craig.uss@pnc.com fileListener.bat: entityArray=duns_noncusts.txt: not found duns_noncusts.txt fileListener.bat: entityArray=duns_misc.cpy: not found... (4 Replies)
Discussion started by: mkjp
4 Replies

5. Shell Programming and Scripting

Array problem in Ubuntu

Hi all, I am working in ubuntu for past few weeks .Since I was working in debian I had no problem with arrays.I followed the same method in ubuntu,but is is not working as I expected. Name="apple" Name="orange" print ${Name} Expected result is apple.But I got a error as "Bad... (8 Replies)
Discussion started by: karthigayan
8 Replies

6. Programming

Help on some array problem!!

i have no idea how to make a text file abc efg hij klm nop qrs to be a array such as, arr to be "abc efg" arr "hij kml" etc..... in C (2 Replies)
Discussion started by: tyckelvin1
2 Replies

7. UNIX for Dummies Questions & Answers

Array declaration problem

Hi all, I would like to declare a vector of variables and access them sequentially. Here is my code ARRAY_CT="0001000000 0000100000 0000010000" ELEMENTS_CT=${#ARRAY_CT} echo $ELEMENTS_CT for (( j=1;j<=$ELEMENTS_IS;j++)); do echo ${ARRAY_IS} done ... (2 Replies)
Discussion started by: f_o_555
2 Replies

8. Shell Programming and Scripting

awk array problem

hi i am trying to perform some calculations with awk and arrays. i have this so far: awk 'NR==FNR{ for(i=1; i<=NF; i++) {array+=$i} tot++;next} {for(i=1; i<=NF; i++) {avg=array/tot} {diff=(array - avg)}} {for(i=1; i<=NF; i++) {printf("%5.8f\n",diff)}}' "$count".txt "$count".ttt >... (4 Replies)
Discussion started by: npatwardhan
4 Replies

9. Shell Programming and Scripting

problem with array=($(find ....)

hi, I get a *.dat files list in an array using: array=($(find . -name "*.dat")) the problem is that when a filename contains spaces, each space-separated token of the filename is in a different element of array. For instance if I have: x@x:~/tmp$ ls *.dat test1.dat test 2.dat ... (1 Reply)
Discussion started by: jul
1 Replies

10. Shell Programming and Scripting

array problem

Dear Experts, please help me out once again my array concepts is not very clear i have one text file like. 1|usa|hh 2|usa|ll 3|usa|vg 4|uk|nn 5|uk|bb 6|kuwait|mm 6|kuwait|jkj 7|dubai|hh i want to store the third fied of a text file in he array and after that it should give me some... (6 Replies)
Discussion started by: shary
6 Replies
Login or Register to Ask a Question
GLGENVERTEXARRAYS(3G)						   OpenGL Manual					     GLGENVERTEXARRAYS(3G)

NAME
glGenVertexArrays - generate vertex array object names C SPECIFICATION
void glGenVertexArrays(GLsizei n, GLuint *arrays); PARAMETERS
n Specifies the number of vertex array object names to generate. arrays Specifies an array in which the generated vertex array object names are stored. DESCRIPTION
glGenVertexArrays returns n vertex array object names in arrays. There is no guarantee that the names form a contiguous set of integers; however, it is guaranteed that none of the returned names was in use immediately before the call to glGenVertexArrays. Vertex array object names returned by a call to glGenVertexArrays are not returned by subsequent calls, unless they are first deleted with glDeleteVertexArrays(). The names returned in arrays are marked as used, for the purposes of glGenVertexArrays only, but they acquire state and type only when they are first bound. ERRORS
GL_INVALID_VALUE is generated if n is negative. SEE ALSO
glBindVertexArray(), glDeleteVertexArrays() COPYRIGHT
Copyright (C) 2010 Khronos Group. This material may be distributed subject to the terms and conditions set forth in the Open Publication License, v 1.0, 8 June 1999. http://opencontent.org/openpub/. AUTHORS
opengl.org opengl.org 06/10/2014 GLGENVERTEXARRAYS(3G)