?
Solved

AS400 VBScript / memory question

Posted on 2005-03-07
21
Medium Priority
?
2,677 Views
Last Modified: 2007-12-19
Hi Everyone,

I have a question about the vbscripts for AS400, specifically the memory they use.

I have a script that requests some files from the Real Vision Report Manager, sends them to an outq, copies them to PCDownload, then deletes them from the outq.  It does this for 9 different RVI reports.

This is KILLING my memory.  The swap file keeps getting increased, and I have to close all other applications.  I watch the memory usage in the task manager just increase quickly while using it (when loading as400 it says the mem usage is 147000K / 631484K, within about 30 seconds its at 500000K.

I put in a few msgbox's into my code to see where the main memory killer is, and it seems to be in 2 portions of code that kill it the most, waitforinputready and searchtext.

The first is " auteclsession.autecloia.WaitForInputReady".  I use this a lot, as I have to wait until the system can accept input before I move on to the next.  Each time this is run, it looks like its using about 2mb of memory, and its not clearing out until the script is done running.  Is there a better alternative for this?

The second is SearchText, which I use while the system is pulling the reports from RVI.  This is the main memory hog, as each iteration through the following loop adds about 2mb of memory to the mem usage:

 do until auteclsession.auteclps.searchtext("Image Inquiry Selection Screen")
REM  auteclsession.autecloia.waitforinputready(1)
 loop

I first had the waitforforintputready(1) line in there, but after I realized that it just increased the mem usage that much more, I REM'ed it out. Still uses the memory.

Is there a better alternative for this as well? I tried using waitforappavailable and just waitforinputready, but the loading screen for these reports doesnt make the application busy, so waitforappavailable and waitforinputready won't work.  

As this loop can often take 1-2 minutes to load all the related reports, my virtual memory is just destroyed at the end, until I close out of the emulator.  Then it resets the mem used back to normal.

Any ideas?
Thanks
Matt
0
Comment
Question by:mvidas
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 10
  • 9
  • 2
21 Comments
 
LVL 4

Expert Comment

by:reginab
ID: 13477994
hmmm, I think will dave will have more to say on this than I will, but be sure you are closing any connection and freeing its memory after use for better efficiency. you know as early as you can in your script.  also search text is always going to be exhaustive, is there something more efficient you can search on, something akin to an index value for the record.

0
 
LVL 14

Accepted Solution

by:
daveslater earned 1000 total points
ID: 13478219
Hi
try to put the memory hogging code in to a sub

ie

Sub xxWait

auteclsession.autecloia.WaitForInputReady

End Sub


call xxWait()

It is a bit of a guess till I have a bit of time to have a ply.

Dave

0
 
LVL 35

Author Comment

by:mvidas
ID: 13478465
That was a good idea, Dave, but unfortunately no change.  The Mem Usage on the pcsws.exe individual line did go down, but the total Mem Usage at the bottom right of the task manager (win2000) stays up at the rediculous level until the emulator is closed.  Even when I stop the macro, the total mem usage in the bottom right stays up (even though the individual pcsws.exe goes back to normal).

I don't actually have any variables opening any connection, as it is used internally in the emulator, but I did set a variable I use for a count to nothing after it is used, still no change.  I'm using the searchtext method as I have to wait until the screen says it is ready for the next step. I'm not manually getting the data from a database, there is an option for our Real Vision Report Manager that loads the report itself, it just says "Please wait while the report is generated", then tells me it is ready so I can send it to the outq.  

It is beginning to sound like an issue with the emulator, that it won't release the virtual memory until the app closes.  If that is the case, I may have to try creating the connection in a .vbs script or in vb code, and just open/close the connection within each iteration through the subs.

This will probably take me a day or two, as I can't dedicate too much time at once to this.  If either of you (or anyone else, for that matter) come up with any other ideas, I'd love to hear them, otherwise I'll get back to you after I complete this.

Thanks again
Matt
0
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

 
LVL 4

Assisted Solution

by:reginab
reginab earned 1000 total points
ID: 13478757
I think you are right thinking it is the emulator, and I was not sure if the report would have any kind of line indicator other than the read text. Oh well good luck.
0
 
LVL 14

Expert Comment

by:daveslater
ID: 13485071
Hi
I tend to agrree that is is somthing in VB script. Can we look at other options:

1) does this need to be done in VB or can we try natiev macros?

2) What is the desired end-result? Can it be achieved another way?

Dave
0
 
LVL 35

Author Comment

by:mvidas
ID: 13486266
I hate using EE in IE sometimes. I had typed a rather lengthy response, and accidentally went back one page, losing everything.  With my thoughts collected more now, I can probably condense what I was saying anyways.

I do have a native macro language equivalent of this macro (about 2300 lines) which I used for over a year.  This is only about 200 lines in vbscript, and is much easier to maintain (as I have 3 main subroutines for the different sections of the macro I need to call for each of the 9 reports I'm copying from RVI).
I do truly feel that this is an emulator issue, as the amount of virtual memory it is using at the time is not unrealistic.  It just doesn't re-use the same memory, and doesn't clear out what it has used until the emulator is closed.

I think I am going to close out this question, as there is no point to keeping it open anymore.  Your thoughts and suggestions, and just discussing the question, got me to understand what the issue is.  I will just have to modify the script to be standalone so it logs in to the server without the emulator.  I may have some problems with it, but the website I posted to the other question has some help with that, and I know I can always open another question here as well.

I know it doesnt necessarily seem as though my initial problem for this question was solved, but understanding the issue is usually the hardest part, and I have this question to thank for me to get there.
I am going to split these points evenly between the two of you; should I ask another question about this I'll gladly let you know!
Thanks
Matt
0
 
LVL 14

Expert Comment

by:daveslater
ID: 13487027
Hi
Do you have time to try this.

Sub zzwait()

Dim objWait

objWait.SetConnectionByName("A")
Set objWait = CreateObject("PCOMM.autECLOIA")

objWait.WaitForInputRead

Set objWait = Nothing

end sub
0
 
LVL 14

Expert Comment

by:daveslater
ID: 13488041
Hi try this for the strting wait

sub srText

Dim zzText
dim bln
Set zztext = CreateObject("PCOMM.autECLPS")
zztext.SetConnectionByName("A")
bln = zztext.WaitForString(("Image Inquiry Selection Screen",,,500)
Set zztext = Nothing

end sub
0
 
LVL 35

Author Comment

by:mvidas
ID: 13488070
I tried that, and added other subs for zzwaitapp, etc. While it did keep the individal process Mem Usage down, the overall still added up as usual :(
I also tried to create a .vbs file to create a connection, but I can't seem to get it working.  Do you happen to have an example of the code to create a connection to the server, or start an emulator instance?
0
 
LVL 35

Author Comment

by:mvidas
ID: 13488113
Hi, didn't refresh before posting that. I don't really want a timeout on the waitfor string, as sometimes it will wait 2-3 minutes before seeing that.   What I had made instead was

Sub looktext(inptText)
 Dim objLook
 Set objLook = CreateObject("PCOMM.autECLPS")
 objLook.SetConnectionByName("A")
 do until objLook.searchtext(inptText)
  zzwaitinput5000
 loop
 set objLook = nothing
 set inptText = nothing
end sub

I just noticed you used waitforstring, and I have searchtext.  I dont think I realized that waitforstring existed, I wouldn't have to use the do loop like I have, so I'll change that portion as well. Sorry about that, got the two confused
0
 
LVL 35

Author Comment

by:mvidas
ID: 13488366
Hi Dave,
Now that I have a couple minutes I am making my rounds on the site here, and noticed your question in vb.  Want me to post my code in your other question, post it here?
0
 
LVL 14

Expert Comment

by:daveslater
ID: 13488741
Hi
I have posted some code in the new thread.
Post it here & I will forward it (one thing I have is free unlimited points).

I have been doing a bit more reading - It may just be the way we are coding it!

Dave
0
 
LVL 14

Expert Comment

by:daveslater
ID: 13488771
ps  the
bln = zztext.WaitForString(("Image Inquiry Selection Screen",,,500)
waut 500 mili-seconds

bln = zztext.WaitForString(("Image Inquiry Selection Screen",row,col,500)
is more efficient and will look for a spacific screen location - this may save memory

I am nore sure what you have and have not tried now.

Have you used both the new subs?

Dave
0
 
LVL 14

Expert Comment

by:daveslater
ID: 13488782
pps
the
zztext.SetConnectionByName("A")
uses the first session that was opend to look for the stuf on the screen etc....


Dave
0
 
LVL 35

Author Comment

by:mvidas
ID: 13488916
I used both "A" and ThisConnectionName, both did the same thing luckily.  I also have unlimited question points (I've been slacking this month so far!), so it really wouldnt matter if that Q came from you or I.

Here is the code from my .mac file


[PCOMM SCRIPT HEADER]
LANGUAGE=VBSCRIPT
DESCRIPTION=Sample file
[PCOMM SCRIPT SOURCE]
OPTION EXPLICIT
autECLSession.SetConnectionByName(ThisSessionName)

REM This line calls the macro subroutine
 dim vcount, i, aa, bb, outq, date1, date2, date3
 outq = "nyrofcp203"
 date1="2005/02/*"
 date2="2005/02/02"
 date3="2005/03/02"
 reqrvi date1,"","qsysprt","bl4028","","","az",""
 zzwaitapp
 zzwaitinput1000
 reqrvi date1,"","qsysprt","bl4028","","","ca",""
 zzwaitapp
 zzwaitinput1000
 reqrvi date1,"","qsysprt","bl4028","","","us",""
 zzwaitapp
 zzwaitinput1000
 reqrvi date1,"","qsysprt","bl4028","","","ea",""
 zzwaitapp
 zzwaitinput1000
 copytopcd "v4028"
 zzwaitapp
 zzwaitinput1000
 delfromoutq
 vcount=0
 zzwaitapp
 zzwaitinput1000
 reqrvi date1,"","qsysprt1","bl4031","","azblbeg140","az",""
 zzwaitapp
 zzwaitinput1000
 reqrvi date1,"","qsysprt1","bl4031","","cablbeg140","ca",""
 zzwaitapp
 zzwaitinput1000
 reqrvi date1,"","qsysprt1","bl4031","","usblbeg140","us",""
 zzwaitapp
 zzwaitinput1000
 reqrvi date1,"","qsysprt1","bl4031","","eablbeg140","ea",""
 zzwaitapp
 zzwaitinput1000
 copytopcd "v4031"
 zzwaitapp
 zzwaitinput1000
 delfromoutq
 vcount=0
 zzwaitapp
 zzwaitinput1000
 reqrvi date2,date3,"","bl2670","","","ca",""
 zzwaitapp
 zzwaitinput1000
 copytopcd "v2670ca"
 zzwaitapp
 zzwaitinput1000
 delfromoutq
 set outq=nothing
 set date1=nothing
 set date2=nothing
 set date3=nothing
 set vcount=nothing
 set i=nothing
 set aa=nothing
 set bb=nothing

Sub DelFromOutQ()
 if not auteclsession.auteclps.searchtext("95] Master Printing") then msgbox "95 not found": exit sub
 zzwaitapp
 zzwaitinput1000
 auteclsession.auteclps.sendkeys "95[enter]"
 puttext 24,58,"1[enter]"
 puttext 5,37,outq&"[enter]"
 zzwaitapp
 zzwaitinput1000
 for i = 1 to int(vcount/9)
  puttext 10,3,"444444444"
  if not i = int(vcount/9) or not vcount mod 9 = 0 then auteclsession.auteclps.sendkeys "[pagedn]"
  zzwaitapp
  zzwaitinput1000
 next
 auteclsession.auteclps.sendkeys string(vcount mod 9,"4")
 zzwaitapp
 zzwaitinput1000
 auteclsession.auteclps.sendkeys "[enter]"
 zzwaitapp
 zzwaitinput1000
 auteclsession.auteclps.sendkeys "[enter]"
 zzwaitapp
 zzwaitinput1000
 auteclsession.auteclps.sendkeys "[pf3]"
 zzwaitapp
 zzwaitinput1000
 auteclsession.auteclps.sendkeys "98[enter]"
End Sub

sub CopyToPCD(pcdname)
 if not auteclsession.auteclps.searchtext("95] Master Printing") then msgbox "95 not found": exit sub
 zzwaitapp
 zzwaitinput1000
 auteclsession.auteclps.sendkeys "95[enter]"
 puttext 24,58,"8[enter]"
 puttext 5,37,outq&"[enter]"
 zzwaitapp
 zzwaitinput1000
 for i = 1 to int(vcount/13)
  puttext 8,2,"1111111111111"
  if not i = int(vcount/9) or not vcount mod 13 = 0 then auteclsession.auteclps.sendkeys "[pagedn]"
  zzwaitapp
  zzwaitinput1000
 next
 auteclsession.auteclps.sendkeys string(vcount mod 13,"1")
 auteclsession.auteclps.sendkeys "[enter]"
 zzwaitapp
 zzwaitinput1000
 aa=1
 if len(pcdname)>7 then pcdname=left(pcdname,7)
 do until gety(3,2,13)="Output queue:"
  zzwaitinput1000
  zzwaitapp
  if auteclsession.auteclps.searchtext ("Name of PCPRINT file on host") then
   auteclsession.auteclps.setcursorpos 5,37
   auteclsession.auteclps.sendkeys pcdname&string(3-len(aa),"0")&aa&string(7-len(pcdname)," ")&"pcdownload"
   auteclsession.auteclps.sendkeys "[enter]"
   aa=aa+1
  end if
 loop
 zzwaitapp
 zzwaitinput1000
 auteclsession.auteclps.sendkeys "[PF3]"
 zzwaitapp
 zzwaitinput1000
 auteclsession.auteclps.sendkeys "98[enter]"
end sub

sub reqrvi(fdate,tdate,fname,udata,uname,job,env,fprofile)
 if not auteclsession.auteclps.searchtext("95] Master Printing") then msgbox "95 not found": exit sub
 zzwaitapp
REM zzwaitinput1000
 auteclsession.auteclps.sendkeys "95[enter]"
 zzwaitapp
REM zzwaitinput(2000)
 auteclsession.auteclps.sendkeys "10[enter]"
 puttext 6,27,fdate
 puttext 6,51,tdate
 puttext 7,27,fname
 puttext 8,27,udata
 puttext 9,27,uname
 puttext 10,27,job
 puttext 11,27,env
 puttext 12,27,fprofile
REM zzwaitinput1000
 auteclsession.auteclps.sendkeys "[enter]"
 zzwaitapp
 zzwaitinput
 bb=cint(gety(7,3,5))
 vcount=vcount+bb
 for i = 1 to int(bb/12)
  puttext 9,2,"pppppppppppp"
  if not i = int(bb/9) or not bb mod 12 = 0 then auteclsession.auteclps.sendkeys "[pagedn]"
  zzwaitapp
REM  zzwaitinput1000
 next
 auteclsession.auteclps.sendkeys string(bb mod 12,"p")
 auteclsession.auteclps.sendkeys "[enter]"
 looktext("Printer Or Out Queue")
 set bb=nothing
 puttext 10,25,outq
 auteclsession.auteclps.sendkeys "[enter]"
 zzwaitapp
 zzwaitinput1000
 looktext("Image Inquiry Selection Screen")
 auteclsession.auteclps.sendkeys "[PF3]"
 zzwaitapp
 zzwaitinput1000
 auteclsession.auteclps.sendkeys "[PF3]"
 zzwaitapp
 zzwaitinput1000
 auteclsession.auteclps.sendkeys "98[enter]"
end sub

sub puttext(rw,cl,txt)
 zzwaitapp
 zzwaitinput1000
 auteclsession.auteclps.setcursorpos rw,cl
 auteclsession.auteclps.sendkeys "[eraseeof]"
 auteclsession.auteclps.sendkeys txt
end sub
Sub zzwaitinput()
 Dim objWait
 Set objWait = CreateObject("PCOMM.autECLOIA")
 objWait.SetConnectionByName("A")
 objWait.WaitForInputReady
 Set objWait = Nothing
end sub
Sub zzwaitinput1000()
 Dim objWait
 Set objWait = CreateObject("PCOMM.autECLOIA")
 objWait.SetConnectionByName("A")
 objWait.WaitForInputReady(1000)
 Set objWait = Nothing
end sub
Sub zzwaitinput5000()
 Dim objWait
 Set objWait = CreateObject("PCOMM.autECLOIA")
 objWait.SetConnectionByName("A")
 objWait.WaitForInputReady(5000)
 Set objWait = Nothing
end sub
Sub zzwaitApp()
 Dim objWait
 Set objWait = CreateObject("PCOMM.autECLOIA")
 objWait.SetConnectionByName("A")
 objWait.WaitForAppAvailable
 Set objWait = Nothing
end sub
sub lookText(inptText)
 Dim zzText
 dim bln
 Set zztext = CreateObject("PCOMM.autECLPS")
 zztext.SetConnectionByName("A")
 bln = zztext.WaitForString((inptText)
 Set zztext = Nothing
end sub
function gety(x,y,z)
 Dim objWait
 Set objWait = CreateObject("PCOMM.autECLPS")
 objWait.SetConnectionByName("A")
 gety=objwait.GetText(x,y,z)
 set objwait = nothing
 set x = nothing
 set y = nothing
 set z = nothing
end function
0
 
LVL 14

Expert Comment

by:daveslater
ID: 13489891
Hi

using the same logic as in Gety create a function to process the
 .searchtext

looking at the question this is adding 2mb per itteration, putting in the function should stop this.

Dave

0
 
LVL 14

Expert Comment

by:daveslater
ID: 13491553
Hi
I am now on holiday till the 18th
let me know if you still want to bounce ideas - even though it is closed it is intresting.

Dave
0
 
LVL 35

Author Comment

by:mvidas
ID: 13491600
I can wait until the 18th (or after, I'm sure you'll need a bit of catch up time), and I'm always up for discussion.  Discussion = more knowledge, always something I want.  :)
I didn't get to create a search function, too busy this afternoon.  I had added a searchy function this morning, I'm not sure why it isn't in the above code.  I can just add it tomorrow anyways.
I got the data I needed for this month, so there is no hurry on this.  I'm just testing it in some extra time I have, so it'll be better for next month (the macro is only run monthly, as may have been able to tell from the variables at the top).  I dont have access to emails while at work, I just check the recent commented/answered questions regularly, so when you are ready I may not get back to you right away.  At that point I'll check this Q again though.

Sounds like a nice long vacation, going anywhere?
0
 
LVL 14

Expert Comment

by:daveslater
ID: 13494020
Hi
it is a warm weather traing in Portugual - London Marathon and Nice Ironman coming up :-)

Dave
0
 
LVL 35

Author Comment

by:mvidas
ID: 13706995
Hi Dave,

I hope you had a fun vacation! Not necessarily my idea of fun to run while on vacation, but I haven't ran a race in a long time and never anything close to a marathon or ironman, actually never more than 5k!  Just wanted to give you a little closure on this, I decided that waiting to load the files in real vision / RVI is what truly killed the memory issue, so I decided to just use a native macro to loop through and load all the reports I need and then run the vbscript one for the work that needs variables.  Not my first choice to use 2 macros but after a lot of playing around a while, that really was the best way to go about it.  I really do appreciate the thought and work you put into this!

Thanks again
Matt
0
 
LVL 35

Author Comment

by:mvidas
ID: 13735818
I'm sure you two will see it anyways, but I've posted a new (somewhat related) question at http:Q_21381526.html
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article lists the top 5 free OST to PST Converter Tools. These tools save a lot of time for users when they want to convert OST to PST after their exchange server is no longer available or some other critical issue with exchange server or impor…
If you're a modern-day technology professional, you may be wondering if certifications are really necessary. They are. Here's why.
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question