# @(#)40 1.1 src/dtuimx/ibmr2/dtscriptdir/contrib/TimeSheet/InitialCode, uimx, dtuimx720 8/8/94 20:09:43 # COMPONENT_NAME: DT UIM/X # # ORIGINS: 58 # # # Copyright IBM Corporation 1991, 1994 # # All Rights Reserved # # Permission to use, copy, modify, and distribute this software and its # documentation for any purpose and without fee is hereby granted, # provided that the above copyright notice appear in all copies and that # both that copyright notice and this permission notice appear in # supporting documentation, and that the name of IBM not be # used in advertising or publicity pertaining to distribution of the # software without specific, written prior permission. # # IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING # ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR # PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR # CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF # USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR # OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE # OR PERFORMANCE OF THIS SOFTWARE. # # initialize values # set -A Week Sat Sun Mon Tue Wed Thu Fri set -A Column Job Description ${Week[@]} Total eval typeset ${Column[@]} ColumnTotal typeset -i NRow=0 RowId ColumnId typeset PrintFile="$HOME/.ts.out" function put_widget_in_row # Widget widget # char* rowname { eval typeset NRow='${#'$2'[@]}' eval $2'[$NRow]=$1' } function find_row_id # void* variable # char* name { typeset col for col in ${Column[@]} do typeset -i indx=0 eval typeset items='${'$col'[@]}' for item in $items do if [[ $2 == $item ]] then eval $1=$indx return fi indx=$indx+1 done done } function find_column_id # void* variable # char* name { typeset -i indx=0 typeset col for col in ${Column[@]} do if [[ $2 == $col ]] then eval $1=$indx return fi indx=$indx+1 done } function recalculate_row # int id { typeset -i id=$1 typeset day rtotal_field=${Total[$id]} typeset -i rtotal=0 for day in ${Week[@]} do typeset -i value eval XtGetValues '${'$day'[$id]}' value:value rtotal=$rtotal+value done if ((rtotal == 0)); then XtSetValues $rtotal_field value:"" else XtSetValues $rtotal_field value:$rtotal fi } function recalculate_column # char* colname { typeset colname=$1 typeset ctotal_field job jobs_in_day typeset -i ctotal=0 typeset -i id find_column_id id $colname ctotal_field=${ColumnTotal[$id]} eval jobs_in_day='${'$colname'[@]}' for job in $jobs_in_day do typeset -i value XtGetValues $job value:value ctotal=$ctotal+value done if ((ctotal == 0)); then XtSetValues $ctotal_field value:"" else XtSetValues $ctotal_field value:$ctotal fi } function recalculate_total { typeset -i total=0 typeset -i id typeset subtotal_field total_field find_column_id id Total total_field=${ColumnTotal[$id]} for subtotal_field in ${ColumnTotal[@]} do typeset -i value if [[ $subtotal_field == $total_field ]] then break fi XtGetValues $subtotal_field value:value total=$total+value done if ((total == 0)); then XtSetValues $total_field value:"" else XtSetValues $total_field value:$total fi } function recalculate # KeyValue keyvalue { typeset colname=$1 typeset -i rowid=$2 recalculate_row $rowid recalculate_column $colname recalculate_total }