@@ -28,6 +28,8 @@ static StrConstant userDataNiceList = "niceList"
28
28
29
29
static StrConstant oneTimeInitUserData = "oneTimeInit"
30
30
31
+ static StrConstant selectAll = "<ALL>"
32
+
31
33
Function /S GetPanel ()
32
34
return panel
33
35
End
@@ -135,6 +137,7 @@ Function/S generateModuleList()
135
137
debugPrint ( "called" )
136
138
137
139
string niceList = getModuleList ()
140
+ niceList = AddListItem ( selectAll, niceList)
138
141
139
142
PopupMenu $ moduleCtrl, win=$ panel, userData ( $ userDataNiceList) = niceList
140
143
@@ -144,11 +147,30 @@ End
144
147
// Callback for the procedure popup, returns a nicified list
145
148
// Stores both the nicified list and the raw list as user data
146
149
Function /S generateProcedureList ()
147
- debugPrint ( "called" )
148
-
149
- string module = getCurrentItem ( module=1 )
150
- string procList = getProcList ( module)
151
- string niceList = nicifyProcedureList ( procList)
150
+ string module, modules, procList, niceList
151
+ variable numModules, i
152
+
153
+ module = getCurrentItem ( module = 1 )
154
+ if ( ! cmpstr ( module, selectAll))
155
+ procList = ""
156
+ niceList = ""
157
+ modules = getModuleList ()
158
+ numModules = ItemsInList ( modules)
159
+ for ( i = 0; i < numModules; i += 1 )
160
+ module = StringFromList ( i , modules)
161
+ procList += getProcList ( module)
162
+ if ( isProcGlobal ( module))
163
+ niceList += getProcList ( module)
164
+ else
165
+ niceList += getProcList ( module, addModule = 1 )
166
+ endif
167
+ endfor
168
+ else
169
+ procList = getProcList ( module)
170
+ niceList = procList
171
+ endif
172
+ niceList = ProcedureListRemoveModule ( niceList)
173
+ niceList = ProcedureListRemoveEnding ( niceList)
152
174
153
175
PopupMenu $ procCtrl, win=$ panel, userData ( $ userDataRawList) = procList, userData ( $ userDataNiceList) = niceList
154
176
@@ -208,25 +230,26 @@ Function isInitialized()
208
230
return getGlobalVar ( "initialized" ) == 1
209
231
End
210
232
211
- // Returns the currently selected item from the panel defined by the optional arguments.
212
- // Exactly one optional argument must be given.
213
- //
214
- // module: Module from ProcGlobal/Independent Module list
215
- // procedure: "myProcedure.ipf [moduleName]"
216
- // procedureWithModule: "myProcedure.ipf"
217
- // index: Zero-based index into main listbox
218
- Function /S getCurrentItem ( [ module, procedure,procedureWithoutModule, index] )
219
- variable module, procedureWithoutModule, procedure, index
233
+ /// Returns the currently selected item from the panel defined by the optional arguments.
234
+ ///
235
+ /// Exactly one optional argument must be given.
236
+ ///
237
+ /// @param module [optional] Module from ProcGlobal/Independent Module list
238
+ /// @param procedure [optional] "myProcedure.ipf [moduleName]"
239
+ /// @param index [optional] Zero-based index into main listbox
240
+ ///
241
+ /// @returns the currently selected item
242
+ Function /S getCurrentItem ( [ module, procedure, index] )
243
+ variable module, procedure, index
220
244
221
- string procName
245
+ string procName, rawList
222
246
223
- module = ParamIsDefault ( module) ? 0 : 1
224
- procedureWithoutModule = ParamIsDefault ( procedureWithoutModule) ? 0 : 1
225
- procedure = ParamIsDefault ( procedure) ? 0 : 1
226
- index = ParamIsDefault ( index) ? 0 : 1
247
+ module = ParamIsDefault ( module) ? 0 : 1
248
+ procedure = ParamIsDefault ( procedure) ? 0 : 1
249
+ index = ParamIsDefault ( index) ? 0 : 1
227
250
228
251
// only one optional argument allowed
229
- if ( module + procedure + procedureWithoutModule + index != 1 )
252
+ if ( module + procedure + index != 1 )
230
253
return "_error_"
231
254
endif
232
255
@@ -242,28 +265,51 @@ Function/S getCurrentItem([module, procedure,procedureWithoutModule, index])
242
265
if ( V_Value >= 0 )
243
266
return num2str ( V_Value)
244
267
endif
245
- elseif ( procedure || procedureWithoutModule)
246
-
268
+ elseif ( procedure)
247
269
ControlInfo / W=$ panel $ procCtrl
248
270
V_Value -= 1 // 1-based index
249
- string rawList = GetUserData ( panel, procCtrl, userDataRawList)
250
271
272
+ rawList = GetUserData ( panel, procCtrl, userDataRawList)
251
273
if ( V_Value < 0 || V_Value >= ItemsInList ( rawList))
252
274
return "_error_"
253
275
endif
254
276
255
- procName = StringFromList ( V_Value, rawList)
256
-
257
- if ( procedureWithoutModule)
258
- return RemoveEverythingAfter ( procName, " [" )
259
- endif
260
-
277
+ procName = StringFromList ( V_Value, rawList)
261
278
return procName
262
279
endif
263
280
264
281
return "_error_"
265
282
End
266
283
284
+ /// Get the basic procedure name from a full procedure name
285
+ ///
286
+ /// @param fullName "myProcedure.ipf [moduleName]"
287
+ ///
288
+ /// @returns myProcedure.ipf without module definition
289
+ Function /S ProcedureWithoutModule ( fullName)
290
+ string fullName
291
+
292
+ return RemoveEverythingAfter ( fullName, " [" )
293
+ End
294
+
295
+ /// Get the module name from a full procedure name
296
+ ///
297
+ /// @param fullName "myProcedure.ipf [moduleName]"
298
+ ///
299
+ /// @returns moduleName without procedure specification
300
+ Function /S ModuleWithoutProcedure ( fullName)
301
+ string fullName
302
+
303
+ string module, procedure
304
+
305
+ SplitString / E= "(.*)\ \[ (\w +)\] " fullName, procedure, module
306
+ if ( V_flag != 2 )
307
+ return ""
308
+ endif
309
+
310
+ return module
311
+ End
312
+
267
313
// Returns the currently selected item from the panel defined by the optional arguments.
268
314
// Argument is returned as number in current list
269
315
// Exactly one optional argument must be given.
@@ -304,7 +350,7 @@ Function getCurrentItemAsNumeric([module, procedure, index, indexTop])
304
350
return -1 // error
305
351
End
306
352
307
- // Updates the the given popup menu
353
+ // Updates the given popup menu
308
354
// Tries to preserve the currently selected item
309
355
Function updatePopup ( ctrlName)
310
356
string ctrlName
@@ -320,7 +366,7 @@ Function updatePopup(ctrlName)
320
366
321
367
ControlUpdate / W=$ panel $ ctrlName
322
368
323
- list = GetUserData ( panel, procCtrl, userDataNiceList)
369
+ list = GetUserData ( panel, procCtrl, userDataNiceList)
324
370
325
371
if ( ItemsInList ( list) == 1 )
326
372
PopupMenu $ ctrlName win=$ panel, disable=2
@@ -329,10 +375,10 @@ Function updatePopup(ctrlName)
329
375
endif
330
376
331
377
// try to restore the previously selected item if it differs from the current one
332
- variable newIndex = WhichListItem ( itemText, list) + 1
378
+ variable newIndex = WhichListItem ( itemText, list) + 1
333
379
334
380
if ( newIndex != index) // only update if required, as the update triggers the list generating function
335
- if ( newIndex > 0 )
381
+ if ( newIndex > 0 )
336
382
PopupMenu $ ctrlName win=$ panel, mode= newIndex
337
383
else
338
384
PopupMenu $ ctrlName win=$ panel, mode=1
0 commit comments