@sasjs/core 7.1.9 → 7.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/base/mf_abort.sas +6 -5
- package/base/mf_verifymacvars.sas +6 -13
- package/package.json +1 -1
- package/viya/mfv_existfile.sas +15 -10
- package/viya/mfv_existfolder.sas +15 -15
- package/viya/mfv_getpathuri.sas +13 -11
package/base/mf_abort.sas
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
@brief Abort, ungracefully
|
|
4
4
|
@details Will abort with a straightforward %abort if the condition is true.
|
|
5
5
|
|
|
6
|
+
Not advised in SASjs web services: %abort gives the program no opportunity to
|
|
7
|
+
capture the failure and return it to the client, so the caller sees a failed
|
|
8
|
+
request with no message. Use mp_abort.sas in that context - it writes the
|
|
9
|
+
standard SASjs abort JSON (message, calling macro, SYSCC and a log extract) to
|
|
10
|
+
_webout before ending the step.
|
|
11
|
+
|
|
6
12
|
@param [in] mac= (mf_abort.sas) Name of calling macro (is printed to the log)
|
|
7
13
|
@param [in] msg= ( ) Additional string to print to the log
|
|
8
14
|
@param [in] iftrue= (%str(1=1)) Conditional logic under which to perform the
|
|
@@ -11,11 +17,6 @@
|
|
|
11
17
|
<h4> Related Macros </h4>
|
|
12
18
|
@li mp_abort.sas
|
|
13
19
|
|
|
14
|
-
@deprecated Use mp_abort.sas. This macro is retained for backwards
|
|
15
|
-
compatibility only: the default SASjs CLI service and test templates still
|
|
16
|
-
declare it as a dependency, and mf_verifymacvars and the viya mfv_* macros
|
|
17
|
-
still call it, so it is not going away. New code should not call it.
|
|
18
|
-
|
|
19
20
|
@version 9.2
|
|
20
21
|
@author Allan Bowe
|
|
21
22
|
@cond
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
@file
|
|
3
3
|
@brief Checks if a set of macro variables exist AND contain values.
|
|
4
|
-
@details Reports a failure in the log
|
|
5
|
-
|
|
4
|
+
@details Reports a failure in the log and returns 0. It never aborts: an
|
|
5
|
+
mf_ macro returns a value, and ending the step here would leave the caller
|
|
6
|
+
unable to see that value or to report the failure itself.
|
|
6
7
|
Usage:
|
|
7
8
|
|
|
8
9
|
%let var1=x;
|
|
@@ -12,16 +13,12 @@
|
|
|
12
13
|
Returns:
|
|
13
14
|
> 1
|
|
14
15
|
|
|
15
|
-
<h4> SAS Macros </h4>
|
|
16
|
-
@li mf_abort.sas
|
|
17
|
-
|
|
18
16
|
@param [in] verifyvars Space separated list of macro variable names
|
|
19
17
|
@param [in] makeupcase= (NO) Set to YES to convert all variable VALUES to
|
|
20
18
|
uppercase.
|
|
21
|
-
@param [in] mAbort= (SOFT)
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
various fashions according to context).
|
|
19
|
+
@param [in] mAbort= (SOFT) Retained for backwards compatibility. The macro
|
|
20
|
+
no longer aborts on any value - a failure is written to the log and 0 is
|
|
21
|
+
returned, so the caller decides what to do with it.
|
|
25
22
|
|
|
26
23
|
@note will not be able to verify the following variables due to
|
|
27
24
|
naming clash!
|
|
@@ -60,10 +57,6 @@
|
|
|
60
57
|
%goto exit_success;
|
|
61
58
|
%exit_err:
|
|
62
59
|
%put &abortmsg;
|
|
63
|
-
%mf_abort(iftrue=(&mabort ne SOFT),
|
|
64
|
-
mac=mf_verifymacvars,
|
|
65
|
-
msg=%str(&abortmsg)
|
|
66
|
-
)
|
|
67
60
|
0
|
|
68
61
|
%return;
|
|
69
62
|
%exit_success:
|
package/package.json
CHANGED
package/viya/mfv_existfile.sas
CHANGED
|
@@ -2,10 +2,14 @@
|
|
|
2
2
|
@file
|
|
3
3
|
@brief Checks whether a file exists in SAS Drive
|
|
4
4
|
@details Returns 1 if the file exists, and 0 if it doesn't. Works by
|
|
5
|
-
attempting to assign a fileref with the filesrvc engine.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
attempting to assign a fileref with the filesrvc engine. When the file is
|
|
6
|
+
not found the filename function sets syscc to a non zero value, so the macro
|
|
7
|
+
resets syscc to zero and returns 0.
|
|
8
|
+
|
|
9
|
+
A non zero syscc on entry means an earlier step has already failed. The macro
|
|
10
|
+
logs a %str(ERR)OR: line and returns 0 without touching syscc, so a caller
|
|
11
|
+
comparing the result against 1 or 0 stays valid, and can tell this case from a
|
|
12
|
+
genuine miss by checking syscc, which a miss resets to zero.
|
|
9
13
|
|
|
10
14
|
Usage:
|
|
11
15
|
|
|
@@ -16,7 +20,6 @@
|
|
|
16
20
|
(eg /Public/myfile.txt)
|
|
17
21
|
|
|
18
22
|
<h4> SAS Macros </h4>
|
|
19
|
-
@li mf_abort.sas
|
|
20
23
|
@li mf_getuniquefileref.sas
|
|
21
24
|
|
|
22
25
|
<h4> Related Macros </h4>
|
|
@@ -29,12 +32,14 @@
|
|
|
29
32
|
%macro mfv_existfile(filepath
|
|
30
33
|
)/*/STORE SOURCE*/;
|
|
31
34
|
|
|
32
|
-
%mf_abort(
|
|
33
|
-
iftrue=(&syscc ne 0),
|
|
34
|
-
msg=Cannot enter mfv_existfile.sas with syscc=&syscc
|
|
35
|
-
)
|
|
36
|
-
|
|
37
35
|
%local fref rc path name;
|
|
36
|
+
|
|
37
|
+
%if &syscc ne 0 %then %do;
|
|
38
|
+
%put %str(ERR)OR: mfv_existfile.sas cannot execute with syscc=&syscc;
|
|
39
|
+
0
|
|
40
|
+
%return;
|
|
41
|
+
%end;
|
|
42
|
+
|
|
38
43
|
%let fref=%mf_getuniquefileref();
|
|
39
44
|
%let name=%scan(&filepath,-1,/);
|
|
40
45
|
%let path=%substr(&filepath,1,%length(&filepath)-%length(&name)-1);
|
package/viya/mfv_existfolder.sas
CHANGED
|
@@ -2,10 +2,14 @@
|
|
|
2
2
|
@file
|
|
3
3
|
@brief Checks whether a folder exists in SAS Drive
|
|
4
4
|
@details Returns 1 if the folder exists, and 0 if it doesn't. Works by
|
|
5
|
-
attempting to assign a fileref with the filesrvc engine.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
attempting to assign a fileref with the filesrvc engine. When the folder is
|
|
6
|
+
not found the filename function sets syscc to a non zero value, so the macro
|
|
7
|
+
resets syscc to zero and returns 0.
|
|
8
|
+
|
|
9
|
+
A non zero syscc on entry means an earlier step has already failed. The macro
|
|
10
|
+
logs a %str(ERR)OR: line and returns 0 without touching syscc, so a caller
|
|
11
|
+
comparing the result against 1 or 0 stays valid, and can tell this case from a
|
|
12
|
+
genuine miss by checking syscc, which a miss resets to zero.
|
|
9
13
|
|
|
10
14
|
Usage:
|
|
11
15
|
|
|
@@ -15,7 +19,6 @@
|
|
|
15
19
|
@param [in] path The path to the folder on SAS drive
|
|
16
20
|
|
|
17
21
|
<h4> SAS Macros </h4>
|
|
18
|
-
@li mf_abort.sas
|
|
19
22
|
@li mf_getuniquefileref.sas
|
|
20
23
|
|
|
21
24
|
<h4> Related Macros </h4>
|
|
@@ -28,12 +31,14 @@
|
|
|
28
31
|
%macro mfv_existfolder(path
|
|
29
32
|
)/*/STORE SOURCE*/;
|
|
30
33
|
|
|
31
|
-
%mf_abort(
|
|
32
|
-
iftrue=(&syscc ne 0),
|
|
33
|
-
msg=Cannot enter mfv_existfolder.sas with syscc=&syscc
|
|
34
|
-
)
|
|
35
|
-
|
|
36
34
|
%local fref rc var;
|
|
35
|
+
|
|
36
|
+
%if &syscc ne 0 %then %do;
|
|
37
|
+
%put %str(ERR)OR: mfv_existfolder.sas cannot execute with syscc=&syscc;
|
|
38
|
+
0
|
|
39
|
+
%return;
|
|
40
|
+
%end;
|
|
41
|
+
|
|
37
42
|
%let fref=%mf_getuniquefileref();
|
|
38
43
|
|
|
39
44
|
%if %sysfunc(filename(fref,,filesrvc,folderPath="&path"))=0 %then %do;
|
|
@@ -47,9 +52,4 @@
|
|
|
47
52
|
%let syscc=0;
|
|
48
53
|
%end;
|
|
49
54
|
|
|
50
|
-
%mf_abort(
|
|
51
|
-
iftrue=(&syscc ne 0),
|
|
52
|
-
msg=Cannot leave mfv_existfolder.sas with syscc=&syscc
|
|
53
|
-
)
|
|
54
|
-
|
|
55
55
|
%mend mfv_existfolder;
|
package/viya/mfv_getpathuri.sas
CHANGED
|
@@ -2,7 +2,13 @@
|
|
|
2
2
|
@file
|
|
3
3
|
@brief Returns the uri of a file or folder
|
|
4
4
|
@details The automatic variable `_FILESRVC_[fref]_URI` is used after assigning
|
|
5
|
-
a fileref using the filesrvc engine.
|
|
5
|
+
a fileref using the filesrvc engine. If the path does not exist the macro
|
|
6
|
+
prints a note, returns nothing, and resets syscc to zero.
|
|
7
|
+
|
|
8
|
+
A non zero syscc on entry means an earlier step has already failed. The macro
|
|
9
|
+
logs a %str(ERR)OR: line and returns an empty uri without touching syscc, so a
|
|
10
|
+
caller that tests the uri for blankness sees no path, and the failure stays
|
|
11
|
+
visible in syscc.
|
|
6
12
|
|
|
7
13
|
Usage:
|
|
8
14
|
|
|
@@ -13,7 +19,6 @@
|
|
|
13
19
|
(eg /Public/myfile.txt)
|
|
14
20
|
|
|
15
21
|
<h4> SAS Macros </h4>
|
|
16
|
-
@li mf_abort.sas
|
|
17
22
|
@li mf_getuniquefileref.sas
|
|
18
23
|
|
|
19
24
|
<h4> Related Macros </h4>
|
|
@@ -27,12 +32,13 @@
|
|
|
27
32
|
%macro mfv_getpathuri(filepath
|
|
28
33
|
)/*/STORE SOURCE*/;
|
|
29
34
|
|
|
30
|
-
%mf_abort(
|
|
31
|
-
iftrue=(&syscc ne 0),
|
|
32
|
-
msg=Cannot enter &sysmacroname with syscc=&syscc
|
|
33
|
-
)
|
|
34
|
-
|
|
35
35
|
%local fref rc path name var /* var is used to avoid delete timing issue */;
|
|
36
|
+
|
|
37
|
+
%if &syscc ne 0 %then %do;
|
|
38
|
+
%put %str(ERR)OR: mfv_getpathuri.sas cannot execute with syscc=&syscc;
|
|
39
|
+
%return;
|
|
40
|
+
%end;
|
|
41
|
+
|
|
36
42
|
%let fref=%mf_getuniquefileref();
|
|
37
43
|
%let name=%scan(&filepath,-1,/);
|
|
38
44
|
%let path=%substr(&filepath,1,%length(&filepath)-%length(&name)-1);
|
|
@@ -49,8 +55,4 @@
|
|
|
49
55
|
%let syscc=0;
|
|
50
56
|
%end;
|
|
51
57
|
|
|
52
|
-
%mf_abort(
|
|
53
|
-
iftrue=(&syscc ne 0),
|
|
54
|
-
msg=Cannot leave &sysmacroname with syscc=&syscc
|
|
55
|
-
)
|
|
56
58
|
%mend mfv_getpathuri;
|