-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathNM_Configurations.ipf
More file actions
1718 lines (1132 loc) · 40.8 KB
/
NM_Configurations.ipf
File metadata and controls
1718 lines (1132 loc) · 40.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#pragma rtGlobals=3 // Use modern global access method and strict wave access.
#pragma hide = 1
//****************************************************************
//****************************************************************
//
// NeuroMatic: data aquisition, analyses and simulation software that runs with the Igor Pro environment
// Copyright (C) 2024 The Silver Lab, UCL
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//
// Contact Jason@ThinkRandom.com
// www.NeuroMatic.ThinkRandom.com
//
//****************************************************************
//****************************************************************
Constant NMConfigsAutoOpenSave = 0 // auto open/save configs to user's Package directory ( 0 ) no ( 1 ) yes // see NMConfigsHowToSaveToPackages
Static StrConstant ConfigsFileName = "NMConfigs.pxp"
//****************************************************************
//****************************************************************
Function /S ConfigDF( fname ) // return Configurations full-path folder name
String fname // config folder name ( e.g. "NeuroMatic", "Main", "Stats" )
return NMPackageDF( "Configurations:" + fname )
End // ConfigDF
//****************************************************************
//****************************************************************
Function NMConfig( fName, copyConfigs [ update ] )
String fName // package folder name
Variable copyConfigs // ( -1 ) copy configs to folder ( 0 ) no copy ( 1 ) copy folder to configs
Variable update
if ( ParamIsDefault( update ) )
update = 1
endif
CheckNMConfig( fName ) // create new config folder and variables
if ( copyConfigs != 0 )
NMConfigCopy( fname, copyConfigs, update = update )
endif
End // NMConfig
//****************************************************************
//****************************************************************
Function CheckNMConfigsAll( [ cleanUp ] )
Variable cleanUp // remove configs for deprecated variables and strings
Variable icnt
String fname, flist = NMConfigList()
for ( icnt = 0; icnt < ItemsInList( flist ); icnt += 1 )
fname = StringFromList( icnt, flist )
CheckNMConfig( fname, cleanUp = cleanUp )
endfor
End // CheckNMConfigsAll
//****************************************************************
//****************************************************************
Function CheckNMConfig( fname [ cleanUp ] )
String fname // config folder name ( "NeuroMatic", "Chan", "Stats"... )
Variable cleanUp // remove configs for deprecated variables and strings
String cdf = ConfigDF( fname )
Variable noCleanUp = NumVarOrDefault( cdf + "C_NoCleanUp", 0 ) // set this parameter to prevent cleanup action (e.g. Clamp Notes)
CheckNMConfigDF( fname )
if ( cleanUp && !noCleanUp )
// null lists, which will then be recreated by the following Execute using current version of NM
SetNMstr( cdf + "C_VarList", "" )
SetNMstr( cdf + "C_WaveList", "" )
endif
Execute /Z "NM" + fname + "Configs()" // run particular configs function if it exists
if ( V_Flag == 2003 )
Execute /Z fname + "Configs()" // try another name
endif
if ( cleanUp && !noCleanUp )
// compare new C_VarList to variables that exist in config folder
// remove variables that are no longer used by NM
NMConfigCleanUp( fname )
endif
//UpdateNMConfigMenu()
End // CheckNMConfig
//****************************************************************
//****************************************************************
Static Function NMConfigCleanUp( fname ) // remove configs for deprecated variables and strings
String fname // config folder name
Variable icnt, changeDF
String vList, vName
String cdf = ConfigDF( fname )
String pdf = NMPackageDF( fname )
String saveDF = GetDataFolder( 1 )
if ( DataFolderExists( cdf ) == 0 )
return -1
endif
String varList = StrVarOrDefault( cdf + "C_VarList", "" )
String wList = StrVarOrDefault( cdf + "C_WaveList", "" )
SetDataFolder $cdf
vList = VariableList( "*", ";", 4 )
vList = RemoveFromList( varList, vList )
for ( icnt = 0 ; icnt < ItemsInList( vList ) ; icnt += 1 )
vName = StringFromList( icnt, vList )
if ( StringMatch( vName[ 0, 1 ], "C_" ) == 1 )
continue
endif
KillVariables /Z $cdf + vName
KillStrings /Z $cdf + "D_" + vName
KillStrings /Z $cdf + "T_" + vName
if ( DataFolderExists( pdf ) == 1 )
KillVariables /Z $pdf + vName
KillStrings /Z $pdf + "D_" + vName
KillStrings /Z $pdf + "T_" + vName
//Print "NMConfigCleanUp: killed variable " + pdf + vName
endif
endfor
vList = StringList( "*", ";" )
vList = RemoveFromList( varList, vList )
vList = RemoveFromList( "FileType", vList )
for ( icnt = 0 ; icnt < ItemsInList( vList ) ; icnt += 1 )
vName = StringFromList( icnt, vList )
if ( StringMatch( vName[ 0, 1 ], "C_" ) == 1 )
continue
endif
if ( StringMatch( vName[ 0, 1 ], "D_" ) == 1 )
continue
endif
if ( StringMatch( vName[ 0, 1 ], "T_" ) == 1 )
continue
endif
KillStrings /Z $cdf + vName
KillStrings /Z $cdf + "D_" + vName
KillStrings /Z $cdf + "T_" + vName
if ( DataFolderExists( pdf ) == 1 )
KillStrings /Z $pdf + vName
KillStrings /Z $pdf + "D_" + vName
KillStrings /Z $pdf + "T_" + vName
//Print "NMConfigCleanUp: killed variable " + pdf + vName
endif
endfor
vList = WaveList( "*", ";", "" )
vList = RemoveFromList( wList, vList )
for ( icnt = 0 ; icnt < ItemsInList( vList ) ; icnt += 1 )
vName = StringFromList( icnt, vList )
if ( StringMatch( vName[ 0, 1 ], "C_" ) == 1 )
continue
endif
KillWaves /Z $cdf + vName
if ( DataFolderExists( pdf ) == 1 )
KillWaves /Z $pdf + vName
endif
//Print "Killed wave " + cdf + vName
endfor
SetDataFolder $saveDf
return 0
End // NMConfigCleanUp
//****************************************************************
//****************************************************************
Function CheckNMConfigDF( fname )
String fname // config folder name
String df = ConfigDF( "" ) // main config folder
String sub = df + fname + ":" // subfolder to check
Variable makeDF
CheckNMPackageDF( "Configurations" )
makeDF = CheckNMPackageDF( "Configurations:"+fname )
SetNMstr( df+"FileType", "NMConfig" )
SetNMstr( sub+"FileType", "NMConfig" )
return makeDF // ( 0 ) already made ( 1 ) yes, made
End // CheckNMConfigDF
//****************************************************************
//****************************************************************
Function /S NMConfigList()
String flist = FolderObjectList( ConfigDF( "" ), 4 )
if ( FindListItem( "NeuroMatic", flist ) >= 0 )
flist = RemoveFromList( "NeuroMatic", flist )
flist = "NeuroMatic;" + flist
endif
return flist
End // NMConfigList
//****************************************************************
//****************************************************************
Function NMConfigCopy( flist, direction [ update ] ) // set configurations
String flist // config folder name list or "All"
Variable direction // ( -1 ) config to package folder ( 1 ) package folder to config
Variable update
Variable icnt, fcnt
String fname, objName, cdf, df, objList
if ( StringMatch( flist, "All" ) == 1 )
flist = NMConfigList()
endif
if ( ParamIsDefault( update ) )
update = 1
endif
for ( fcnt = 0; fcnt < ItemsInList( flist ); fcnt += 1 )
fname = StringFromList( fcnt, flist )
cdf = ConfigDF( fname ) // config data folder
df = NMPackageDF( fname ) // package data folder
if ( DataFolderExists( cdf ) == 0 )
continue
endif
if ( direction == -1 )
CheckNMPackageDF( fname )
endif
objList = NMConfigVarList( fname, 2 ) // numbers
for ( icnt = 0; icnt < ItemsInList( objList ); icnt += 1 )
objName = StringFromList( icnt, objList )
if ( ( direction == 1 ) && ( exists( df+objName ) == 2 ) )
SetNMvar( cdf+objName, NumVarOrDefault( df+objName, Nan ) )
elseif ( direction == -1 )
SetNMvar( df+objName, NumVarOrDefault( cdf+objName, Nan ) )
endif
endfor
objList = NMConfigVarList( fname, 3 ) // strings
for ( icnt = 0; icnt < ItemsInList( objList ); icnt += 1 )
objName = StringFromList( icnt, objList )
if ( ( direction == 1 ) && ( exists( df+objName ) == 2 ) )
SetNMstr( cdf+objName, StrVarOrDefault( df+objName, "" ) )
elseif ( direction == -1 )
SetNMstr( df+objName, StrVarOrDefault( cdf+objName, "" ) )
endif
endfor
objList = NMConfigVarList( fname, 5 ) // numeric waves
for ( icnt = 0; icnt < ItemsInList( objList ); icnt += 1 )
objName = StringFromList( icnt, objList )
if ( ( direction == 1 ) && ( WaveExists( $( df+objName ) ) == 1 ) )
Duplicate /O $( df+objName ), $( cdf+objName )
elseif ( direction == -1 )
Duplicate /O $( cdf+objName ), $( df+objName )
endif
endfor
objList = NMConfigVarList( fname, 6 ) // text waves
for ( icnt = 0; icnt < ItemsInList( objList ); icnt += 1 )
objName = StringFromList( icnt, objList )
if ( ( direction == 1 ) && ( WaveExists( $( df+objName ) ) == 1 ) )
Duplicate /O $( df+objName ), $( cdf+objName )
elseif ( direction == -1 )
Duplicate /O $( cdf+objName ), $( df+objName )
endif
endfor
endfor
if ( update && ( direction == -1 ) )
UpdateNM( 0 )
endif
return 0
End // NMConfigCopy
//****************************************************************
//****************************************************************
Function /S NMConfigSaveCall( fname )
String fname // config folder name
String flist = NMConfigList()
if ( ( strlen( fname ) == 0 ) || ( FindListItem( fname, flist ) < 0 ) )
fname = "All"
if ( ItemsInList( flist ) == 0 )
NMDoAlert( "No Configurations to save." )
return ""
endif
if ( ItemsInList( flist ) > 1 )
flist += "All;"
endif
Prompt fname, "select configuration to save:", popup flist
DoPrompt "Save Configuration", fname
if ( V_flag == 1 )
return "" // cancel
endif
endif
return NMConfigSave( fname, history = 1 )
End // NMConfigSaveCall
//****************************************************************
//****************************************************************
Function /S NMConfigSave( fname [ history ] ) // save config folder
String fname // config folder fname, or "All"
Variable history
String folder, tdf, df, file = "NMConfig" + fname
String vlist = ""
if ( history )
vlist = NMCmdStr( fname, vlist )
NMCommandHistory( vlist )
endif
if ( StringMatch( fname, "All" ) == 1 )
return NMConfigSaveAll()
endif
df = ConfigDF( "" )
if ( StringMatch( StrVarOrDefault( df+"FileType", "" ), "NMConfig" ) == 0 )
NMDoAlert( "NMConfigSave Error: folder is not a NM configuration file." )
return ""
endif
NMConfigCopy( fname, 1 ) // get current configuration values
tdf = "root:" + file + ":" // temp folder
if ( DataFolderExists( tdf ) == 1 )
KillDataFolder $tdf // kill temp folder if already exists
endif
NewDataFolder $RemoveEnding( tdf, ":" )
SetNMstr( tdf+"FileType", "NMConfig" )
DuplicateDataFolder $( df+fname ), $( tdf+fname )
CheckNMPath()
folder = NMFolderSaveToDisk( folder = tdf, extFile = file, path = "NMPath" )
KillNMPath()
if ( DataFolderExists( tdf ) == 1 )
KillDataFolder $tdf // kill temp folder
endif
return folder
End // NMConfigSave
//****************************************************************
//****************************************************************
Function /S NMConfigSaveAll()
String df = ConfigDF( "" )
String file = StrVarOrDefault( df+"CurrentFile", "" )
if ( strlen( file ) == 0 )
file = "NMConfigs"
endif
if ( StringMatch( StrVarOrDefault( df+"FileType", "" ), "NMConfig" ) == 0 )
NMDoAlert( "NMConfigSave Error: folder is not a NM configuration file." )
return ""
endif
NMConfigCopy( "All", 1 ) // get current configuration values
CheckNMPath()
file = NMFolderSaveToDisk( folder = df, extFile = file, path = "NMPath" )
KillNMPath()
return file
End // NMConfigSaveAll
//****************************************************************
//****************************************************************
Function NMConfigsHowToSaveToPackages()
Variable configLine = 23
String txt = "NM configs can be automatically saved within each user's Package folder. "
txt += "To use, set NMConfigsAutoOpenSave = 1 in the procedure NM_Configurations.ipf "
txt += "and save the procedure ( Igor Menu/File/Save Procedure ). "
txt += "To edit, click the pencil icon."
Execute /Z "SetIgorOption IndependentModuleDev = 1"
DisplayProcedure /L=( configLine )/W=$"NM_Configurations.ipf"
NMDoAlert( txt, title="NM Configs Auto Save/Open" )
End // NMConfigsHowToSaveToPackages
//****************************************************************
//****************************************************************
Function /S NMConfigsSaveToPackages()
String df = ConfigDF( "" )
String file = ConfigsFileName
String thisfxn = GetRTStackInfo( 1 )
if ( !DataFolderExists( df ) )
return ""
endif
String fullPath = SpecialDirPath("Packages", 0, 0, 0)
fullPath += NMPackage
if ( StringMatch( StrVarOrDefault( df+"FileType", "" ), "NMConfig" ) == 0 )
NMDoAlert( thisfxn + " Error: folder is not a NM configuration file." )
return ""
endif
NMConfigCopy( "All", 1 ) // get current configuration values
NewPath /O/C/Q NMPath, fullPath
if (V_Flag != 0 )
NMDoAlert( thisfxn + " Error: failed to created folder: " + fullPath )
endif
fullPath += ":" + ConfigsFileName
DFREF saveDF = GetDataFolderDFR()
SetDataFolder $df
SaveData /O/Q/R fullPath
if (V_Flag != 0 )
NMDoAlert( thisfxn + " Error: failed to save " + ConfigsFileName )
fullPath = ""
else
NMHistory( "Saved NM configs to User Packages directory " + fullPath )
endif
SetDataFolder saveDF
KillPath /Z NMPath
return fullPath
End // NMConfigsSaveToPackages
//****************************************************************
//****************************************************************
Function NMConfigsOpenFromPackages()
String fullPath = SpecialDirPath("Packages", 0, 0, 0) + NMPackage + ":" + ConfigsFileName
Variable error = NMConfigOpen( fullPath, history = 0, quiet = 1 )
if ( error == 0 )
NMHistory( "Opened NM configs from User Packages directory " + fullPath )
endif
End // NMConfigsOpenFromPackages
//****************************************************************
//****************************************************************
Function NMConfigOpen( file [ history, quiet ] )
String file
Variable history
Variable quiet
Variable icnt, dialogue = 0, error = -1
String flist, fname, folder, odf, ndf, cdf, vlist = "", df = ConfigDF( "" )
Variable nmPrefix = 0 // leave folder name as is
if ( history )
vlist = NMCmdStr( file, vlist )
NMCommandHistory( vlist )
endif
CheckNMPath()
if ( strlen( file ) == 0 )
dialogue = 1
endif
folder = NMFileBinOpen( dialogue, ".pxp", "root:", "NMPath", file, 0, nmPrefix = nmPrefix, history = history, quiet = quiet ) // NM_FileManager.ipf
KillNMPath()
if ( strlen( folder ) == 0 )
return error // cancel
endif
if ( IsNMFolder( folder, "NMConfig" ) == 1 )
flist = FolderObjectList( folder, 4 ) // subfolder list
for ( icnt = 0; icnt < ItemsInList( flist ); icnt += 1 )
fname = StringFromList( icnt, flist )
if ( StringMatch( fname, "Notes" ) )
odf = folder + ":Notes"
ndf = folder + ":ClampNotes"
if ( !DataFolderExists( folder + ":ClampNotes" ) )
fname = "ClampNotes"
RenameDataFolder $odf, $fname
endif
endif
odf = folder + ":" + fname
cdf = df + fname
if ( DataFolderExists( cdf ) == 1 )
KillDataFolder $cdf // kill config folder
endif
DuplicateDataFolder $odf, $cdf
NMConfigCopy( fname, -1 ) // set config values
endfor
error = 0
CheckNMConfigsAll( cleanUp = 1 )
CheckNMPaths()
else
NMDoAlert( "Open File Error: file is not a NeuroMatic configuration file: " + file )
endif
if ( DataFolderExists( folder ) == 1 )
KillDataFolder $folder
endif
//UpdateNMConfigMenu()
return error
End // NMConfigOpen
//****************************************************************
//****************************************************************
Function NMConfigOpenAuto()
Variable icnt, error = -1
String path, flist, fileName, ext = ".pxp"
CheckNMPath()
PathInfo NMPath
if ( V_flag == 0 )
return 0
endif
path = S_path
flist = IndexedFile( NMPath, -1, "????" )
flist = RemoveFromList( "NMConfigs.pxp", flist )
flist = "NMConfigs.pxp;" + flist // open NMConfigs first
for ( icnt = 0; icnt < ItemsInList( flist ); icnt += 1 )
fileName = StringFromList( icnt, flist )
if ( StrSearch( fileName, ".ipf", 0, 2 ) >= 0 )
continue // skip procedure files
endif
if ( StrSearch( fileName, ext, 0, 2 ) >= 0 )
error = NMConfigOpen( path + fileName )
endif
endfor
//UpdateNMConfigMenu()
CheckNMConfigsAll( cleanUp = 1 )
KillNMPath()
PathInfo /S Igor // reset path to Igor
End // NMConfigOpenAuto
//****************************************************************
//****************************************************************
Function NMConfigKillCall( fname )
String fname // config folder name
String flist = NMConfigList()
if ( ( strlen( fname ) == 0 ) || ( FindListItem( fname, flist ) < 0 ) )
if ( ItemsInList( flist ) == 0 )
NMDoAlert( "No configuration to kill." )
return 0
endif
if ( ItemsInList( flist ) > 1 )
flist += "All;"
endif
Prompt fname, "select configuration to kill:", popup flist
DoPrompt "Kill Configuration", fname
if ( V_flag == 1 )
return 0 // cancel
endif
endif
return NMConfigKill( fname, history = 1 )
End // NMConfigKillCall
//****************************************************************
//****************************************************************
Function NMConfigKill( flist [ history ] ) // kill config folder
String flist // config folder list, or "All"
Variable history
String vlist = ""
if ( history )
vlist = NMCmdStr( flist, "" )
NMCommandHistory( vlist )
endif
if ( StringMatch( flist, "All" ) == 1 )
flist = NMConfigList()
endif
Variable icnt
String fname, cdf, df = ConfigDF( "" )
for ( icnt = 0; icnt < ItemsInList( flist ); icnt += 1 )
fname = StringFromList( icnt, flist )
cdf = df + fname
if ( DataFolderExists( cdf ) == 1 )
KillDataFolder $cdf // kill config folder
endif
endfor
UpdateNM( 1 )
End // NMConfigKill
//****************************************************************
//****************************************************************
Function NMConfigKill2( fname )
String fname // config folder name
Variable icnt
String iName, iList
String cdf = ConfigDF( fname )
String pdf = NMPackageDF( fname ) // package data folder
iList = NMConfigVarList( fname, 1 ) // waves
for ( icnt = 0 ; icnt < ItemsInList( iList ) ; icnt += 1 )
iName = StringFromList( icnt, iList )
if ( WaveExists( $cdf + iName ) == 1 )
KillWaves /Z $cdf + iName
endif
if ( WaveExists( $pdf + iName ) == 1 )
KillWaves /Z $pdf + iName
endif
endfor
iList = NMConfigVarList( fname, 2 ) // variables
for ( icnt = 0 ; icnt < ItemsInList( iList ) ; icnt += 1 )
iName = StringFromList( icnt, iList )
if ( exists( cdf + iName ) == 2 )
KillVariables /Z $cdf + iName
endif
if ( exists( pdf + iName ) == 2 )
KillVariables /Z $pdf + iName
endif
endfor
iList = NMConfigVarList( fname, 3 ) // strings
for ( icnt = 0 ; icnt < ItemsInList( iList ) ; icnt += 1 )
iName = StringFromList( icnt, iList )
if (exists( cdf + iName ) == 2 )
KillStrings /Z $cdf + iName
endif
if ( exists( pdf + iName ) == 2 )
KillStrings /Z $pdf + iName
endif
endfor
End // NMConfigKill2
//****************************************************************
//****************************************************************
Function NMConfigResetCall( fname )
String fname // config folder name
String flist = NMConfigList()
if ( ItemsInList( flist ) == 0 )
NMDoAlert( "No configuration to reset." )
return 0
endif
if ( ItemsInList( flist ) > 1 )
flist += "All;"
endif
Prompt fname, "select configuration:", popup flist
DoPrompt "Reset Configs to Default Values", fname
if ( V_flag == 1 )
return 0 // cancel
endif
return NMConfigReset( fname, history = 1 )
End // NMConfigResetCall
//****************************************************************
//****************************************************************
Function NMConfigReset( flist [ history ] ) // reset config folder
String flist // config folder list, or "All"
Variable history
Variable icnt
String fname
String vlist = ""
if ( history )
vlist = NMCmdStr( flist, vlist )
NMCommandHistory( vlist )
endif
if ( StringMatch( flist, "All" ) == 1 )
flist = NMConfigList()
endif
for ( icnt = 0; icnt < ItemsInList( flist ); icnt += 1 )
fname = StringFromList( icnt, flist )
if ( StringMatch( fname, "NeuroMatic" ) )
KillStrings $( NMDF + "TabControlList" )
endif
NMConfigKill2( fname )
CheckNMConfig( fname, cleanUp = 1 )
endfor
UpdateNM( 1 )
End // NMConfigReset
//****************************************************************
//****************************************************************
Function NMConfigVarListAdd( fname, varName )
String fname // config folder name
String varName
String df = ConfigDF( fname )
String vList = StrVarOrDefault( df + "C_VarList", "" )
vList = AddListItem( varName, vList, ";", inf )
SetNMstr( df + "C_VarList", vList )
End // NMConfigVarListAdd
//****************************************************************
//****************************************************************
Function NMConfigWaveListAdd( fname, wName )
String fname // config folder name
String wName // wave name
String df = ConfigDF( fname )
String vList = StrVarOrDefault( df + "C_WaveList", "" )
vList = AddListItem( wName, vList, ";", inf )
SetNMstr( df + "C_WaveList", vList )
End // NMConfigWaveListAdd
//****************************************************************
//****************************************************************
Function NMConfigVar( fname, vName, value, infoStr, type )
String fname, vName
Variable value
String infoStr
String type
String df = ConfigDF( fname )
String pf = NMPackageDF( fname )
NMConfigVarListAdd( fname, vName )
CheckNMConfigDF( fname ) // check config folder exists
CheckNMvar( df+vname, NumVarOrDefault( pf+vName, value ) )
CheckNMstr( df+"D_"+vName, infoStr )
CheckNMstr( df+"T_"+vName, type )
End // NMConfigVar
//****************************************************************
//****************************************************************
Function NMConfigVarRename( fname, oldName, newName )
String fname
String oldName, newName
Variable value
String cdf = ConfigDF( fname )
String pdf = NMPackageDF( fname )
if ( exists( cdf + oldName ) == 2 )
value = NumVarOrDefault( cdf + oldName, NaN )
SetNMvar( cdf + newName, value )
KillVariables /Z $cdf + oldName
endif
if ( exists( pdf + oldName ) == 2 )
value = NumVarOrDefault( pdf + oldName, NaN )
SetNMvar( pdf + newName, value )
KillVariables /Z $pdf + oldName
endif
End // NMConfigVarRename
//****************************************************************
//****************************************************************
Function NMConfigStr( fname, vName, strValue, infoStr, type )
String fname, vName, strValue, infoStr, type
String df = ConfigDF( fname )
String pf = NMPackageDF( fname )
NMConfigVarListAdd( fname, vName )
CheckNMConfigDF( fname ) // check config folder exists
CheckNMstr( df+vName, StrVarOrDefault( pf+vName, strValue ) )
CheckNMstr( df+"D_"+vName, infoStr )
CheckNMstr( df+"T_"+vName, type )
End // NMConfigStr
//****************************************************************
//****************************************************************