Sponsored Content
Top Forums Shell Programming and Scripting Adding an element to a bash array with a variable Post 302937960 by Don Cragun on Wednesday 11th of March 2015 02:32:50 AM
Old 03-11-2015
It also seems that a simple string, rather than an array, might be a simpler approach here. When you get to the point that you want to invoke a command, I would assume that you would want -L 22 -s 0 -r -O -A i -N 100 -n to be eleven separate arguments to that command; not a single argument.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Adding array element in KSH

All, I would like to add the first 10 elements of an array. Here is how I am doing it now (only included first few add ops): #!/usr/bin/ksh ###Grab the array values out of a file### TOTAL=`awk '/time/' /tmp/file.out | awk '{print $4}'` set -A times $TOTAL SUM=$((${times} + times... (3 Replies)
Discussion started by: Shoeless_Mike
3 Replies

2. Shell Programming and Scripting

saving awk value in a bash array variable

hi all i am trying to save an awk value into an array in bash: total=`awk '{sum+=$3} END {print sum}' "$count".txt"` ((count++)) the above statement is in a while loop.. $count is to keep track of file numbers (1.txt,2.txt,3.txt,etc.) i get the following error: ./lines1:... (1 Reply)
Discussion started by: npatwardhan
1 Replies

3. Windows & DOS: Issues & Discussions

Array element & string variable

Hello, I am trying to assign $string = $a; #a= 10100 print " $string"; # showing 10100 I am using this $string as $result = index($string, $char, $offset); As above, is not capturing binary nos. in following format; $string = '10100'; so index is not working. kindly suggest. (5 Replies)
Discussion started by: shristi
5 Replies

4. Shell Programming and Scripting

How to assign an array element to a variable

Hi every one.. I'm new to shell scripting... I would like to assign a single array element to a variable... Is it possible to do it.... Could any body help me.... (3 Replies)
Discussion started by: kaushik_87
3 Replies

5. Shell Programming and Scripting

Creating bash array name from variable

Hi gurus, I need to create arrays from variables, via a loop. The issue I have is with the array name creation. How do I use a variable to define an array? I want to do something like declare -a $H where $H is my loop variable. I then need to add items to each array I've created,... (3 Replies)
Discussion started by: melias
3 Replies

6. Shell Programming and Scripting

Adding Content to Variable (bash)

is this possible? its kind of like incrementing the value of a number in a variable. but in this case, instead of the value of the variable being a number, it's just contents/strings/characters/alpha-numeric etc. NOT a number. For instance: VAR=Tommy for all in $(blah blah) do ... (2 Replies)
Discussion started by: SkySmart
2 Replies

7. Shell Programming and Scripting

Bash question: working with an array of previously set variable strings

while i've used arrays to work with variables, i've never used them to loop through a set of strings and wanted to ask the community for some feedback or assistance. let me be specific. here's my code: # URL port Variables port2195=`nc -z $url2195 2195` port2196=`nc -z $url2196 2196`... (5 Replies)
Discussion started by: hungryd
5 Replies

8. UNIX for Advanced & Expert Users

Array Element

This question is for someone that's more familiar with Array Element. I need to know if the maximum array element that can be assigned is 1024 and if its so, Is there a workaround solution when the counter exceeded 1024? param_array="$param_nam" counter=$counter+1 #to avoid space... (3 Replies)
Discussion started by: cumeh1624
3 Replies

9. UNIX for Beginners Questions & Answers

Unset array element and save to file in Bash

#!/bin/bash X=(2H 4S 10D QC JD 9H 8S) How do I unset the 10D from this array and save it to a file? Please use CODE tags as required by forum rules! (5 Replies)
Discussion started by: cogiz
5 Replies

10. UNIX for Beginners Questions & Answers

Adding to an array in an external file, and adding elements to it.

I have an array in an external file, "array.txt", which contains: char *testarray={"Zero", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine"};I want to be able to add an element to this array, and have that element display, whenever I call it, without having to recompile... (29 Replies)
Discussion started by: ignatius
29 Replies
XtActionProc()															    XtActionProc()

Name
  XtActionProc - interface definition for action procedure.

Synopsis
  typedef void (*XtActionProc)(Widget, XEvent *, String *, Cardinal *);
	 Widget w;
	 XEvent *event;
	 String *params;
	 Cardinal *num_params;

Inputs
  w	    Specifies the widget in which the event occurred that caused the action to be called.

  event     Specifies the event that caused the action to be called.  If the action is called after a sequence of events, then the last event
	    in the sequence is used.

  params    Specifies an array of strings that were specified in the translation table as comma-separated arguments to the action.

  num_params
	    Specifies the number of strings in params.

Description
  An XtActionProc is an action procedure.  Action procedures are given names in an XtActionList and that array	of  name/procedure  pairs  is
  then	registered with the Translation Manager either through a call to XtAppAddActions() or by statically initializing the actions field of
  the Core widget record.  The translation table of a widget binds event sequences into a sequence of action procedures, and the  Translation
  Manager automatically invokes the action procedures when the specified event sequences occur.

  The  params  argument  is  an  array	of strings that the action may use.  These strings are the comma-separated arguments specified in the
  translation table.  An action procedure may use or ignore them, and may invoke a resource converter to convert strings to convert  each  of
  the strings to some other desired type.

  Action  procedures should not assume that the widget in which they are invoked is realized; an accelerator can cause an action procedure to
  be called for a widget that does not yet have a window.

Usage
  As an application programmer, you can often customize the behavior of a widget either by adding callback functions  to  one  of  the	lists
  defined by the widget, or by writing and registering custom action procedures and invoking them from the widget's translation table.	Call-
  backs are the simpler approach and are usually sufficient.  Action procedures are usually used when you need to  directly  bind  particular
  user	events	to  particular actions-for example, when the widget does not provide a callback that is invoked in response to the event type
  that you are interested in.  If you wanted to pop up a menu when the mouse entered a widget, or draw	a  box	when  the  user  clicked  and
  dragged  the	mouse,	for  example,  you  would  probably  use  action  procedures.	Note that action procedures are not registered with a
  client_data argument as callbacks are, and so application-level action procedures may have to depend on global data.	 Widget-level  action
  procedures can usually get all the data they need from their widget argument.

  Note that it is usually a widget's action procedures that invoke the functions registered on that widget's callback lists.

  Many	action	routines are intentionally written not to depend on the detailed information inside any particular type of event, so that the
  user may use the translation table to invoke the action in response to different types of events.  For example, it is useful for an  action
  routine  normally  triggered	by a pointer click to work when called in response to a key instead.  Such an action should not depend on the
  event structure fields unique to button events.  If your action does depend on the details of a particular event type, you  must  cast  the
  event argument to a pointer to an event structure of the appropriate type.

  When	you  write a widget or an application, you should document each of the action procedures that users may invoke from a translation ta-
  ble, and document any arguments each action expects, and also the event types that the action can be safely called on.  Also, if an  action
  procedure invokes the procedures on a callback list without checking that the widget is realized, the callback documentation must note that
  the widget may not yet be realized.

  In many action procedures, the last two arguments are unused.  When you don't use the last two arguments, be sure to place the lint comment
  /*ARGSUSED*/	just  before  the  action  procedure  definition.   To conform to ANSI-C standards, all four arguments of an action should be
  declared, even if the trailing arguments are not used.

  The Intrinsics reserve all action names and parameters starting with the characters "Xt" for future standard enhancements.  Users, applica-
  tions,  and  widgets	should not declare action names or pass parameters starting with these characters except to invoke specified built-in
  Intrinsics functions.

Example
  The following two action procedures are from the Xaw Command widget:

     static void
     Highlight(w,event,params,num_params)
     Widget w;
     XEvent *event;
     String *params;
     Cardinal *num_params;
     {
       CommandWidget cbw = (CommandWidget)w;

       if ( *num_params == (Cardinal) 0)
	 cbw->command.highlighted = HighlightWhenUnset;
       else {
	 if ( *num_params != (Cardinal) 1)
	   XtWarning("Too many parameters passed to highlight action table.");
	 switch (params[0][0]) {
	 case 'A':
	 case 'a':
	   cbw->command.highlighted = HighlightAlways;
	   break;
	 default:
	   cbw->command.highlighted = HighlightWhenUnset;
	   break;
	 }
       }

       if (XtIsRealized(w))
	 PaintCommandWidget(w, HighlightRegion(cbw), TRUE);
     }

     /* ARGSUSED */
     static void
     Notify(w,event,params,num_params)
     Widget w;
     XEvent *event;
     String *params;	     /* unused */
     Cardinal *num_params;   /* unused */
     {
       CommandWidget cbw = (CommandWidget)w;

       /* check to be sure state is still Set so that user can cancel
	  the action (e.g., by moving outside the window, in the default
	  bindings.
       */
       if (cbw->command.set)
	 XtCallCallbackList(w, cbw->command.callbacks, NULL);
     }

Structures
  The XtActionsRec structure and the XtActionList type are defined as follows:

     typedef struct _XtActionsRec{
	 String      string;
	 XtActionProc proc;
     } XtActionsRec;

     typedef struct _XtActionsRec *XtActionList;

See Also
  XtAppAddActions(1).

Xt - Translations and Actions													    XtActionProc()
All times are GMT -4. The time now is 04:02 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy