<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Macro/vbscript breaking down? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-vbscript-breaking-down/m-p/12616#M1389</link>
    <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
I am using the EG 4.3 ,where I have a certain project set up. Inside the project there are 3 simple macros (for interchanging some filters based on a name from a list) as well as approx 200 other query buiders, simple run and extraction programs etc. Now, I need to run this project 70 times based on those different names from the list, therefore I have found the following program in VBS that I have been using. It is as follows:&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
Option Explicit&lt;BR /&gt;
Dim app&lt;BR /&gt;
Call dowork&lt;BR /&gt;
&lt;BR /&gt;
If not (app Is Nothing) Then&lt;BR /&gt;
    app.Quit&lt;BR /&gt;
    Set app = Nothing&lt;BR /&gt;
End If&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Sub dowork()&lt;BR /&gt;
    On Error Resume Next&lt;BR /&gt;
    Dim prjName&lt;BR /&gt;
    Dim prjObject&lt;BR /&gt;
    Dim dc		&lt;BR /&gt;
    Dim d				&lt;BR /&gt;
    Dim tc				 &lt;BR /&gt;
    Dim t				 &lt;BR /&gt;
    Dim rc				&lt;BR /&gt;
    Dim r                      &lt;BR /&gt;
    Dim outfile			&lt;BR /&gt;
    Dim fileSys               &lt;BR /&gt;
    Dim Contents               &lt;BR /&gt;
    Dim ext                    &lt;BR /&gt;
    &lt;BR /&gt;
    outfile = ""  'Output file name&lt;BR /&gt;
&lt;BR /&gt;
    Set fileSys = CreateObject("Scripting.FileSystemObject")&lt;BR /&gt;
    Set Contents = fileSys.OpenTextFile(outfile, 2, True)&lt;BR /&gt;
&lt;BR /&gt;
    'Name the project to run&lt;BR /&gt;
    prjName = ""    'Project Name&lt;BR /&gt;
      &lt;BR /&gt;
    Set app = CreateObject("SASEGObjectModel.Application.4.3")&lt;BR /&gt;
    If Checkerror("CreateObject") = True Then&lt;BR /&gt;
        Exit Sub&lt;BR /&gt;
    End If&lt;BR /&gt;
    &lt;BR /&gt;
    Set prjObject = app.Open(prjName,"")&lt;BR /&gt;
    If Checkerror("app.Open") = True Then&lt;BR /&gt;
        Exit Sub&lt;BR /&gt;
    End If&lt;BR /&gt;
    &lt;BR /&gt;
  	d = 0&lt;BR /&gt;
	do while d &amp;lt; 75&lt;BR /&gt;
	&lt;BR /&gt;
    prjObject.run&lt;BR /&gt;
    If Checkerror("Project.run") = True Then&lt;BR /&gt;
        Exit Sub&lt;BR /&gt;
    End If&lt;BR /&gt;
	&lt;BR /&gt;
	d = d + 1&lt;BR /&gt;
	Loop&lt;BR /&gt;
           &lt;BR /&gt;
       prjObject.Close&lt;BR /&gt;
    If Checkerror("Project.Close") = True Then&lt;BR /&gt;
        Exit Sub&lt;BR /&gt;
    End If&lt;BR /&gt;
       &lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
Function Checkerror(fnName)&lt;BR /&gt;
    Checkerror = False&lt;BR /&gt;
    &lt;BR /&gt;
    Dim strmsg&lt;BR /&gt;
    Dim errNum&lt;BR /&gt;
    &lt;BR /&gt;
    If Err.Number &amp;lt;&amp;gt; 0 Then&lt;BR /&gt;
        strmsg = "Error #" &amp;amp; Hex(Err.Number) &amp;amp; vbCrLf &amp;amp; "In Function " &amp;amp; fnName &amp;amp; vbCrLf &amp;amp; Err.Description&lt;BR /&gt;
        'MsgBox strmsg  &lt;BR /&gt;
        Checkerror = True&lt;BR /&gt;
    End If&lt;BR /&gt;
         &lt;BR /&gt;
End Function&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
Now this all runs smoothly, however the problem I have is that it keeps on 'crashing' (i.e. stops processing) in random places at random times. Sometimes it does 20 items from the list and then stops, other times it just runs 2 times and stops. I have tried to split the project into 2 smaller ones (thinking that this could be due the the amount of queries), but the problem still prevails.&lt;BR /&gt;
&lt;BR /&gt;
On the other hand I have identical VBS attached to different project (it's kind of a prestage to this one above), which has identical macros, but has only about 10 queries and this one runs smoothly (i.e. does it 70 times without interuption).&lt;BR /&gt;
&lt;BR /&gt;
Does anyone know what could cause these interuptions and how to rectify this?&lt;BR /&gt;
&lt;BR /&gt;
Many thanks in advance,&lt;BR /&gt;
&lt;BR /&gt;
Simi</description>
    <pubDate>Tue, 14 Jun 2011 10:44:10 GMT</pubDate>
    <dc:creator>Simi</dc:creator>
    <dc:date>2011-06-14T10:44:10Z</dc:date>
    <item>
      <title>Macro/vbscript breaking down?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-vbscript-breaking-down/m-p/12616#M1389</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
I am using the EG 4.3 ,where I have a certain project set up. Inside the project there are 3 simple macros (for interchanging some filters based on a name from a list) as well as approx 200 other query buiders, simple run and extraction programs etc. Now, I need to run this project 70 times based on those different names from the list, therefore I have found the following program in VBS that I have been using. It is as follows:&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
Option Explicit&lt;BR /&gt;
Dim app&lt;BR /&gt;
Call dowork&lt;BR /&gt;
&lt;BR /&gt;
If not (app Is Nothing) Then&lt;BR /&gt;
    app.Quit&lt;BR /&gt;
    Set app = Nothing&lt;BR /&gt;
End If&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Sub dowork()&lt;BR /&gt;
    On Error Resume Next&lt;BR /&gt;
    Dim prjName&lt;BR /&gt;
    Dim prjObject&lt;BR /&gt;
    Dim dc		&lt;BR /&gt;
    Dim d				&lt;BR /&gt;
    Dim tc				 &lt;BR /&gt;
    Dim t				 &lt;BR /&gt;
    Dim rc				&lt;BR /&gt;
    Dim r                      &lt;BR /&gt;
    Dim outfile			&lt;BR /&gt;
    Dim fileSys               &lt;BR /&gt;
    Dim Contents               &lt;BR /&gt;
    Dim ext                    &lt;BR /&gt;
    &lt;BR /&gt;
    outfile = ""  'Output file name&lt;BR /&gt;
&lt;BR /&gt;
    Set fileSys = CreateObject("Scripting.FileSystemObject")&lt;BR /&gt;
    Set Contents = fileSys.OpenTextFile(outfile, 2, True)&lt;BR /&gt;
&lt;BR /&gt;
    'Name the project to run&lt;BR /&gt;
    prjName = ""    'Project Name&lt;BR /&gt;
      &lt;BR /&gt;
    Set app = CreateObject("SASEGObjectModel.Application.4.3")&lt;BR /&gt;
    If Checkerror("CreateObject") = True Then&lt;BR /&gt;
        Exit Sub&lt;BR /&gt;
    End If&lt;BR /&gt;
    &lt;BR /&gt;
    Set prjObject = app.Open(prjName,"")&lt;BR /&gt;
    If Checkerror("app.Open") = True Then&lt;BR /&gt;
        Exit Sub&lt;BR /&gt;
    End If&lt;BR /&gt;
    &lt;BR /&gt;
  	d = 0&lt;BR /&gt;
	do while d &amp;lt; 75&lt;BR /&gt;
	&lt;BR /&gt;
    prjObject.run&lt;BR /&gt;
    If Checkerror("Project.run") = True Then&lt;BR /&gt;
        Exit Sub&lt;BR /&gt;
    End If&lt;BR /&gt;
	&lt;BR /&gt;
	d = d + 1&lt;BR /&gt;
	Loop&lt;BR /&gt;
           &lt;BR /&gt;
       prjObject.Close&lt;BR /&gt;
    If Checkerror("Project.Close") = True Then&lt;BR /&gt;
        Exit Sub&lt;BR /&gt;
    End If&lt;BR /&gt;
       &lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
Function Checkerror(fnName)&lt;BR /&gt;
    Checkerror = False&lt;BR /&gt;
    &lt;BR /&gt;
    Dim strmsg&lt;BR /&gt;
    Dim errNum&lt;BR /&gt;
    &lt;BR /&gt;
    If Err.Number &amp;lt;&amp;gt; 0 Then&lt;BR /&gt;
        strmsg = "Error #" &amp;amp; Hex(Err.Number) &amp;amp; vbCrLf &amp;amp; "In Function " &amp;amp; fnName &amp;amp; vbCrLf &amp;amp; Err.Description&lt;BR /&gt;
        'MsgBox strmsg  &lt;BR /&gt;
        Checkerror = True&lt;BR /&gt;
    End If&lt;BR /&gt;
         &lt;BR /&gt;
End Function&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
Now this all runs smoothly, however the problem I have is that it keeps on 'crashing' (i.e. stops processing) in random places at random times. Sometimes it does 20 items from the list and then stops, other times it just runs 2 times and stops. I have tried to split the project into 2 smaller ones (thinking that this could be due the the amount of queries), but the problem still prevails.&lt;BR /&gt;
&lt;BR /&gt;
On the other hand I have identical VBS attached to different project (it's kind of a prestage to this one above), which has identical macros, but has only about 10 queries and this one runs smoothly (i.e. does it 70 times without interuption).&lt;BR /&gt;
&lt;BR /&gt;
Does anyone know what could cause these interuptions and how to rectify this?&lt;BR /&gt;
&lt;BR /&gt;
Many thanks in advance,&lt;BR /&gt;
&lt;BR /&gt;
Simi</description>
      <pubDate>Tue, 14 Jun 2011 10:44:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-vbscript-breaking-down/m-p/12616#M1389</guid>
      <dc:creator>Simi</dc:creator>
      <dc:date>2011-06-14T10:44:10Z</dc:date>
    </item>
    <item>
      <title>Re: Macro/vbscript breaking down?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-vbscript-breaking-down/m-p/12617#M1390</link>
      <description>Does the last part of the loop that attempts to run produce any errors in the code?&lt;BR /&gt;
&lt;BR /&gt;
    prjObject.run&lt;BR /&gt;
    If Checkerror("Project.run") = True Then&lt;BR /&gt;
        Exit Sub&lt;BR /&gt;
    End If&lt;BR /&gt;
&lt;BR /&gt;
If any errors crop up, then VBScript will terminate at that point, and won't run any further.&lt;BR /&gt;
&lt;BR /&gt;
The CheckError function has a popup that's commented out - you could try removing that, and then you should get a popup at that point in the code which might help direct you to the error.&lt;BR /&gt;
&lt;BR /&gt;
The difficulty you'll have in checking the EG logs is that the script will terminate before saving after it finds any error, so your project (and hence log files) will not be saved.&lt;BR /&gt;
&lt;BR /&gt;
That said, if it's always at a particular point in the loop (i.e. for a certain value of "d") then you might be able to try running that part manually and see if you get the same issue.</description>
      <pubDate>Tue, 14 Jun 2011 17:01:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-vbscript-breaking-down/m-p/12617#M1390</guid>
      <dc:creator>DF</dc:creator>
      <dc:date>2011-06-14T17:01:12Z</dc:date>
    </item>
  </channel>
</rss>

