I am using the following command to capture a namespace to a script
[]SE.SALT.Save #.CLAIMS '[ws]/OpenClaims'
The namespace contains some global variables that are constantly changing. How can I exclude variables to be written to the script.
Excluding variables at namespace granularity
Re: Excluding variables at namespace granularity
SALT.Save simply writes out the namespace as it is.
Is it possible to remove the variables using ⎕EX? e.g.
Is it possible to remove the variables using ⎕EX? e.g.
Code: Select all
#.Claims.⎕ex ListOfVarsToExpunge
⎕SE.SALT.Save '#.CLAIMS [ws]/OpenClaims'
Re: Excluding variables at namespace granularity
Not Really. It would significantly increase the overhead involved each time I wanted to save the namespace script.
Re: Excluding variables at namespace granularity
)clear
clear ws
⍝ dfns: notes is full of arrays
)copy dfns notes⍝ now copy the entire ws into notes
C:\Program Files\Dyalog\Dyalog APL-64 14.0 Unicode\ws\dfns saved Sat Jun 28 08:57:24 2014
notes.⎕cy'dfns'⍝ get rid of the spaces
,∘≢⌸notes.(⎕nc⎕nl-⍳10)
2.1 61
4.2 64
3.2 197
9.1 2
notes.⎕nl 9
notes
scripts
notes.(⎕ex⎕nl 9)
,∘≢⌸notes.(⎕nc⎕nl-2 3 4)
2.1 61
4.2 64
3.2 197
⍝ we have a ns with vars fns & ops
⍝ the vars happen to be those not obscured by fns or ops of the same name.
⍝ All that was just creating the test environment.
⍝ Now run this function:
∇f00←{⍺←⊢
[1] file←⍺
[2] space←⍵
[3] hidden←space.(⎕NS ⎕NL 2.1)
[4] z←space.(⎕EX ⎕NL 2)
[5] z←⎕SE.Salt.Save space file
[6] 'space'⎕NS'hidden.',⍤1⊢hidden.⎕NL 2
[7] ⍝ ⍺ file
[8] ⍝ ⍵ space
[9] }
∇
'c:\users\phil\desktop\notes' f00 notes
,∘≢⌸notes.(⎕nc⎕nl-2 3 4)
2.1 61
4.2 64
3.2 197
⍝ now in another session:
)clear⍝ look! no vars!
clear ws
⎕SE.SALT.Load'c:\users\phil\desktop\notes.dyalog'
,∘≢⌸notes.(⎕nc⎕nl-⍳10)
9.1 1
4.2 64
3.2 197
notes.⎕nl 9
SALT_Data
⍝ Works fine but if anything goes wrong on line five or six
⍝ and the stack is cleared I'm afraid you've lost the lot!
⍝ A bit like juggling I suppose.
Re: Excluding variables at namespace granularity
Phil's program would work except for line 5 which should read
z←⎕SE.SALT.Save space file
You could put f00 permanently in your ⎕SE or, better yet, write a user command to do the same.
z←⎕SE.SALT.Save space file
You could put f00 permanently in your ⎕SE or, better yet, write a user command to do the same.
Re: Excluding variables at namespace granularity
Quite right Dan. I remember now I had to fix it in mid flow after copying piecemeal to a text file (easier than composing it in the browser). Then I copied it to the browser without the change!!!
Re: Excluding variables at namespace granularity
∇f00←{⍺←⊢
[1] file←⍺
[2] space←⍵
[3] new←'#.n',⍕{⊣/(⍳1+⍴⍵)~⍵}∪⊃{⍺/⍵}/⎕VFI,' ',0 1↓'n'#.⎕NL⍳10
[4] z←new{⍎⍺,'←⍵'}hidden←space.(⎕NS ⎕NL 2.1)
[5] z←space.(⎕EX ⎕NL 2)
[6] z←⎕SE.SALT.Save space file
[7] z←'space'⎕NS'hidden.',⍤1⊢hidden.⎕NL 2
[8] ⎕EX new
[9] ⍝ ⍺ file
[10] ⍝ ⍵ space
[11] }
∇
added lines [3,8] and amended [4] ensure that there is a copy of the vars in previously non-existent root space #.nNN if an error is )RESET. The new space is expunged as a last operation if all is well.