Sponsored Content
Top Forums Shell Programming and Scripting [Solved] If doesn't evaluate the first test Post 302746069 by jimm on Tuesday 18th of December 2012 05:48:55 PM
Old 12-18-2012
Thanks Chubler_XL that will save a few lines. I had it expanded like that so I could stick "echo" in as needed to see where It got on each try. I also just ran with a space after and before each [ ], no joy.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Test on string containing spacewhile test 1 -eq 1 do read a $a if test $a = quitC then break fi d

This is the code: while test 1 -eq 1 do read a $a if test $a = stop then break fi done I read a command on every loop an execute it. I check if the string equals the word stop to end the loop,but it say that I gave too many arguments to test. For example echo hello. Now the... (1 Reply)
Discussion started by: Max89
1 Replies

2. Programming

Kernel module - How to test if file doesn't exist

Hey, I'm currently getting into some kernel module progamming. As a little exercise I want to read the headers out of an ELF file. My code is very simple, here is the important part: struct file *fp; /* ... */ fp = filp_open("some/file/on/my/pc", O_RDONLY, 0); if(fp == NULL) { ... (15 Replies)
Discussion started by: disaster
15 Replies

3. Shell Programming and Scripting

[Solved] Bash test 2 variables to see if ones greater by n

Experts, I have a bash shell script that generates 2 variables that have the current minute and a minute from a log file. Can someone please show me the best way to test if the minutes stray by 5. So basically if: This is ok: Last Fitting Min ============= 02 Current Minute =============... (2 Replies)
Discussion started by: jaysunn
2 Replies

4. Shell Programming and Scripting

Value of variable is NULL, but test doesn't seem to recognize

Hello, Unix-forums! My problem: read -p "Enter any number, please" number sleep 1 echo $number | tr -d 0-9 test -z $number && echo "Thank you" || echo "This is not a number"Test always displays "This is not a number". It doesn't matter if I entered a or 1. But if I order echo... (2 Replies)
Discussion started by: intelinside
2 Replies

5. Shell Programming and Scripting

[Solved] BASH - chaining TEST and COMMAND with && and II

Can you explain what this line of script is doing. What I have understood is : -- variable C is the name of a software which is either not installed, so it must be installed or allready installed and then should be update if newer version found -- branch B="$B $C" is to install the software --... (4 Replies)
Discussion started by: jcdole
4 Replies

6. Shell Programming and Scripting

[Solved] Script doesn't work..help?

hi, i am trying to run this script.the name of script is final.sh after i run it: #./final.sh & i grep the command # ps -a | grep bash and i see more then one processes runing 3!! Please use code tags how can i solve this problem? my target script must always run in... (8 Replies)
Discussion started by: zigizag
8 Replies

7. UNIX for Dummies Questions & Answers

[Solved]Can anyone tell me why -H flag with sudo doesn't switch to the target user's home directory?

I have checked the man page ,which says : The -H (HOME) option sets the HOME environment variable to the homedir of the target user (root by default) as specified in passwd(5). By default, sudo does not modify HOME But I have tried below command: #... (1 Reply)
Discussion started by: Michaelw321
1 Replies

8. Shell Programming and Scripting

[solved] awk: test assoc. array for content

Hi all, I am looking for a quick/short way in awk to check if an associative array has any content. I know I can split() it to an indexed array and check if the 1st element is set, or cycle through it with something like for( ele in arr ), but I want to avoid that, as I am looking for a shorter... (3 Replies)
Discussion started by: zaxxon
3 Replies

9. UNIX for Dummies Questions & Answers

[Solved] Custom actions in Thunar doesn't display at all.

I have came across a few websites stating some custom actions for Thunar - crunchbang ubuntu I tried inputting the stated commands to Thunar, but it doesn't display at all in mine. I tried "gksu thunar %f" ( Opens current folder with root permissions.) , but when I right click in a... (0 Replies)
Discussion started by: Hijanoqu
0 Replies

10. Shell Programming and Scripting

How to test that a string doesn't contain specific characters?

Hi ! :) I made this : #!/bin/bash rsa_dir="/etc/openvpn/easy-rsa/" rsa_key_dir="/etc/openvpn/easy-rsa/keys/" ccd_dir="/etc/openvpn/ccd/" regex_special_char='' cd $rsa_dir while read -p "Please can you enter the vpn's username : " username ] || ] || ] || ] do echo "Your entry... (10 Replies)
Discussion started by: Arnaudh78
10 Replies
joy(3alleg4)							  Allegro manual						      joy(3alleg4)

NAME
joy - Global array of joystick state information. Allegro game programming library. SYNOPSIS
#include <allegro.h> extern JOYSTICK_INFO joy[n]; DESCRIPTION
Global array of joystick state information, which is updated by the poll_joystick() function. Only the first num_joysticks elements will contain meaningful information. The JOYSTICK_INFO structure is defined as: typedef struct JOYSTICK_INFO { int flags; - status flags for this joystick int num_sticks; - how many stick inputs? int num_buttons; - how many buttons? JOYSTICK_STICK_INFO stick[n]; - stick state information JOYSTICK_BUTTON_INFO button[n]; - button state information } JOYSTICK_INFO; The button status is stored in the structure: typedef struct JOYSTICK_BUTTON_INFO { int b; - boolean on/off flag char *name; - description of this button } JOYSTICK_BUTTON_INFO; You may wish to display the button names as part of an input configuration screen to let the user choose what game function will be per- formed by each button, but in simpler situations you can safely assume that the first two elements in the button array will always be the main trigger controls. Each joystick will provide one or more stick inputs, of varying types. These can be digital controls which snap to specific positions (eg. a gamepad controller, the coolie hat on a Flightstick Pro or Wingman Extreme, or a normal joystick which hasn't yet been calibrated), or they can be full analogue inputs with a smooth range of motion. Sticks may also have different numbers of axes, for example a normal direc- tional control has two, but the Flightstick Pro throttle is only a single axis, and it is possible that the system could be extended in the future to support full 3d controllers. A stick input is described by the structure: typedef struct JOYSTICK_STICK_INFO { int flags; - status flags for this input int num_axis; - how many axes do we have? (note the misspelling) JOYSTICK_AXIS_INFO axis[n]; - axis state information char *name; - description of this input } JOYSTICK_STICK_INFO; A single joystick may provide several different stick inputs, but you can safely assume that the first element in the stick array will always be the main directional controller. Information about each of the stick axis is stored in the substructure: typedef struct JOYSTICK_AXIS_INFO { int pos; - analogue axis position int d1, d2; - digital axis position char *name; - description of this axis } JOYSTICK_AXIS_INFO; This provides both analogue input in the pos field (ranging from -128 to 128 or from 0 to 255, depending on the type of the control), and digital values in the d1 and d2 fields. For example, when describing the X-axis position, the pos field will hold the horizontal position of the joystick, d1 will be set if it is moved left, and d2 will be set if it is moved right. Allegro will fill in all these values regard- less of whether it is using a digital or analogue joystick, emulating the pos field for digital inputs by snapping it to the min, middle, and maximum positions, and emulating the d1 and d2 values for an analogue stick by comparing the current position with the centre point. The joystick flags field may contain any combination of the bit flags: JOYFLAG_DIGITAL This control is currently providing digital input. JOYFLAG_ANALOGUE This control is currently providing analogue input. JOYFLAG_CALIB_DIGITAL This control will be capable of providing digital input once it has been calibrated, but is not doing this at the moment. JOYFLAG_CALIB_ANALOGUE This control will be capable of providing analogue input once it has been calibrated, but is not doing this at the moment. JOYFLAG_CALIBRATE Indicates that this control needs to be calibrated. Many devices require multiple calibration steps, so you should call the calibrate_joystick() function from a loop until this flag is cleared. JOYFLAG_SIGNED Indicates that the analogue axis position is in signed format, ranging from -128 to 128. This is the case for all 2d direc- tional controls. JOYFLAG_UNSIGNED Indicates that the analogue axis position is in unsigned format, ranging from 0 to 255. This is the case for all 1d throt- tle controls. Note for people who spell funny: in case you don't like having to type "analogue", there are some #define aliases in allegro/joystick.h that will allow you to write "analog" instead. SEE ALSO
install_joystick(3alleg4), poll_joystick(3alleg4), num_joysticks(3alleg4), calibrate_joystick(3alleg4), calibrate_joystick_name(3alleg4), exjoy(3alleg4) Allegro version 4.4.2 joy(3alleg4)
All times are GMT -4. The time now is 02:30 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy