Go Back   Rhinocerus > Newsgroup > Newsgroup comp.lang.* 2 > Newsgroup comp.lang.mumps

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 08-08-2012, 06:46 AM
Andy
Guest
 
Posts: n/a
Default GT.M function variable check

Is there a tool for GTM to check variables in routine? The tool should catch every local variable declared, but not used or used but not declared. Because GTM does not have a good studio to check that, it is pretty common that a variable is declared but a different variable is actually used in thecode. That causes a lot of bugs. Thanks in advance!
Reply With Quote
Alt Today
Advertising
 
and become member of Rhinocerus
Standard Sponsored Links

  #2 (permalink)  
Old 08-08-2012, 10:25 AM
Tomas Morstein
Guest
 
Posts: n/a
Default Re: GT.M function variable check

Dne středa, 8. srpna 2012 8:46:38 UTC+2 Andy napsal(a):
> Is there a tool for GTM to check variables in routine?


Have you tried ZSHOW or $ZJOBEXAM()?

It's not the only debugging tool, take a look here:
http://www.mumps.cz/gtm/books/pg/UNI...l/ch02s02.html

> The tool should catch every local variable declared, but not used or usedbut not declared.


What do you mean by "declaration?" That they're New'd?
ZSHOW "V" shows you only variables holding a value; I am not aware of any technique to discover undefined (New'd-only) variables. Would it make some sense to have such a tool?

> Because GTM does not have a good studio to check that,


What about Serenji and Gambas?
http://www.georgejames.com/serenji
http://eltranssoft.blogspot.cz/2012/...tm-gambas.html

BTW, the best IDE is a well-configured ViM :-)

> it is pretty common that a variable is declared but a different variable is actually used in the code. That causes a lot of bugs. Thanks in advance!


How often do you work with N[ew] command? If the code is well structured, this should not happen daily. Not with N[ew]!

Tom
Reply With Quote
  #3 (permalink)  
Old 08-08-2012, 08:20 PM
Andy
Guest
 
Posts: n/a
Default Re: GT.M function variable check

I am creating new code/function every day. Most of the time, I declared a variable in the "new" statement at the top of a function. In the function,when I use the variable, I may have typo in the code which causes all kinds of error. So I need a tool to check a routine to report me any variable declared but not used or variables used but not declared. This is not a run time check. So zshow or zwr does not work.

What is ViM? Is it using Vi to edit M code?

Thanks,

andy
Reply With Quote
  #4 (permalink)  
Old 08-09-2012, 08:51 PM
Tomas Morstein
Guest
 
Posts: n/a
Default Re: GT.M function variable check

Dne středa, 8. srpna 2012 22:20:04 UTC+2 Andy napsal(a):
> I am creating new code/function every day. Most of the time, I declared a variable in the "new" statement at the top of a function. In the function, when I use the variable, I may have typo in the code which causes all kinds of error. So I need a tool to check a routine to report me any variable declared but not used or variables used but not declared. This is not a run time check. So zshow or zwr does not work.


Ah, sorry, I've got it now! So you're looking for something like XINDEX routine from OpenVista then. Haven't tried it personally yet, but I guess it will be seriously tied with the rest of OpenVista..

> What is ViM? Is it using Vi to edit M code?


:-) Well, its official name is Vi IMproved, but after few years using it for M development, I can confirm it's also Vi M-proved ;-) (GT.M and Cache)
At the other hand, I know at least one person who wrote GT.M code in Cache Studio just to get features you're looking for...
Reply With Quote
  #5 (permalink)  
Old 08-10-2012, 05:12 AM
Andy
Guest
 
Posts: n/a
Default Re: GT.M function variable check

On Thursday, August 9, 2012 1:51:50 PM UTC-7, Tomas Morstein wrote:
> Dne středa, 8. srpna 2012 22:20:04 UTC+2 Andy napsal(a):
>
> > I am creating new code/function every day. Most of the time, I declared a variable in the "new" statement at the top of a function. In the function, when I use the variable, I may have typo in the code which causes all kinds of error. So I need a tool to check a routine to report me any variable declared but not used or variables used but not declared. This is not a run time check. So zshow or zwr does not work.

>
>
>
> Ah, sorry, I've got it now! So you're looking for something like XINDEX routine from OpenVista then. Haven't tried it personally yet, but I guess itwill be seriously tied with the rest of OpenVista..
>
>
>
> > What is ViM? Is it using Vi to edit M code?

>
>
>
> :-) Well, its official name is Vi IMproved, but after few years using it for M development, I can confirm it's also Vi M-proved ;-) (GT.M and Cache)
>
> At the other hand, I know at least one person who wrote GT.M code in Cache Studio just to get features you're looking for...


I used Cache studio a lot in the past when working on Cache Mumps code. Itis a very nice tool. Hope someone can develop a tool like that.

As of the variable check, since I only use GT.M, XINDEX may not work for you. I spent a couple days and wrote a small parser. It may not work for all scenario, but it is good enough for me to do variable validation.

Thanks a lot for the help.

Andy
Reply With Quote
  #6 (permalink)  
Old 08-10-2012, 06:12 PM
igotmumps
Guest
 
Posts: n/a
Default Re: GT.M function variable check

On Tuesday, August 7, 2012 11:46:38 PM UTC-7, Andy wrote:
> Is there a tool for GTM to check variables in routine? The tool should catch every local variable declared, but not used or used but not declared. Because GTM does not have a good studio to check that, it is pretty commonthat a variable is declared but a different variable is actually used in the code. That causes a lot of bugs. Thanks in advance!


A static code analysis tool like you describe is something that has been onmy mind for some time. I just haven't had the bandwidth to do anything about it. There are a lot of other useful things that a tool like this coulddo:

* determining F S var=$O(....) Q:VAR="" scenarios
* forgetting to New variables
* referencing non-existent globals
* etc

MZ
Reply With Quote
  #7 (permalink)  
Old 08-12-2012, 06:04 AM
Andy
Guest
 
Posts: n/a
Default Re: GT.M function variable check

On Friday, August 10, 2012 11:12:13 AM UTC-7, igotmumps wrote:
> On Tuesday, August 7, 2012 11:46:38 PM UTC-7, Andy wrote:
>
> > Is there a tool for GTM to check variables in routine? The tool shouldcatch every local variable declared, but not used or used but not declared.. Because GTM does not have a good studio to check that, it is pretty common that a variable is declared but a different variable is actually used inthe code. That causes a lot of bugs. Thanks in advance!

>
>
>
> A static code analysis tool like you describe is something that has been on my mind for some time. I just haven't had the bandwidth to do anything about it. There are a lot of other useful things that a tool like this could do:
>
>
>
> * determining F S var=$O(....) Q:VAR="" scenarios
>
> * forgetting to New variables
>
> * referencing non-existent globals
>
> * etc
>
>
>
> MZ


If you have more request, post here. I am thinking or make one and share it with the group later.
Reply With Quote
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT. The time now is 10:07 PM.


Copyright ©2009

LinkBacks Enabled by vBSEO 3.3.0 RC2 © 2009, Crawlability, Inc.