Where Am I?

Started by George Vagenas, November 18, 2013, 01:38:00 PM

Previous topic - Next topic

George Vagenas

If you have a lot of long UDFs it can sometimes get confusing as to which function you're in or if you're in one at all.

Add this to your WSP-USER.mnu file.
Code (winbatch) Select
; This is a top level menu item, indent and change hotkey as required.
Where Am I   \ ^!i
      DefStart = 0
      DefEnd = 0
      Col = wgetcolno()
      Ln = wgetlineno()
      wend()                                                      ; May be on a #define line.
      Found = wfind('#define', 0, 0, 0, 0)                        ; Search back case insensitive.
      Chk = strtrim(clipget())
      if strsub(strtrim(clipget()), 1, 1)!='#' then Found = @false
      if Found
         f00 = clipget()
         Def = itemextract(2, strtrim(itemextract(1, f00, '(')), ' ')
         DefStart = wgetlineno()
         Found = wfind('#end', 1, 0, 0, 0)
         DefEnd = wgetlineno()
      Chk = Ln>=DefStart && Ln<=DefEnd
      if Chk then display(10, 'Inside a user defined routine', 'Line %Ln% is in user defined routine %Def%.')
      if !Chk && isdefined(Def) then  display(10, 'Current position is below a user defined routine.', 'User defined routine %Def% is at line %DefStart%.')
      if !Chk && !isdefined(Def) then display(10, 'No routine found!', 'There are no user defined routines above line %Ln%.')
      drop(Chk, Col, Def, DefEnd, DefStart, f00, Found, Ln)

Tells you if you're in a function or if there are any definitions above your current position.



Thanks for sharing.
Deana F.
Technical Support
Wilson WindowWare Inc.