array


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers array
# 1  
Old 03-24-2008
array

Hi Friends
Using Redhat version 9
I have following data and me not knowing the array concept , hence please do help.
data is as belowSmilieDate is in Dd/MM/YYYY format.)

Lf No Chq No Amount Date Name Address
123M4567891223 23456 2450.00 1/01/2008 ABC 123,Ave
234Y1234567891 45678 1840.00 1/02/2008 CDE 145,bbc
456H4567899123 98765 2500.00 1/03/2008 EFG 456,cde
789Q9876543211 12345 3000.00 1/04/2008 HIJ 324,EFG

And like wise. The 4th character in LfNo is indicative of the Payment is
Q-> Qtly H-> HalfYealy Y->Yearly M-> Monthly.I have aleady code for
totaling and sorting .What I want is that

Name Lf No Chq fm TO Amount From To
ABC 123M567891223 23456 to 234559 2450.00 1/01/2008 to 31/12/2008

This will be followed by all Qly payment and likewise Halfyearly and Yearly
.I will have to use array for individual total and sorting the Lf Again, where I require the help .

Thanks in advance .Smilie

Last edited by vakharia Mahesh; 03-24-2008 at 02:02 PM.. Reason: system I m using
# 2  
Old 03-24-2008
Deleted post

Last edited by jgt; 03-24-2008 at 03:28 PM..
# 3  
Old 03-24-2008
There is a fairly standard procedure for writing reports with rolling totals.
In pseudo code:
Grandtotal=0
Companytotal=0
Depttotal=0
firstswitch="Y"
while not eof
read record
if firstwitch = "Y"
prev_dept=record_dept
prev_company=record_company
firstswitch="N"
endif
if record_company not equal prev_company
perform company_total
prev_company = record_company
endif
if record_dept not equal prev_dept
perform dept_total
prev_dept=record_dept
endif
add record_amount to dept_total
print record details if required
endwhile
perform grandtotal
stop
grandtotal
perform companytotal
print grandtotal
return
companytotal
perform depttotal
add companytotal to grandotal
print companytotal
companytotal=0
return
depttotal
add depttotal to companytotal
print depttotal
depttotal=0
return

Last edited by jgt; 03-24-2008 at 03:30 PM.. Reason: typos
# 4  
Old 03-27-2008
arary

Thanx jgt for your help and I have written the code using your guidence
and using the array .Thanx once again.Smilie
# 5  
Old 03-27-2008
Thanks should go to the nice people at Orenda Engines who gave me a booklet of sample code in 1970.
Still curious though as to why you need the array?
# 6  
Old 03-27-2008
array

Hello JGT
Thanx to GOD that I have came accross a good person like you , who
showered the Thanx to the original personal.Very good gesture .
Being able to get your answer in time has helped me to form the array and
I have written the code successfully and CREDIT goes to the path shown
by YOU.

With Warm Regards Cheer UPSmilie
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help reading the array and sum of the array elements

Hi All, need help with reading the array and sum of the array elements. given an array of integers of size N . You need to print the sum of the elements in the array, keeping in mind that some of those integers may be quite large. Input Format The first line of the input consists of an... (1 Reply)
Discussion started by: nishantrefound
1 Replies

2. Shell Programming and Scripting

Bash arrays: rebin/interpolate smaller array to large array

hello, i need a bit of help on how to do this effectively in bash without a lot of extra looping or massive switch/case i have a long array of M elements and a short array of N elements, so M > N always. M is not a multiple of N. for case 1, I want to stretch N to fit M arrayHuge H = (... (2 Replies)
Discussion started by: f77hack
2 Replies

3. Shell Programming and Scripting

Pass array to a function and display the array

Hi All I have multiple arrays like below. set -A val1 1 2 4 5 set -A val2 a b c d . . . Now i would like to pass the individual arrays one by one to a function and display/ do some action. Note : I am using ksh Can you please advise any solution... Thanks in advance. (7 Replies)
Discussion started by: Girish19
7 Replies

4. Shell Programming and Scripting

Bash 3.2 - Array / Regex - IF 3rd member in array ends in 5 digits then do somthing...

Trying to do some control flow parsing based on the index postion of an array member. Here is the pseudo code I am trying to write in (preferably in pure bash) where possible. I am thinking regex with do the trick, but need a little help. pesudo code if == ENDSINFIVEINTS ]]; then do... (4 Replies)
Discussion started by: briandanielz
4 Replies

5. Shell Programming and Scripting

PERL : Read an array and write to another array with intial string pattern checks

I have an array and two variables as below, I need to check if $datevar is present in $filename. If so, i need to replace $filename with the values in the array. I need the output inside an ARRAY How can this be done. Any help will be appreciated. Thanks in advance. (2 Replies)
Discussion started by: irudayaraj
2 Replies

6. Shell Programming and Scripting

Store all the passed arguments in an array and display the array

Hi I want to write a script which store all the parameters passed to the script into an array. Once it is stored I want scan through the array and and delete those files for last month present inside the directory. The files in directory is appneded with YYYY_MM_DD. I want to know how can I... (3 Replies)
Discussion started by: dgmm
3 Replies

7. Shell Programming and Scripting

perl, put one array into many array when field is equal to sth

Hi Everyone, #!/usr/bin/perl use strict; use warnings; my @test=("a;b;qqq;c;d","a;b;ggg;c;d","a;b;qqq;c;d"); would like to split the @test array into two array: @test1=(("a;b;qqq;c;d","a;b;qqq;c;d"); and @test2=("a;b;ggg;c;d"); means search for 3rd filed. Thanks find the... (0 Replies)
Discussion started by: jimmy_y
0 Replies

8. Shell Programming and Scripting

PHP: Search Multi-Dimensional(nested) array and export values of currenly worked on array.

Hi All, I'm writing a nagios check that will see if our ldap servers are in sync... I got the status data into a nested array, I would like to search key of each array and if "OK" is NOT present, echo other key=>values in the current array to a variable so...eg...let take the single array... (1 Reply)
Discussion started by: zeekblack
1 Replies

9. Programming

Creating an array to hold posix thread ids: Only dynamic array works

I am facing a strange error while creating posix threads: Given below are two snippets of code, the first one works whereas the second one gives a garbage value in the output. Snippet 1 This works: -------------- int *threadids; threadids = (int *) malloc (num_threads * sizeof(int)); ... (4 Replies)
Discussion started by: kmehta
4 Replies

10. Shell Programming and Scripting

create array holding characters from sring then echo array.

Hi, I wish to store $string1 in $string1array a character in each array element. Then i wish to echo the entire array to the screen so that it reads as the normal string again. I have been trying with the code below but does not work. Please help... To put string into array: ... (5 Replies)
Discussion started by: rorey_breaker
5 Replies
Login or Register to Ask a Question