2 Copyright © 1995-2016, The AROS Development Team. All rights reserved.
9 /******************************************************************************
25 Jump to a new position in a script. If a label is specified, control
26 goes to the first Lab command found that has the same label. If no
27 label is specified, control goes to the first EndSkip command found.
29 If the BACK switch is given, the search for a matching Lab or
30 EndSkip command starts at the beginning of the script; otherwise the
31 search starts at the Skip command. If a matching Lab/EndSkip is not
32 found, an error is returned.
36 LABEL -- The label to skip to.
38 BACK -- Specify this if the label appears before the Skip statement
44 This command can only be used in scripts.
56 ******************************************************************************/
58 #include <proto/dos.h>
60 #include <dos/dosextens.h>
61 #include <dos/rdargs.h>
62 #include "dos_commanderrors.h"
63 #include <dos/stdio.h>
65 #include <aros/shcommands.h>
68 AROS_SHA(STRPTR
, , LABEL
, , NULL
),
69 AROS_SHA(BOOL
, , BACK
, /S
, FALSE
))
73 struct CommandLineInterface
*cli
= Cli();
74 BOOL labelFound
= FALSE
;
77 if (cli
== NULL
|| cli
->cli_CurrentInput
== cli
->cli_StandardInput
)
79 PrintFault(ERROR_SCRIPT_ONLY
, "Skip");
90 SelectInput(cli
->cli_CurrentInput
);
95 Seek(Input(), 0, OFFSET_BEGINNING
);
100 status
= ReadItem(buffer
, sizeof(buffer
), NULL
);
102 if (status
== ITEM_ERROR
)
107 if (status
!= ITEM_NOTHING
)
109 switch (FindArg("LAB,ENDSKIP", buffer
))
112 if (SHArg(LABEL
) != NULL
)
114 ReadItem(buffer
, sizeof(buffer
), NULL
);
116 if (FindArg(SHArg(LABEL
), buffer
) == 0)
130 /* Skip to the next line */
134 } while (a
!= '\n' && a
!= ENDSTREAMCH
);
136 if (a
== ENDSTREAMCH
)
141 if (!labelFound
&& SHArg(LABEL
) != NULL
)
143 SetIoErr(ERROR_OBJECT_NOT_FOUND
);
144 PrintFault(ERROR_OBJECT_NOT_FOUND
, "Skip");