cancel
Showing results for 
Search instead for 
Did you mean: 

Need to check in a file if dim is displaying in the routine or not

SOLVED
New Contributor

Need to check in a file if dim is displaying in the routine or not

Hi All, 

 

I need help in writing a code for below scenario:

I have a txt file where there is around 2000+ line of code and I need to check multiple routines that if the DIM is displaying under the routine then its fine. DIM should not display out of the routine.

I know that this could be the DO While loop in vbscript or how we can tackle? 

 

Thanks,

1 ACCEPTED SOLUTION

Accepted Solutions
Community Leader

Re: Need to check in a file if dim is displaying in the routine or not

Hi. Not 100% sure what you're trying to achieve here. Are you trying to parse Visual Basic code to determine if there are variables defined outside functions defined in the code?

 

Parsing code is quite an advanced task, especially if you have to factor in all the edge cases. At a basic level you need to read in the code using one of these approaches (probably easiest to read the file line-by-line into an array), find all your "Dim" statements and check that they occur inside a "Sub...End Sub" block (by reading backwards and forwards).

 

This is where it gets a little tricky. When you find a "Dim" statement, you need to go backwards to find a "Sub" statement without encountering any "End Sub" statements. Likewise, you will need to read forwards to find an "End Sub" statement without encountering any "Sub" statements.


--------------------
QA Systems Architect
Integrated Control Technology
https://www.ict.co/

View solution in original post

2 REPLIES 2
Community Leader

Re: Need to check in a file if dim is displaying in the routine or not

Hi. Not 100% sure what you're trying to achieve here. Are you trying to parse Visual Basic code to determine if there are variables defined outside functions defined in the code?

 

Parsing code is quite an advanced task, especially if you have to factor in all the edge cases. At a basic level you need to read in the code using one of these approaches (probably easiest to read the file line-by-line into an array), find all your "Dim" statements and check that they occur inside a "Sub...End Sub" block (by reading backwards and forwards).

 

This is where it gets a little tricky. When you find a "Dim" statement, you need to go backwards to find a "Sub" statement without encountering any "End Sub" statements. Likewise, you will need to read forwards to find an "End Sub" statement without encountering any "Sub" statements.


--------------------
QA Systems Architect
Integrated Control Technology
https://www.ict.co/

View solution in original post

New Contributor

Re: Need to check in a file if dim is displaying in the routine or not

Thanks a lot

New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors