Add support for optional function arguments
Currently functions only have very limited optional argument support,
this expands it so that we can have more complex sets of optional
arguments for functions, such as multiple arguments where not all need
to be provided. This will be used in the future for some upcoming
functionality.
Note that this does not support any generic optional argument format,
the commas always have to be provided unless an optional argument is at
the end of the parameter list. Thus, if you have a format with two
optional arguments and you want to omit the second, then you need to call
it as 'foo(2, , 3)`, rather than `foo(2, 3)`. This is important for
avoiding ambiguous situations, and is how many SUBs currently function.
The two functions that violate that requirement are INSTR() and
_INSTRREV(), which use the format `[?],?,?` and allow omitting the comma
for the first argument. This format is simply handled as a special case.
Fixes: #303
2023-02-07 05:57:10 +00:00
|
|
|
|
|
|
|
FUNCTION getelement$ (a$, elenum)
|
2023-02-13 03:38:29 +00:00
|
|
|
DIM p AS LONG, n AS LONG, i AS LONG
|
|
|
|
|
Add support for optional function arguments
Currently functions only have very limited optional argument support,
this expands it so that we can have more complex sets of optional
arguments for functions, such as multiple arguments where not all need
to be provided. This will be used in the future for some upcoming
functionality.
Note that this does not support any generic optional argument format,
the commas always have to be provided unless an optional argument is at
the end of the parameter list. Thus, if you have a format with two
optional arguments and you want to omit the second, then you need to call
it as 'foo(2, , 3)`, rather than `foo(2, 3)`. This is important for
avoiding ambiguous situations, and is how many SUBs currently function.
The two functions that violate that requirement are INSTR() and
_INSTRREV(), which use the format `[?],?,?` and allow omitting the comma
for the first argument. This format is simply handled as a special case.
Fixes: #303
2023-02-07 05:57:10 +00:00
|
|
|
IF a$ = "" THEN EXIT FUNCTION 'no elements!
|
|
|
|
|
|
|
|
n = 1
|
|
|
|
p = 1
|
|
|
|
getelementnext:
|
|
|
|
i = INSTR(p, a$, sp)
|
|
|
|
|
|
|
|
IF elenum = n THEN
|
|
|
|
IF i THEN
|
|
|
|
getelement$ = MID$(a$, p, i - p)
|
|
|
|
ELSE
|
|
|
|
getelement$ = RIGHT$(a$, LEN(a$) - p + 1)
|
|
|
|
END IF
|
|
|
|
EXIT FUNCTION
|
|
|
|
END IF
|
|
|
|
|
|
|
|
IF i = 0 THEN EXIT FUNCTION 'no more elements!
|
|
|
|
n = n + 1
|
|
|
|
p = i + 1
|
|
|
|
GOTO getelementnext
|
|
|
|
END FUNCTION
|
|
|
|
|
|
|
|
FUNCTION getelements$ (a$, i1, i2)
|
2023-02-13 03:38:29 +00:00
|
|
|
DIM p AS LONG, n AS LONG, i AS LONG, i1pos AS LONG
|
|
|
|
|
Add support for optional function arguments
Currently functions only have very limited optional argument support,
this expands it so that we can have more complex sets of optional
arguments for functions, such as multiple arguments where not all need
to be provided. This will be used in the future for some upcoming
functionality.
Note that this does not support any generic optional argument format,
the commas always have to be provided unless an optional argument is at
the end of the parameter list. Thus, if you have a format with two
optional arguments and you want to omit the second, then you need to call
it as 'foo(2, , 3)`, rather than `foo(2, 3)`. This is important for
avoiding ambiguous situations, and is how many SUBs currently function.
The two functions that violate that requirement are INSTR() and
_INSTRREV(), which use the format `[?],?,?` and allow omitting the comma
for the first argument. This format is simply handled as a special case.
Fixes: #303
2023-02-07 05:57:10 +00:00
|
|
|
IF i2 < i1 THEN getelements$ = "": EXIT FUNCTION
|
|
|
|
n = 1
|
|
|
|
p = 1
|
|
|
|
getelementsnext:
|
|
|
|
i = INSTR(p, a$, sp)
|
|
|
|
IF n = i1 THEN
|
|
|
|
i1pos = p
|
|
|
|
END IF
|
|
|
|
IF n = i2 THEN
|
|
|
|
IF i THEN
|
|
|
|
getelements$ = MID$(a$, i1pos, i - i1pos)
|
|
|
|
ELSE
|
|
|
|
getelements$ = RIGHT$(a$, LEN(a$) - i1pos + 1)
|
|
|
|
END IF
|
|
|
|
EXIT FUNCTION
|
|
|
|
END IF
|
|
|
|
n = n + 1
|
|
|
|
p = i + 1
|
|
|
|
GOTO getelementsnext
|
|
|
|
END FUNCTION
|
|
|
|
|
|
|
|
SUB insertelements (a$, i, elements$)
|
2023-02-13 03:38:29 +00:00
|
|
|
DIM a2 AS STRING, n AS LONG, i2 AS LONG
|
|
|
|
|
Add support for optional function arguments
Currently functions only have very limited optional argument support,
this expands it so that we can have more complex sets of optional
arguments for functions, such as multiple arguments where not all need
to be provided. This will be used in the future for some upcoming
functionality.
Note that this does not support any generic optional argument format,
the commas always have to be provided unless an optional argument is at
the end of the parameter list. Thus, if you have a format with two
optional arguments and you want to omit the second, then you need to call
it as 'foo(2, , 3)`, rather than `foo(2, 3)`. This is important for
avoiding ambiguous situations, and is how many SUBs currently function.
The two functions that violate that requirement are INSTR() and
_INSTRREV(), which use the format `[?],?,?` and allow omitting the comma
for the first argument. This format is simply handled as a special case.
Fixes: #303
2023-02-07 05:57:10 +00:00
|
|
|
IF i = 0 THEN
|
|
|
|
IF a$ = "" THEN
|
|
|
|
a$ = elements$
|
|
|
|
EXIT SUB
|
|
|
|
END IF
|
|
|
|
a$ = elements$ + sp + a$
|
|
|
|
EXIT SUB
|
|
|
|
END IF
|
|
|
|
|
|
|
|
a2$ = ""
|
|
|
|
n = numelements(a$)
|
|
|
|
|
|
|
|
FOR i2 = 1 TO n
|
|
|
|
IF i2 > 1 THEN a2$ = a2$ + sp
|
|
|
|
a2$ = a2$ + getelement$(a$, i2)
|
|
|
|
IF i = i2 THEN a2$ = a2$ + sp + elements$
|
|
|
|
NEXT
|
|
|
|
|
|
|
|
a$ = a2$
|
|
|
|
|
|
|
|
END SUB
|
|
|
|
|
|
|
|
FUNCTION numelements (a$)
|
2023-02-13 03:38:29 +00:00
|
|
|
DIM p AS LONG, n AS LONG, i AS LONG
|
|
|
|
|
Add support for optional function arguments
Currently functions only have very limited optional argument support,
this expands it so that we can have more complex sets of optional
arguments for functions, such as multiple arguments where not all need
to be provided. This will be used in the future for some upcoming
functionality.
Note that this does not support any generic optional argument format,
the commas always have to be provided unless an optional argument is at
the end of the parameter list. Thus, if you have a format with two
optional arguments and you want to omit the second, then you need to call
it as 'foo(2, , 3)`, rather than `foo(2, 3)`. This is important for
avoiding ambiguous situations, and is how many SUBs currently function.
The two functions that violate that requirement are INSTR() and
_INSTRREV(), which use the format `[?],?,?` and allow omitting the comma
for the first argument. This format is simply handled as a special case.
Fixes: #303
2023-02-07 05:57:10 +00:00
|
|
|
IF a$ = "" THEN EXIT FUNCTION
|
|
|
|
n = 1
|
|
|
|
p = 1
|
|
|
|
numelementsnext:
|
|
|
|
i = INSTR(p, a$, sp)
|
|
|
|
IF i = 0 THEN numelements = n: EXIT FUNCTION
|
|
|
|
n = n + 1
|
|
|
|
p = i + 1
|
|
|
|
GOTO numelementsnext
|
|
|
|
END FUNCTION
|
|
|
|
|
|
|
|
SUB removeelements (a$, first, last, keepindexing)
|
2023-02-13 03:38:29 +00:00
|
|
|
DIM n AS LONG, i AS LONG, a2 AS STRING
|
|
|
|
|
Add support for optional function arguments
Currently functions only have very limited optional argument support,
this expands it so that we can have more complex sets of optional
arguments for functions, such as multiple arguments where not all need
to be provided. This will be used in the future for some upcoming
functionality.
Note that this does not support any generic optional argument format,
the commas always have to be provided unless an optional argument is at
the end of the parameter list. Thus, if you have a format with two
optional arguments and you want to omit the second, then you need to call
it as 'foo(2, , 3)`, rather than `foo(2, 3)`. This is important for
avoiding ambiguous situations, and is how many SUBs currently function.
The two functions that violate that requirement are INSTR() and
_INSTRREV(), which use the format `[?],?,?` and allow omitting the comma
for the first argument. This format is simply handled as a special case.
Fixes: #303
2023-02-07 05:57:10 +00:00
|
|
|
a2$ = ""
|
|
|
|
'note: first and last MUST be valid
|
|
|
|
' keepindexing means the number of elements will stay the same
|
|
|
|
' but some elements will be equal to ""
|
|
|
|
|
|
|
|
n = numelements(a$)
|
|
|
|
FOR i = 1 TO n
|
|
|
|
IF i < first OR i > last THEN
|
|
|
|
a2$ = a2$ + sp + getelement(a$, i)
|
|
|
|
ELSE
|
|
|
|
IF keepindexing THEN a2$ = a2$ + sp
|
|
|
|
END IF
|
|
|
|
NEXT
|
|
|
|
IF LEFT$(a2$, 1) = sp THEN a2$ = RIGHT$(a2$, LEN(a2$) - 1)
|
|
|
|
|
|
|
|
a$ = a2$
|
|
|
|
|
|
|
|
END SUB
|
|
|
|
|
|
|
|
' a$ should be a function argument list
|
|
|
|
' Returns number of function arguments (including empty ones) in the provided list
|
|
|
|
FUNCTION countFunctionElements (a$)
|
2023-02-13 03:38:29 +00:00
|
|
|
DIM count AS LONG, p AS LONG, lvl AS LONG, i AS LONG
|
Add support for optional function arguments
Currently functions only have very limited optional argument support,
this expands it so that we can have more complex sets of optional
arguments for functions, such as multiple arguments where not all need
to be provided. This will be used in the future for some upcoming
functionality.
Note that this does not support any generic optional argument format,
the commas always have to be provided unless an optional argument is at
the end of the parameter list. Thus, if you have a format with two
optional arguments and you want to omit the second, then you need to call
it as 'foo(2, , 3)`, rather than `foo(2, 3)`. This is important for
avoiding ambiguous situations, and is how many SUBs currently function.
The two functions that violate that requirement are INSTR() and
_INSTRREV(), which use the format `[?],?,?` and allow omitting the comma
for the first argument. This format is simply handled as a special case.
Fixes: #303
2023-02-07 05:57:10 +00:00
|
|
|
p = 1
|
|
|
|
lvl = 1
|
|
|
|
i = 0
|
|
|
|
|
2023-02-13 03:38:29 +00:00
|
|
|
IF LEN(a$) = 0 THEN
|
Add support for optional function arguments
Currently functions only have very limited optional argument support,
this expands it so that we can have more complex sets of optional
arguments for functions, such as multiple arguments where not all need
to be provided. This will be used in the future for some upcoming
functionality.
Note that this does not support any generic optional argument format,
the commas always have to be provided unless an optional argument is at
the end of the parameter list. Thus, if you have a format with two
optional arguments and you want to omit the second, then you need to call
it as 'foo(2, , 3)`, rather than `foo(2, 3)`. This is important for
avoiding ambiguous situations, and is how many SUBs currently function.
The two functions that violate that requirement are INSTR() and
_INSTRREV(), which use the format `[?],?,?` and allow omitting the comma
for the first argument. This format is simply handled as a special case.
Fixes: #303
2023-02-07 05:57:10 +00:00
|
|
|
countFunctionElements = 0
|
2023-02-13 03:38:29 +00:00
|
|
|
EXIT FUNCTION
|
|
|
|
END IF
|
Add support for optional function arguments
Currently functions only have very limited optional argument support,
this expands it so that we can have more complex sets of optional
arguments for functions, such as multiple arguments where not all need
to be provided. This will be used in the future for some upcoming
functionality.
Note that this does not support any generic optional argument format,
the commas always have to be provided unless an optional argument is at
the end of the parameter list. Thus, if you have a format with two
optional arguments and you want to omit the second, then you need to call
it as 'foo(2, , 3)`, rather than `foo(2, 3)`. This is important for
avoiding ambiguous situations, and is how many SUBs currently function.
The two functions that violate that requirement are INSTR() and
_INSTRREV(), which use the format `[?],?,?` and allow omitting the comma
for the first argument. This format is simply handled as a special case.
Fixes: #303
2023-02-07 05:57:10 +00:00
|
|
|
|
2023-02-13 03:38:29 +00:00
|
|
|
DO
|
|
|
|
SELECT CASE ASC(a$, i + 1)
|
|
|
|
CASE ASC("("):
|
Add support for optional function arguments
Currently functions only have very limited optional argument support,
this expands it so that we can have more complex sets of optional
arguments for functions, such as multiple arguments where not all need
to be provided. This will be used in the future for some upcoming
functionality.
Note that this does not support any generic optional argument format,
the commas always have to be provided unless an optional argument is at
the end of the parameter list. Thus, if you have a format with two
optional arguments and you want to omit the second, then you need to call
it as 'foo(2, , 3)`, rather than `foo(2, 3)`. This is important for
avoiding ambiguous situations, and is how many SUBs currently function.
The two functions that violate that requirement are INSTR() and
_INSTRREV(), which use the format `[?],?,?` and allow omitting the comma
for the first argument. This format is simply handled as a special case.
Fixes: #303
2023-02-07 05:57:10 +00:00
|
|
|
lvl = lvl + 1
|
|
|
|
|
2023-02-13 03:38:29 +00:00
|
|
|
CASE ASC(")"):
|
Add support for optional function arguments
Currently functions only have very limited optional argument support,
this expands it so that we can have more complex sets of optional
arguments for functions, such as multiple arguments where not all need
to be provided. This will be used in the future for some upcoming
functionality.
Note that this does not support any generic optional argument format,
the commas always have to be provided unless an optional argument is at
the end of the parameter list. Thus, if you have a format with two
optional arguments and you want to omit the second, then you need to call
it as 'foo(2, , 3)`, rather than `foo(2, 3)`. This is important for
avoiding ambiguous situations, and is how many SUBs currently function.
The two functions that violate that requirement are INSTR() and
_INSTRREV(), which use the format `[?],?,?` and allow omitting the comma
for the first argument. This format is simply handled as a special case.
Fixes: #303
2023-02-07 05:57:10 +00:00
|
|
|
lvl = lvl - 1
|
|
|
|
|
2023-02-13 03:38:29 +00:00
|
|
|
CASE ASC(","):
|
|
|
|
IF lvl = 1 THEN
|
Add support for optional function arguments
Currently functions only have very limited optional argument support,
this expands it so that we can have more complex sets of optional
arguments for functions, such as multiple arguments where not all need
to be provided. This will be used in the future for some upcoming
functionality.
Note that this does not support any generic optional argument format,
the commas always have to be provided unless an optional argument is at
the end of the parameter list. Thus, if you have a format with two
optional arguments and you want to omit the second, then you need to call
it as 'foo(2, , 3)`, rather than `foo(2, 3)`. This is important for
avoiding ambiguous situations, and is how many SUBs currently function.
The two functions that violate that requirement are INSTR() and
_INSTRREV(), which use the format `[?],?,?` and allow omitting the comma
for the first argument. This format is simply handled as a special case.
Fixes: #303
2023-02-07 05:57:10 +00:00
|
|
|
count = count + 1
|
2023-02-13 03:38:29 +00:00
|
|
|
END IF
|
Add support for optional function arguments
Currently functions only have very limited optional argument support,
this expands it so that we can have more complex sets of optional
arguments for functions, such as multiple arguments where not all need
to be provided. This will be used in the future for some upcoming
functionality.
Note that this does not support any generic optional argument format,
the commas always have to be provided unless an optional argument is at
the end of the parameter list. Thus, if you have a format with two
optional arguments and you want to omit the second, then you need to call
it as 'foo(2, , 3)`, rather than `foo(2, 3)`. This is important for
avoiding ambiguous situations, and is how many SUBs currently function.
The two functions that violate that requirement are INSTR() and
_INSTRREV(), which use the format `[?],?,?` and allow omitting the comma
for the first argument. This format is simply handled as a special case.
Fixes: #303
2023-02-07 05:57:10 +00:00
|
|
|
|
2023-02-13 03:38:29 +00:00
|
|
|
END SELECT
|
Add support for optional function arguments
Currently functions only have very limited optional argument support,
this expands it so that we can have more complex sets of optional
arguments for functions, such as multiple arguments where not all need
to be provided. This will be used in the future for some upcoming
functionality.
Note that this does not support any generic optional argument format,
the commas always have to be provided unless an optional argument is at
the end of the parameter list. Thus, if you have a format with two
optional arguments and you want to omit the second, then you need to call
it as 'foo(2, , 3)`, rather than `foo(2, 3)`. This is important for
avoiding ambiguous situations, and is how many SUBs currently function.
The two functions that violate that requirement are INSTR() and
_INSTRREV(), which use the format `[?],?,?` and allow omitting the comma
for the first argument. This format is simply handled as a special case.
Fixes: #303
2023-02-07 05:57:10 +00:00
|
|
|
|
|
|
|
i = INSTR(p, a$, sp)
|
2023-02-13 03:38:29 +00:00
|
|
|
IF i = 0 THEN
|
|
|
|
EXIT DO
|
|
|
|
END IF
|
Add support for optional function arguments
Currently functions only have very limited optional argument support,
this expands it so that we can have more complex sets of optional
arguments for functions, such as multiple arguments where not all need
to be provided. This will be used in the future for some upcoming
functionality.
Note that this does not support any generic optional argument format,
the commas always have to be provided unless an optional argument is at
the end of the parameter list. Thus, if you have a format with two
optional arguments and you want to omit the second, then you need to call
it as 'foo(2, , 3)`, rather than `foo(2, 3)`. This is important for
avoiding ambiguous situations, and is how many SUBs currently function.
The two functions that violate that requirement are INSTR() and
_INSTRREV(), which use the format `[?],?,?` and allow omitting the comma
for the first argument. This format is simply handled as a special case.
Fixes: #303
2023-02-07 05:57:10 +00:00
|
|
|
|
|
|
|
p = i + 1
|
2023-02-13 03:38:29 +00:00
|
|
|
LOOP
|
Add support for optional function arguments
Currently functions only have very limited optional argument support,
this expands it so that we can have more complex sets of optional
arguments for functions, such as multiple arguments where not all need
to be provided. This will be used in the future for some upcoming
functionality.
Note that this does not support any generic optional argument format,
the commas always have to be provided unless an optional argument is at
the end of the parameter list. Thus, if you have a format with two
optional arguments and you want to omit the second, then you need to call
it as 'foo(2, , 3)`, rather than `foo(2, 3)`. This is important for
avoiding ambiguous situations, and is how many SUBs currently function.
The two functions that violate that requirement are INSTR() and
_INSTRREV(), which use the format `[?],?,?` and allow omitting the comma
for the first argument. This format is simply handled as a special case.
Fixes: #303
2023-02-07 05:57:10 +00:00
|
|
|
|
|
|
|
' Make sure to count the argument after the last comma
|
|
|
|
countFunctionElements = count + 1
|
|
|
|
END FUNCTION
|
|
|
|
|
|
|
|
' a$ should be a function argument list
|
|
|
|
' Returns true if the argument was provided in the list
|
2023-02-13 03:38:29 +00:00
|
|
|
FUNCTION hasFunctionElement (a$, element)
|
|
|
|
DIM count AS LONG, p AS LONG, lvl AS LONG, i AS LONG, start AS LONG
|
Add support for optional function arguments
Currently functions only have very limited optional argument support,
this expands it so that we can have more complex sets of optional
arguments for functions, such as multiple arguments where not all need
to be provided. This will be used in the future for some upcoming
functionality.
Note that this does not support any generic optional argument format,
the commas always have to be provided unless an optional argument is at
the end of the parameter list. Thus, if you have a format with two
optional arguments and you want to omit the second, then you need to call
it as 'foo(2, , 3)`, rather than `foo(2, 3)`. This is important for
avoiding ambiguous situations, and is how many SUBs currently function.
The two functions that violate that requirement are INSTR() and
_INSTRREV(), which use the format `[?],?,?` and allow omitting the comma
for the first argument. This format is simply handled as a special case.
Fixes: #303
2023-02-07 05:57:10 +00:00
|
|
|
start = 0
|
|
|
|
p = 1
|
|
|
|
lvl = 1
|
|
|
|
i = 1
|
|
|
|
|
2023-02-13 03:38:29 +00:00
|
|
|
IF LEN(a$) = 0 THEN
|
Add support for optional function arguments
Currently functions only have very limited optional argument support,
this expands it so that we can have more complex sets of optional
arguments for functions, such as multiple arguments where not all need
to be provided. This will be used in the future for some upcoming
functionality.
Note that this does not support any generic optional argument format,
the commas always have to be provided unless an optional argument is at
the end of the parameter list. Thus, if you have a format with two
optional arguments and you want to omit the second, then you need to call
it as 'foo(2, , 3)`, rather than `foo(2, 3)`. This is important for
avoiding ambiguous situations, and is how many SUBs currently function.
The two functions that violate that requirement are INSTR() and
_INSTRREV(), which use the format `[?],?,?` and allow omitting the comma
for the first argument. This format is simply handled as a special case.
Fixes: #303
2023-02-07 05:57:10 +00:00
|
|
|
hasFunctionElement = 0
|
2023-02-13 03:38:29 +00:00
|
|
|
EXIT FUNCTION
|
|
|
|
END IF
|
Add support for optional function arguments
Currently functions only have very limited optional argument support,
this expands it so that we can have more complex sets of optional
arguments for functions, such as multiple arguments where not all need
to be provided. This will be used in the future for some upcoming
functionality.
Note that this does not support any generic optional argument format,
the commas always have to be provided unless an optional argument is at
the end of the parameter list. Thus, if you have a format with two
optional arguments and you want to omit the second, then you need to call
it as 'foo(2, , 3)`, rather than `foo(2, 3)`. This is important for
avoiding ambiguous situations, and is how many SUBs currently function.
The two functions that violate that requirement are INSTR() and
_INSTRREV(), which use the format `[?],?,?` and allow omitting the comma
for the first argument. This format is simply handled as a special case.
Fixes: #303
2023-02-07 05:57:10 +00:00
|
|
|
|
|
|
|
' Special case for a single provided argument
|
2023-02-13 03:38:29 +00:00
|
|
|
IF INSTR(a$, sp) = 0 AND LEN(a$) <> 0 THEN
|
Add support for optional function arguments
Currently functions only have very limited optional argument support,
this expands it so that we can have more complex sets of optional
arguments for functions, such as multiple arguments where not all need
to be provided. This will be used in the future for some upcoming
functionality.
Note that this does not support any generic optional argument format,
the commas always have to be provided unless an optional argument is at
the end of the parameter list. Thus, if you have a format with two
optional arguments and you want to omit the second, then you need to call
it as 'foo(2, , 3)`, rather than `foo(2, 3)`. This is important for
avoiding ambiguous situations, and is how many SUBs currently function.
The two functions that violate that requirement are INSTR() and
_INSTRREV(), which use the format `[?],?,?` and allow omitting the comma
for the first argument. This format is simply handled as a special case.
Fixes: #303
2023-02-07 05:57:10 +00:00
|
|
|
hasFunctionElement = element = 1
|
2023-02-13 03:38:29 +00:00
|
|
|
EXIT FUNCTION
|
|
|
|
END IF
|
Add support for optional function arguments
Currently functions only have very limited optional argument support,
this expands it so that we can have more complex sets of optional
arguments for functions, such as multiple arguments where not all need
to be provided. This will be used in the future for some upcoming
functionality.
Note that this does not support any generic optional argument format,
the commas always have to be provided unless an optional argument is at
the end of the parameter list. Thus, if you have a format with two
optional arguments and you want to omit the second, then you need to call
it as 'foo(2, , 3)`, rather than `foo(2, 3)`. This is important for
avoiding ambiguous situations, and is how many SUBs currently function.
The two functions that violate that requirement are INSTR() and
_INSTRREV(), which use the format `[?],?,?` and allow omitting the comma
for the first argument. This format is simply handled as a special case.
Fixes: #303
2023-02-07 05:57:10 +00:00
|
|
|
|
2023-02-13 03:38:29 +00:00
|
|
|
DO
|
|
|
|
IF i > LEN(a$) THEN
|
|
|
|
EXIT DO
|
|
|
|
END IF
|
Add support for optional function arguments
Currently functions only have very limited optional argument support,
this expands it so that we can have more complex sets of optional
arguments for functions, such as multiple arguments where not all need
to be provided. This will be used in the future for some upcoming
functionality.
Note that this does not support any generic optional argument format,
the commas always have to be provided unless an optional argument is at
the end of the parameter list. Thus, if you have a format with two
optional arguments and you want to omit the second, then you need to call
it as 'foo(2, , 3)`, rather than `foo(2, 3)`. This is important for
avoiding ambiguous situations, and is how many SUBs currently function.
The two functions that violate that requirement are INSTR() and
_INSTRREV(), which use the format `[?],?,?` and allow omitting the comma
for the first argument. This format is simply handled as a special case.
Fixes: #303
2023-02-07 05:57:10 +00:00
|
|
|
|
2023-02-13 03:38:29 +00:00
|
|
|
SELECT CASE ASC(a$, i)
|
|
|
|
CASE ASC("("):
|
Add support for optional function arguments
Currently functions only have very limited optional argument support,
this expands it so that we can have more complex sets of optional
arguments for functions, such as multiple arguments where not all need
to be provided. This will be used in the future for some upcoming
functionality.
Note that this does not support any generic optional argument format,
the commas always have to be provided unless an optional argument is at
the end of the parameter list. Thus, if you have a format with two
optional arguments and you want to omit the second, then you need to call
it as 'foo(2, , 3)`, rather than `foo(2, 3)`. This is important for
avoiding ambiguous situations, and is how many SUBs currently function.
The two functions that violate that requirement are INSTR() and
_INSTRREV(), which use the format `[?],?,?` and allow omitting the comma
for the first argument. This format is simply handled as a special case.
Fixes: #303
2023-02-07 05:57:10 +00:00
|
|
|
lvl = lvl + 1
|
|
|
|
|
2023-02-13 03:38:29 +00:00
|
|
|
CASE ASC(")"):
|
Add support for optional function arguments
Currently functions only have very limited optional argument support,
this expands it so that we can have more complex sets of optional
arguments for functions, such as multiple arguments where not all need
to be provided. This will be used in the future for some upcoming
functionality.
Note that this does not support any generic optional argument format,
the commas always have to be provided unless an optional argument is at
the end of the parameter list. Thus, if you have a format with two
optional arguments and you want to omit the second, then you need to call
it as 'foo(2, , 3)`, rather than `foo(2, 3)`. This is important for
avoiding ambiguous situations, and is how many SUBs currently function.
The two functions that violate that requirement are INSTR() and
_INSTRREV(), which use the format `[?],?,?` and allow omitting the comma
for the first argument. This format is simply handled as a special case.
Fixes: #303
2023-02-07 05:57:10 +00:00
|
|
|
lvl = lvl - 1
|
|
|
|
|
2023-02-13 03:38:29 +00:00
|
|
|
CASE ASC(","):
|
|
|
|
IF lvl = 1 THEN
|
Add support for optional function arguments
Currently functions only have very limited optional argument support,
this expands it so that we can have more complex sets of optional
arguments for functions, such as multiple arguments where not all need
to be provided. This will be used in the future for some upcoming
functionality.
Note that this does not support any generic optional argument format,
the commas always have to be provided unless an optional argument is at
the end of the parameter list. Thus, if you have a format with two
optional arguments and you want to omit the second, then you need to call
it as 'foo(2, , 3)`, rather than `foo(2, 3)`. This is important for
avoiding ambiguous situations, and is how many SUBs currently function.
The two functions that violate that requirement are INSTR() and
_INSTRREV(), which use the format `[?],?,?` and allow omitting the comma
for the first argument. This format is simply handled as a special case.
Fixes: #303
2023-02-07 05:57:10 +00:00
|
|
|
count = count + 1
|
|
|
|
|
2023-02-13 03:38:29 +00:00
|
|
|
IF element = count THEN
|
Add support for optional function arguments
Currently functions only have very limited optional argument support,
this expands it so that we can have more complex sets of optional
arguments for functions, such as multiple arguments where not all need
to be provided. This will be used in the future for some upcoming
functionality.
Note that this does not support any generic optional argument format,
the commas always have to be provided unless an optional argument is at
the end of the parameter list. Thus, if you have a format with two
optional arguments and you want to omit the second, then you need to call
it as 'foo(2, , 3)`, rather than `foo(2, 3)`. This is important for
avoiding ambiguous situations, and is how many SUBs currently function.
The two functions that violate that requirement are INSTR() and
_INSTRREV(), which use the format `[?],?,?` and allow omitting the comma
for the first argument. This format is simply handled as a special case.
Fixes: #303
2023-02-07 05:57:10 +00:00
|
|
|
' We have a element here if there's any elements
|
|
|
|
' inbetween the previous comma and this one
|
2023-02-13 03:38:29 +00:00
|
|
|
hasFunctionElement = (i <> 1) AND (i - 2 <> start)
|
|
|
|
EXIT FUNCTION
|
|
|
|
END IF
|
Add support for optional function arguments
Currently functions only have very limited optional argument support,
this expands it so that we can have more complex sets of optional
arguments for functions, such as multiple arguments where not all need
to be provided. This will be used in the future for some upcoming
functionality.
Note that this does not support any generic optional argument format,
the commas always have to be provided unless an optional argument is at
the end of the parameter list. Thus, if you have a format with two
optional arguments and you want to omit the second, then you need to call
it as 'foo(2, , 3)`, rather than `foo(2, 3)`. This is important for
avoiding ambiguous situations, and is how many SUBs currently function.
The two functions that violate that requirement are INSTR() and
_INSTRREV(), which use the format `[?],?,?` and allow omitting the comma
for the first argument. This format is simply handled as a special case.
Fixes: #303
2023-02-07 05:57:10 +00:00
|
|
|
|
|
|
|
start = i
|
2023-02-13 03:38:29 +00:00
|
|
|
END IF
|
|
|
|
END SELECT
|
Add support for optional function arguments
Currently functions only have very limited optional argument support,
this expands it so that we can have more complex sets of optional
arguments for functions, such as multiple arguments where not all need
to be provided. This will be used in the future for some upcoming
functionality.
Note that this does not support any generic optional argument format,
the commas always have to be provided unless an optional argument is at
the end of the parameter list. Thus, if you have a format with two
optional arguments and you want to omit the second, then you need to call
it as 'foo(2, , 3)`, rather than `foo(2, 3)`. This is important for
avoiding ambiguous situations, and is how many SUBs currently function.
The two functions that violate that requirement are INSTR() and
_INSTRREV(), which use the format `[?],?,?` and allow omitting the comma
for the first argument. This format is simply handled as a special case.
Fixes: #303
2023-02-07 05:57:10 +00:00
|
|
|
|
|
|
|
p = i
|
|
|
|
i = INSTR(i, a$, sp)
|
|
|
|
|
2023-02-13 03:38:29 +00:00
|
|
|
IF i = 0 THEN
|
|
|
|
EXIT DO
|
|
|
|
END IF
|
Add support for optional function arguments
Currently functions only have very limited optional argument support,
this expands it so that we can have more complex sets of optional
arguments for functions, such as multiple arguments where not all need
to be provided. This will be used in the future for some upcoming
functionality.
Note that this does not support any generic optional argument format,
the commas always have to be provided unless an optional argument is at
the end of the parameter list. Thus, if you have a format with two
optional arguments and you want to omit the second, then you need to call
it as 'foo(2, , 3)`, rather than `foo(2, 3)`. This is important for
avoiding ambiguous situations, and is how many SUBs currently function.
The two functions that violate that requirement are INSTR() and
_INSTRREV(), which use the format `[?],?,?` and allow omitting the comma
for the first argument. This format is simply handled as a special case.
Fixes: #303
2023-02-07 05:57:10 +00:00
|
|
|
|
|
|
|
i = i + 1
|
2023-02-13 03:38:29 +00:00
|
|
|
LOOP
|
Add support for optional function arguments
Currently functions only have very limited optional argument support,
this expands it so that we can have more complex sets of optional
arguments for functions, such as multiple arguments where not all need
to be provided. This will be used in the future for some upcoming
functionality.
Note that this does not support any generic optional argument format,
the commas always have to be provided unless an optional argument is at
the end of the parameter list. Thus, if you have a format with two
optional arguments and you want to omit the second, then you need to call
it as 'foo(2, , 3)`, rather than `foo(2, 3)`. This is important for
avoiding ambiguous situations, and is how many SUBs currently function.
The two functions that violate that requirement are INSTR() and
_INSTRREV(), which use the format `[?],?,?` and allow omitting the comma
for the first argument. This format is simply handled as a special case.
Fixes: #303
2023-02-07 05:57:10 +00:00
|
|
|
|
2023-02-13 03:38:29 +00:00
|
|
|
IF element > count + 1 THEN
|
Add support for optional function arguments
Currently functions only have very limited optional argument support,
this expands it so that we can have more complex sets of optional
arguments for functions, such as multiple arguments where not all need
to be provided. This will be used in the future for some upcoming
functionality.
Note that this does not support any generic optional argument format,
the commas always have to be provided unless an optional argument is at
the end of the parameter list. Thus, if you have a format with two
optional arguments and you want to omit the second, then you need to call
it as 'foo(2, , 3)`, rather than `foo(2, 3)`. This is important for
avoiding ambiguous situations, and is how many SUBs currently function.
The two functions that violate that requirement are INSTR() and
_INSTRREV(), which use the format `[?],?,?` and allow omitting the comma
for the first argument. This format is simply handled as a special case.
Fixes: #303
2023-02-07 05:57:10 +00:00
|
|
|
hasFunctionElement = 0
|
2023-02-13 03:38:29 +00:00
|
|
|
EXIT FUNCTION
|
|
|
|
END IF
|
Add support for optional function arguments
Currently functions only have very limited optional argument support,
this expands it so that we can have more complex sets of optional
arguments for functions, such as multiple arguments where not all need
to be provided. This will be used in the future for some upcoming
functionality.
Note that this does not support any generic optional argument format,
the commas always have to be provided unless an optional argument is at
the end of the parameter list. Thus, if you have a format with two
optional arguments and you want to omit the second, then you need to call
it as 'foo(2, , 3)`, rather than `foo(2, 3)`. This is important for
avoiding ambiguous situations, and is how many SUBs currently function.
The two functions that violate that requirement are INSTR() and
_INSTRREV(), which use the format `[?],?,?` and allow omitting the comma
for the first argument. This format is simply handled as a special case.
Fixes: #303
2023-02-07 05:57:10 +00:00
|
|
|
|
|
|
|
' Check if last argument was provided.
|
|
|
|
'
|
|
|
|
' Syntax '2,3' has two arguments, the '3' argument is what gets compared here
|
|
|
|
' Syntax '2,' has one argument, the comma is the last element so it fails this check.
|
2023-02-13 03:38:29 +00:00
|
|
|
IF p > 0 THEN
|
|
|
|
IF ASC(a$, p) <> ASC(",") THEN
|
Add support for optional function arguments
Currently functions only have very limited optional argument support,
this expands it so that we can have more complex sets of optional
arguments for functions, such as multiple arguments where not all need
to be provided. This will be used in the future for some upcoming
functionality.
Note that this does not support any generic optional argument format,
the commas always have to be provided unless an optional argument is at
the end of the parameter list. Thus, if you have a format with two
optional arguments and you want to omit the second, then you need to call
it as 'foo(2, , 3)`, rather than `foo(2, 3)`. This is important for
avoiding ambiguous situations, and is how many SUBs currently function.
The two functions that violate that requirement are INSTR() and
_INSTRREV(), which use the format `[?],?,?` and allow omitting the comma
for the first argument. This format is simply handled as a special case.
Fixes: #303
2023-02-07 05:57:10 +00:00
|
|
|
hasFunctionElement = -1
|
2023-02-13 03:38:29 +00:00
|
|
|
EXIT FUNCTION
|
|
|
|
END IF
|
|
|
|
END IF
|
Add support for optional function arguments
Currently functions only have very limited optional argument support,
this expands it so that we can have more complex sets of optional
arguments for functions, such as multiple arguments where not all need
to be provided. This will be used in the future for some upcoming
functionality.
Note that this does not support any generic optional argument format,
the commas always have to be provided unless an optional argument is at
the end of the parameter list. Thus, if you have a format with two
optional arguments and you want to omit the second, then you need to call
it as 'foo(2, , 3)`, rather than `foo(2, 3)`. This is important for
avoiding ambiguous situations, and is how many SUBs currently function.
The two functions that violate that requirement are INSTR() and
_INSTRREV(), which use the format `[?],?,?` and allow omitting the comma
for the first argument. This format is simply handled as a special case.
Fixes: #303
2023-02-07 05:57:10 +00:00
|
|
|
|
|
|
|
hasFunctionElement = 0
|
|
|
|
END FUNCTION
|
|
|
|
|
|
|
|
' Returns true if the provided arguments are a valid set for the given function format
|
|
|
|
' firstOptionalArgument returns the index of the first argument that is optional
|
2023-02-13 03:38:29 +00:00
|
|
|
FUNCTION isValidArgSet (format AS STRING, providedArgs() AS LONG, firstOptionalArgument AS LONG)
|
|
|
|
DIM maxArgument AS LONG, i AS LONG
|
|
|
|
DIM currentArg AS LONG, optionLvl AS LONG
|
|
|
|
DIM wasProvided(0 TO 10) AS LONG
|
|
|
|
DIM AS LONG ArgProvided, ArgNotProvided, ArgIgnored
|
Add support for optional function arguments
Currently functions only have very limited optional argument support,
this expands it so that we can have more complex sets of optional
arguments for functions, such as multiple arguments where not all need
to be provided. This will be used in the future for some upcoming
functionality.
Note that this does not support any generic optional argument format,
the commas always have to be provided unless an optional argument is at
the end of the parameter list. Thus, if you have a format with two
optional arguments and you want to omit the second, then you need to call
it as 'foo(2, , 3)`, rather than `foo(2, 3)`. This is important for
avoiding ambiguous situations, and is how many SUBs currently function.
The two functions that violate that requirement are INSTR() and
_INSTRREV(), which use the format `[?],?,?` and allow omitting the comma
for the first argument. This format is simply handled as a special case.
Fixes: #303
2023-02-07 05:57:10 +00:00
|
|
|
|
|
|
|
ArgProvided = -1
|
|
|
|
ArgNotProvided = 0
|
|
|
|
ArgIgnored = -2
|
|
|
|
firstOptionalArgument = 0
|
|
|
|
|
|
|
|
wasProvided(0) = ArgIgnored
|
|
|
|
|
|
|
|
' Inside of each set of brackets, all arguments must either be provide or not provided, with no mixing.
|
|
|
|
' For nested brackets, if the argument(s) inside the nested brackets are
|
|
|
|
' provided, then the arguments inside the outer brackets also have to be
|
|
|
|
' provided. Ex:
|
|
|
|
'
|
|
|
|
' x[,y[,z]]
|
|
|
|
'
|
|
|
|
' When x is provided, y and z are optional, but when y is provided x is required.
|
|
|
|
' When z is provided both y and x are required.
|
|
|
|
|
|
|
|
maxArgument = UBOUND(providedArgs)
|
|
|
|
|
2023-02-13 03:38:29 +00:00
|
|
|
FOR i = 1 TO LEN(format)
|
|
|
|
SELECT CASE ASC(format, i)
|
|
|
|
CASE ASC("["):
|
Add support for optional function arguments
Currently functions only have very limited optional argument support,
this expands it so that we can have more complex sets of optional
arguments for functions, such as multiple arguments where not all need
to be provided. This will be used in the future for some upcoming
functionality.
Note that this does not support any generic optional argument format,
the commas always have to be provided unless an optional argument is at
the end of the parameter list. Thus, if you have a format with two
optional arguments and you want to omit the second, then you need to call
it as 'foo(2, , 3)`, rather than `foo(2, 3)`. This is important for
avoiding ambiguous situations, and is how many SUBs currently function.
The two functions that violate that requirement are INSTR() and
_INSTRREV(), which use the format `[?],?,?` and allow omitting the comma
for the first argument. This format is simply handled as a special case.
Fixes: #303
2023-02-07 05:57:10 +00:00
|
|
|
optionLvl = optionLvl + 1
|
|
|
|
wasProvided(optionLvl) = ArgIgnored
|
|
|
|
|
2023-02-13 03:38:29 +00:00
|
|
|
CASE ASC("]"):
|
Add support for optional function arguments
Currently functions only have very limited optional argument support,
this expands it so that we can have more complex sets of optional
arguments for functions, such as multiple arguments where not all need
to be provided. This will be used in the future for some upcoming
functionality.
Note that this does not support any generic optional argument format,
the commas always have to be provided unless an optional argument is at
the end of the parameter list. Thus, if you have a format with two
optional arguments and you want to omit the second, then you need to call
it as 'foo(2, , 3)`, rather than `foo(2, 3)`. This is important for
avoiding ambiguous situations, and is how many SUBs currently function.
The two functions that violate that requirement are INSTR() and
_INSTRREV(), which use the format `[?],?,?` and allow omitting the comma
for the first argument. This format is simply handled as a special case.
Fixes: #303
2023-02-07 05:57:10 +00:00
|
|
|
optionLvl = optionLvl - 1
|
|
|
|
|
2023-02-13 03:38:29 +00:00
|
|
|
IF wasProvided(optionLvl) = ArgIgnored THEN
|
Add support for optional function arguments
Currently functions only have very limited optional argument support,
this expands it so that we can have more complex sets of optional
arguments for functions, such as multiple arguments where not all need
to be provided. This will be used in the future for some upcoming
functionality.
Note that this does not support any generic optional argument format,
the commas always have to be provided unless an optional argument is at
the end of the parameter list. Thus, if you have a format with two
optional arguments and you want to omit the second, then you need to call
it as 'foo(2, , 3)`, rather than `foo(2, 3)`. This is important for
avoiding ambiguous situations, and is how many SUBs currently function.
The two functions that violate that requirement are INSTR() and
_INSTRREV(), which use the format `[?],?,?` and allow omitting the comma
for the first argument. This format is simply handled as a special case.
Fixes: #303
2023-02-07 05:57:10 +00:00
|
|
|
' If not provided, then we stay in the ignored state
|
|
|
|
' because whether this arg set was provided does not matter
|
|
|
|
' for the rest of the parsing
|
2023-02-13 03:38:29 +00:00
|
|
|
IF wasProvided(optionLvl + 1) = ArgProvided THEN
|
Add support for optional function arguments
Currently functions only have very limited optional argument support,
this expands it so that we can have more complex sets of optional
arguments for functions, such as multiple arguments where not all need
to be provided. This will be used in the future for some upcoming
functionality.
Note that this does not support any generic optional argument format,
the commas always have to be provided unless an optional argument is at
the end of the parameter list. Thus, if you have a format with two
optional arguments and you want to omit the second, then you need to call
it as 'foo(2, , 3)`, rather than `foo(2, 3)`. This is important for
avoiding ambiguous situations, and is how many SUBs currently function.
The two functions that violate that requirement are INSTR() and
_INSTRREV(), which use the format `[?],?,?` and allow omitting the comma
for the first argument. This format is simply handled as a special case.
Fixes: #303
2023-02-07 05:57:10 +00:00
|
|
|
wasProvided(optionLvl) = ArgProvided
|
2023-02-13 03:38:29 +00:00
|
|
|
END IF
|
|
|
|
ELSE
|
Add support for optional function arguments
Currently functions only have very limited optional argument support,
this expands it so that we can have more complex sets of optional
arguments for functions, such as multiple arguments where not all need
to be provided. This will be used in the future for some upcoming
functionality.
Note that this does not support any generic optional argument format,
the commas always have to be provided unless an optional argument is at
the end of the parameter list. Thus, if you have a format with two
optional arguments and you want to omit the second, then you need to call
it as 'foo(2, , 3)`, rather than `foo(2, 3)`. This is important for
avoiding ambiguous situations, and is how many SUBs currently function.
The two functions that violate that requirement are INSTR() and
_INSTRREV(), which use the format `[?],?,?` and allow omitting the comma
for the first argument. This format is simply handled as a special case.
Fixes: #303
2023-02-07 05:57:10 +00:00
|
|
|
' If an arg at this level was already not provided, then
|
|
|
|
' this optional set can't be provided either
|
2023-02-13 03:38:29 +00:00
|
|
|
IF wasProvided(optionLvl) = ArgNotProvided AND wasProvided(optionLvl + 1) = ArgProvided THEN
|
Add support for optional function arguments
Currently functions only have very limited optional argument support,
this expands it so that we can have more complex sets of optional
arguments for functions, such as multiple arguments where not all need
to be provided. This will be used in the future for some upcoming
functionality.
Note that this does not support any generic optional argument format,
the commas always have to be provided unless an optional argument is at
the end of the parameter list. Thus, if you have a format with two
optional arguments and you want to omit the second, then you need to call
it as 'foo(2, , 3)`, rather than `foo(2, 3)`. This is important for
avoiding ambiguous situations, and is how many SUBs currently function.
The two functions that violate that requirement are INSTR() and
_INSTRREV(), which use the format `[?],?,?` and allow omitting the comma
for the first argument. This format is simply handled as a special case.
Fixes: #303
2023-02-07 05:57:10 +00:00
|
|
|
isValidArgSet = 0
|
|
|
|
EXIT FUNCTION
|
2023-02-13 03:38:29 +00:00
|
|
|
END IF
|
|
|
|
END IF
|
Add support for optional function arguments
Currently functions only have very limited optional argument support,
this expands it so that we can have more complex sets of optional
arguments for functions, such as multiple arguments where not all need
to be provided. This will be used in the future for some upcoming
functionality.
Note that this does not support any generic optional argument format,
the commas always have to be provided unless an optional argument is at
the end of the parameter list. Thus, if you have a format with two
optional arguments and you want to omit the second, then you need to call
it as 'foo(2, , 3)`, rather than `foo(2, 3)`. This is important for
avoiding ambiguous situations, and is how many SUBs currently function.
The two functions that violate that requirement are INSTR() and
_INSTRREV(), which use the format `[?],?,?` and allow omitting the comma
for the first argument. This format is simply handled as a special case.
Fixes: #303
2023-02-07 05:57:10 +00:00
|
|
|
|
2023-02-13 03:38:29 +00:00
|
|
|
CASE ASC("?"):
|
Add support for optional function arguments
Currently functions only have very limited optional argument support,
this expands it so that we can have more complex sets of optional
arguments for functions, such as multiple arguments where not all need
to be provided. This will be used in the future for some upcoming
functionality.
Note that this does not support any generic optional argument format,
the commas always have to be provided unless an optional argument is at
the end of the parameter list. Thus, if you have a format with two
optional arguments and you want to omit the second, then you need to call
it as 'foo(2, , 3)`, rather than `foo(2, 3)`. This is important for
avoiding ambiguous situations, and is how many SUBs currently function.
The two functions that violate that requirement are INSTR() and
_INSTRREV(), which use the format `[?],?,?` and allow omitting the comma
for the first argument. This format is simply handled as a special case.
Fixes: #303
2023-02-07 05:57:10 +00:00
|
|
|
currentArg = currentArg + 1
|
2023-02-13 03:38:29 +00:00
|
|
|
IF optionLvl >= 1 AND firstOptionalArgument = 0 THEN firstOptionalArgument = currentArg
|
Add support for optional function arguments
Currently functions only have very limited optional argument support,
this expands it so that we can have more complex sets of optional
arguments for functions, such as multiple arguments where not all need
to be provided. This will be used in the future for some upcoming
functionality.
Note that this does not support any generic optional argument format,
the commas always have to be provided unless an optional argument is at
the end of the parameter list. Thus, if you have a format with two
optional arguments and you want to omit the second, then you need to call
it as 'foo(2, , 3)`, rather than `foo(2, 3)`. This is important for
avoiding ambiguous situations, and is how many SUBs currently function.
The two functions that violate that requirement are INSTR() and
_INSTRREV(), which use the format `[?],?,?` and allow omitting the comma
for the first argument. This format is simply handled as a special case.
Fixes: #303
2023-02-07 05:57:10 +00:00
|
|
|
|
2023-02-13 03:38:29 +00:00
|
|
|
IF wasProvided(optionLvl) = ArgIgnored THEN
|
|
|
|
IF maxArgument >= currentArg THEN
|
Add support for optional function arguments
Currently functions only have very limited optional argument support,
this expands it so that we can have more complex sets of optional
arguments for functions, such as multiple arguments where not all need
to be provided. This will be used in the future for some upcoming
functionality.
Note that this does not support any generic optional argument format,
the commas always have to be provided unless an optional argument is at
the end of the parameter list. Thus, if you have a format with two
optional arguments and you want to omit the second, then you need to call
it as 'foo(2, , 3)`, rather than `foo(2, 3)`. This is important for
avoiding ambiguous situations, and is how many SUBs currently function.
The two functions that violate that requirement are INSTR() and
_INSTRREV(), which use the format `[?],?,?` and allow omitting the comma
for the first argument. This format is simply handled as a special case.
Fixes: #303
2023-02-07 05:57:10 +00:00
|
|
|
wasProvided(optionLvl) = providedArgs(currentArg)
|
2023-02-13 03:38:29 +00:00
|
|
|
ELSE
|
Add support for optional function arguments
Currently functions only have very limited optional argument support,
this expands it so that we can have more complex sets of optional
arguments for functions, such as multiple arguments where not all need
to be provided. This will be used in the future for some upcoming
functionality.
Note that this does not support any generic optional argument format,
the commas always have to be provided unless an optional argument is at
the end of the parameter list. Thus, if you have a format with two
optional arguments and you want to omit the second, then you need to call
it as 'foo(2, , 3)`, rather than `foo(2, 3)`. This is important for
avoiding ambiguous situations, and is how many SUBs currently function.
The two functions that violate that requirement are INSTR() and
_INSTRREV(), which use the format `[?],?,?` and allow omitting the comma
for the first argument. This format is simply handled as a special case.
Fixes: #303
2023-02-07 05:57:10 +00:00
|
|
|
wasProvided(optionLvl) = 0
|
2023-02-13 03:38:29 +00:00
|
|
|
END IF
|
|
|
|
ELSE
|
|
|
|
IF maxArgument < currentArg THEN
|
|
|
|
IF wasProvided(optionLvl) <> ArgNotProvided THEN
|
Add support for optional function arguments
Currently functions only have very limited optional argument support,
this expands it so that we can have more complex sets of optional
arguments for functions, such as multiple arguments where not all need
to be provided. This will be used in the future for some upcoming
functionality.
Note that this does not support any generic optional argument format,
the commas always have to be provided unless an optional argument is at
the end of the parameter list. Thus, if you have a format with two
optional arguments and you want to omit the second, then you need to call
it as 'foo(2, , 3)`, rather than `foo(2, 3)`. This is important for
avoiding ambiguous situations, and is how many SUBs currently function.
The two functions that violate that requirement are INSTR() and
_INSTRREV(), which use the format `[?],?,?` and allow omitting the comma
for the first argument. This format is simply handled as a special case.
Fixes: #303
2023-02-07 05:57:10 +00:00
|
|
|
isValidArgSet = 0
|
2023-02-13 03:38:29 +00:00
|
|
|
EXIT FUNCTION
|
|
|
|
END IF
|
|
|
|
ELSEIF wasProvided(optionLvl) <> providedArgs(currentArg) THEN
|
Add support for optional function arguments
Currently functions only have very limited optional argument support,
this expands it so that we can have more complex sets of optional
arguments for functions, such as multiple arguments where not all need
to be provided. This will be used in the future for some upcoming
functionality.
Note that this does not support any generic optional argument format,
the commas always have to be provided unless an optional argument is at
the end of the parameter list. Thus, if you have a format with two
optional arguments and you want to omit the second, then you need to call
it as 'foo(2, , 3)`, rather than `foo(2, 3)`. This is important for
avoiding ambiguous situations, and is how many SUBs currently function.
The two functions that violate that requirement are INSTR() and
_INSTRREV(), which use the format `[?],?,?` and allow omitting the comma
for the first argument. This format is simply handled as a special case.
Fixes: #303
2023-02-07 05:57:10 +00:00
|
|
|
isValidArgSet = 0
|
|
|
|
EXIT FUNCTION
|
2023-02-13 03:38:29 +00:00
|
|
|
END IF
|
|
|
|
END IF
|
|
|
|
END SELECT
|
|
|
|
NEXT
|
Add support for optional function arguments
Currently functions only have very limited optional argument support,
this expands it so that we can have more complex sets of optional
arguments for functions, such as multiple arguments where not all need
to be provided. This will be used in the future for some upcoming
functionality.
Note that this does not support any generic optional argument format,
the commas always have to be provided unless an optional argument is at
the end of the parameter list. Thus, if you have a format with two
optional arguments and you want to omit the second, then you need to call
it as 'foo(2, , 3)`, rather than `foo(2, 3)`. This is important for
avoiding ambiguous situations, and is how many SUBs currently function.
The two functions that violate that requirement are INSTR() and
_INSTRREV(), which use the format `[?],?,?` and allow omitting the comma
for the first argument. This format is simply handled as a special case.
Fixes: #303
2023-02-07 05:57:10 +00:00
|
|
|
|
|
|
|
' The base level of arguments are required. They can be in the
|
|
|
|
' 'ignored' state though if all arguments are within brackets
|
2023-02-13 03:38:29 +00:00
|
|
|
IF currentArg < maxArgument OR wasProvided(0) = ArgNotProvided THEN
|
Add support for optional function arguments
Currently functions only have very limited optional argument support,
this expands it so that we can have more complex sets of optional
arguments for functions, such as multiple arguments where not all need
to be provided. This will be used in the future for some upcoming
functionality.
Note that this does not support any generic optional argument format,
the commas always have to be provided unless an optional argument is at
the end of the parameter list. Thus, if you have a format with two
optional arguments and you want to omit the second, then you need to call
it as 'foo(2, , 3)`, rather than `foo(2, 3)`. This is important for
avoiding ambiguous situations, and is how many SUBs currently function.
The two functions that violate that requirement are INSTR() and
_INSTRREV(), which use the format `[?],?,?` and allow omitting the comma
for the first argument. This format is simply handled as a special case.
Fixes: #303
2023-02-07 05:57:10 +00:00
|
|
|
isValidArgSet = 0
|
2023-02-13 03:38:29 +00:00
|
|
|
EXIT FUNCTION
|
|
|
|
END IF
|
Add support for optional function arguments
Currently functions only have very limited optional argument support,
this expands it so that we can have more complex sets of optional
arguments for functions, such as multiple arguments where not all need
to be provided. This will be used in the future for some upcoming
functionality.
Note that this does not support any generic optional argument format,
the commas always have to be provided unless an optional argument is at
the end of the parameter list. Thus, if you have a format with two
optional arguments and you want to omit the second, then you need to call
it as 'foo(2, , 3)`, rather than `foo(2, 3)`. This is important for
avoiding ambiguous situations, and is how many SUBs currently function.
The two functions that violate that requirement are INSTR() and
_INSTRREV(), which use the format `[?],?,?` and allow omitting the comma
for the first argument. This format is simply handled as a special case.
Fixes: #303
2023-02-07 05:57:10 +00:00
|
|
|
|
|
|
|
isValidArgSet = -1
|
|
|
|
END FUNCTION
|