@@ -230,27 +230,26 @@ Function isInitialized()
230
230
return getGlobalVar ( "initialized" ) == 1
231
231
End
232
232
233
- // Returns the currently selected item from the panel defined by the optional arguments.
234
- // Exactly one optional argument must be given.
235
- //
236
- // @param module: Module from ProcGlobal/Independent Module list
237
- // @param procedure: "myProcedure.ipf [moduleName]"
238
- // @param procedureWithModule: "myProcedure.ipf"
239
- // @param index: Zero-based index into main listbox
240
- //
241
- // @returns the currently selected item
242
- Function /S getCurrentItem ( [ module, procedure, procedureWithoutModule, index] )
243
- variable module, procedureWithoutModule, procedure, index
244
-
245
- string procName
246
-
247
- module = ParamIsDefault ( module) ? 0 : 1
248
- procedureWithoutModule = ParamIsDefault ( procedureWithoutModule) ? 0 : 1
249
- procedure = ParamIsDefault ( procedure) ? 0 : 1
250
- index = ParamIsDefault ( index) ? 0 : 1
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
244
+
245
+ string procName, rawList
246
+
247
+ module = ParamIsDefault ( module) ? 0 : 1
248
+ procedure = ParamIsDefault ( procedure) ? 0 : 1
249
+ index = ParamIsDefault ( index) ? 0 : 1
251
250
252
251
// only one optional argument allowed
253
- if ( module + procedure + procedureWithoutModule + index != 1 )
252
+ if ( module + procedure + index != 1 )
254
253
return "_error_"
255
254
endif
256
255
@@ -266,28 +265,51 @@ Function/S getCurrentItem([module, procedure, procedureWithoutModule, index])
266
265
if ( V_Value >= 0 )
267
266
return num2str ( V_Value)
268
267
endif
269
- elseif ( procedure || procedureWithoutModule)
270
-
268
+ elseif ( procedure)
271
269
ControlInfo / W=$ panel $ procCtrl
272
270
V_Value -= 1 // 1-based index
273
- string rawList = GetUserData ( panel, procCtrl, userDataRawList)
274
271
272
+ rawList = GetUserData ( panel, procCtrl, userDataRawList)
275
273
if ( V_Value < 0 || V_Value >= ItemsInList ( rawList))
276
274
return "_error_"
277
275
endif
278
276
279
- procName = StringFromList ( V_Value, rawList)
280
-
281
- if ( procedureWithoutModule)
282
- return RemoveEverythingAfter ( procName, " [" )
283
- endif
284
-
277
+ procName = StringFromList ( V_Value, rawList)
285
278
return procName
286
279
endif
287
280
288
281
return "_error_"
289
282
End
290
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
+
291
313
// Returns the currently selected item from the panel defined by the optional arguments.
292
314
// Argument is returned as number in current list
293
315
// Exactly one optional argument must be given.
0 commit comments