New bitmap method SetRGBConversionFunction which can be used to
[tangerine.git] / workbench / c / shellcommands / Else.c
blob5f6b9bb963d9fcca071a177a404445dc9239e843
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: English
7 */
9 /*****************************************************************************
11 NAME
13 Else
15 SYNOPSIS
17 LOCATION
19 Workbench:C
21 FUNCTION
23 Separate the 'true' and 'false' blocks of an If statement. The block
24 following an Else command is executed if the condition in the previous
25 If statement was false.
27 INPUTS
29 RESULT
31 NOTES
33 EXAMPLE
35 If EXISTS Sys:Devs
36 Copy random.device Sys:Devs/
37 Else
38 Echo "Cannot find Sys:Devs"
39 EndIf
41 BUGS
43 SEE ALSO
45 If, EndIf
47 INTERNALS
49 HISTORY
51 12.01.2000 SDuvan implemented
53 ******************************************************************************/
55 #include <dos/dos.h>
56 #include <dos/dosextens.h>
57 #include <dos/rdargs.h>
58 #include <dos/stdio.h>
59 #include <proto/dos.h>
60 #include <dos_commanderrors.h>
62 #include <aros/shcommands.h>
64 AROS_SH0(Else,41.1)
66 AROS_SHCOMMAND_INIT
68 struct CommandLineInterface *cli = Cli();
71 if ((cli != NULL) && (cli->cli_CurrentInput != cli->cli_StandardInput))
73 BOOL found = FALSE;
74 int level = 1;
75 char buffer[256];
77 SelectInput(cli->cli_CurrentInput);
79 while (!found)
81 LONG status;
82 int temp;
84 status = ReadItem(buffer, sizeof(buffer), NULL);
86 if (status == ITEM_ERROR || ITEM_NOTHING)
88 break;
91 switch ((temp = FindArg("IF,ENDIF", buffer)))
93 case 0:
94 level++;
95 break;
97 case 1:
98 level--;
100 if (level == 0)
102 found = TRUE;
105 break;
108 /* Take care of long lines */
110 char a;
114 a = FGetC(Input());
115 } while(a != '\n' && a != ENDSTREAMCH);
119 if (!found)
121 PrintFault(ERROR_NO_MATCHING_ELSEENDIF, "Else");
123 return RETURN_FAIL;
126 else
128 PrintFault(ERROR_SCRIPT_ONLY, "Else");
130 return RETURN_ERROR;
133 return RETURN_OK;
135 AROS_SHCOMMAND_EXIT