Changeset 11084 for trunk/Ohana/src/opihi/lib.shell/variable.c
- Timestamp:
- Jan 12, 2007, 4:26:31 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/opihi/lib.shell/variable.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/lib.shell/variable.c
r8134 r11084 244 244 } 245 245 246 double get_double_variable (char *name) { 247 248 int i; 249 char *local, *MacroName; 250 251 MacroName = GetMacroName (); 252 253 /* look for local variable first */ 254 ALLOCATE (local, char, strlen(name) + strlen(MacroName) + 2); 255 sprintf (local, "%s.%s", MacroName, name); 256 for (i = 0; i < Nvariables; i++) { /* find the variable mentioned */ 257 if (!strcmp(local, variables[i].name)) { 258 free (local); 246 double get_double_variable (char *name, int *found) { 247 248 int i; 249 char *local, *MacroName; 250 251 MacroName = GetMacroName (); 252 253 /* look for local variable first */ 254 ALLOCATE (local, char, strlen(name) + strlen(MacroName) + 2); 255 sprintf (local, "%s.%s", MacroName, name); 256 for (i = 0; i < Nvariables; i++) { /* find the variable mentioned */ 257 if (!strcmp(local, variables[i].name)) { 258 free (local); 259 *found = TRUE; 259 260 return (atof (variables[i].value)); 260 261 } … … 265 266 for (i = 0; i < Nvariables; i++) { /* find the variable mentioned */ 266 267 if (!strcmp(name, variables[i].name)) { 268 *found = TRUE; 267 269 return (atof (variables[i].value)); 268 270 } 269 271 } 272 *found = FALSE; 273 return (0.0); 274 } 275 276 int get_int_variable (char *name, int *found) { 277 278 int i; 279 char *local, *MacroName; 280 281 MacroName = GetMacroName (); 282 283 /* look for local variable first */ 284 ALLOCATE (local, char, strlen(name) + strlen(MacroName) + 2); 285 sprintf (local, "%s.%s", MacroName, name); 286 for (i = 0; i < Nvariables; i++) { /* find the variable mentioned */ 287 if (!strcmp(local, variables[i].name)) { 288 *found = TRUE; 289 free (local); 290 return (atof (variables[i].value)); 291 } 292 } 293 free (local); 294 295 /* look for global variable */ 296 for (i = 0; i < Nvariables; i++) { /* find the variable mentioned */ 297 if (!strcmp(name, variables[i].name)) { 298 *found = TRUE; 299 return (atof (variables[i].value)); 300 } 301 } 302 *found = FALSE; 270 303 return (0.0); 271 304 }
Note:
See TracChangeset
for help on using the changeset viewer.
