I am having an issue with a sub routine not returning to where it should. The script works fine until I send it to the last sub routine and when it finishes the subroutine it contines to the next line. I checked on the site and someone else had this issue and was told to send the script to support.
I don't know if they did or not but I could not find a solution. I have moved the subroutine labels numerous times making them inside one another etc. with no sucess. If someone has some ideas it would be great.
Below is the script it is the sub compile that does not return
Let>APP_TITLE=Archive to PDF
Iffileexists>C:\ScrapeLOS\pdfarchive.ini,readini,skipreadini
Label>readini
ReadIniFile>C:\ScrapeLOS\pdfarchive.ini,Path,BRWPath,BRW
ReadIniFile>C:\ScrapeLOS\pdfarchive.ini,Path,BRWDate,ReportDate
ReadIniFile>C:\ScrapeLOS\pdfarchive.ini,Path,BRWENDDate,ENDreportdate
ReadIniFile>C:\ScrapeLOS\pdfarchive.ini,Path,pdfpath,pdfarchivepath
ReadIniFile>C:\ScrapeLOS\pdfarchive.ini,Path,tifpath,tiffstoragepath
ReadIniFile>C:\ScrapeLOS\pdfarchive.ini,Path,movetiff,mtiff
ReadIniFile>C:\ScrapeLOS\ScrapeLOS.ini,Path,ArchiveFolder,AF
Goto>Begin
Label>skipreadini
Let>BRW=
Let>BRWDate=
Label>Begin
Dialog>One
Caption=Archive to PDF Files
Width=427
Height=352
Top=CENTER
Left=CENTER
Max=1
Min=1
Close=1
Resize=1
Label=Enter Path of Point file Folder or ,46,62,true
Label=Enter Beginning Date as xx/xx/xx,40,102,true
Image=C:\ScrapeLOS\eDocFileBAckground2.bmp,0,0,417,49
Label=Browse to a Borrower or Prospect file,24,74,true
Label=Copyright© eDocFile Inc. 2005,132,298,true
Label=Enter ENDing Date as xx/xx/xx,54,136,true
Label=Storage Path of Archived PDF's,48,169,true
Label=Tiff Storage Path,112,204,true
Edit=msEditBRW,208,64,145,%BRW%
Edit=msEditDate,208,98,145,%ReportDate%
Button=Continue,128,266,75,25,1
Button=Exit,208,266,75,25,2
Button=...,360,64,25,25,0
Edit=msEdit1,208,132,145,%ENDreportdate%
Edit=mpdfarchivepath,208,165,145,%pdfarchivepath%
Edit=tiffstorage,208,200,145,%tiffstoragepath%
CheckBox=msCheckBox1,Check to Leave Tiff files in Place,112,232,193,%mtiff%
FileBrowse=...,msEditBRW,Borrower Files|*.BRW|Prospect Files|*.PRS|,open
ENDDialog>One
Label>LoopOne
Show>One,Result
IF>Result=1,createnewini
If>Result=2,EOF
GetDialogAction>One,r
Goto>LoopOne
Label>createnewini
Let>IsItafile={if(pos(".",%one.msEditBRW%)>0,"yes","no")}
If>IsItafile=yes,processfile,readytowrite
SRT>processfile
Len>%one.msEditBRW%,ENDofline
Sub>ENDofline,4
Label>repeat
MidStr>%one.msEditBRW%,%ENDofline%,1,backslash
If>%backslash%=\,gotit,again
Label>again
Sub>ENDofline,1
If>%ENDofline%=0
MDL>Error
ENDif
Goto>repeat
Label>gotit
MidStr>%one.msEditBRW%,1,%ENDofline%,basepath
END>processfile
SRT>readytowrite
Let>basepath=%one.msEditBRW%
END>readytowrite
DeleteFile>C:\ScrapeLOS\pdfarchive.ini
WriteLn>C:\ScrapeLOS\pdfarchive.ini,result,[Path]
WriteLn>C:\ScrapeLOS\pdfarchive.ini,result,BRWPath=%basepath%
WriteLn>C:\ScrapeLOS\pdfarchive.ini,result,BRWDate=%one.msEditDate%
WriteLn>C:\ScrapeLOS\pdfarchive.ini,result,BRWENDDate=%one.msEdit1%
WriteLn>C:\ScrapeLOS\pdfarchive.ini,result,pdfpath=%one.mpdfarchivepath%
WriteLn>C:\ScrapeLOS\pdfarchive.ini,result,tifpath=%one.tiffstorage%
WriteLn>C:\ScrapeLOS\pdfarchive.ini,result,movetiff=%one.msCheckBox1%
IfDirExists>%one.mpdfarchivepath%,pdfdirexists
MDL>The path for the Archived PDF's does not exist the program will now exit
Goto>EOF
Label>pdfdirexists
If>%one.msCheckBox1%=False,tifdirexists
IfDirExists>%one.tiffstorage%,tifdirexists
MDL>The path to move the Archived Tiff Images to does not exist the program will now exit
Goto>EOF
Label>tifdirexists
Let>comma=,
Let>BRW=%basepath%
Let>ReportDate=%one.msEditDate%
Let>ReportENDDate=%one.msEdit1%
VBSTART
Function filetime (filespec)
Dim fso, f, s
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFile(filespec)
s = f.DateLastModified
s = FormatDateTime(s,vbGeneralTime)
filetime = s
END Function
VBEND
GetFileList>%BRW%*.*,files
Separate>files,;,file_names
If>file_name_count=0,EOF
Let>k=0
Repeat>k
Let>k=k+1
/////////////////////////////
Let>checktime=file_names_%k%
VBEval>filetime("%checktime%"),brwtime
VbEval>(DateDiff("n","%ReportDate%","%brwtime%")),TimeSpan
VbEval>(DateDiff("n","%ReportENDDate%","%brwtime%")),TimeSpan2
Sub>TimeSpan2,TimeSpan
If>TimeSpan>0
StringReplace>%checktime%,%BRW%,,pointfile
Len>%pointfile%,plen
Sub>plen,4
Mid>%pointfile%,1,%plen%,BaseFileName
VBEval>Replace("%BaseFileName%"," ",""),LoanNumber
///////////////////////////////////////////////////////////Move Tiff Images
If>%one.msCheckBox1%=False
CopyFile>%AF%\%LoanNumber%*.*,%one.tiffstorage%\
GoSub>MakethePDF
ENDif
ENDif
Until>k,file_names_count
SRT>MakethePDF
IfFileExists>%AF%\%LoanNumber%-APPRAISAL.PDF,colorsub,pdfsub
END>MakethePDF
SRT>colorsub
Ask>A PDF File of the Appraisal Exists - would you like to use it,cpdf
If>cpdf=YES
CopyFile>%AF%%createpdf%,c:\ScrapeLOS\temp\%createpdf%
Else
IfFileExists>%AF%\%LoanNumber%-APPRAISAL.tif,blackandwhitesub
ENDif
END>colorsub
SRT>pdfsub
///////////////////////
GetFileList>%AF%\%LoanNumber%*.tif,pfiles
Separate>pfiles,;,pfile_names
IF>%pfile_names_count%=0,notiffs
Let>p=0
Repeat>p
Let>p=p+1
Let>sectiontomake=pfile_names_%p%
Len>%sectiontomake%,elen
Sub>elen,3
Len>%AF%\%LoanNumber%,rsection
Add>rsection,2
Sub>elen,rsection
Mid>%sectiontomake%,%rsection%,%elen%,sectif
GoSub>blackandwhitesub
Until>p,%pfile_names_count%
GoSub>compile
Label>notiffs
END>pdfsub
SRT>blackandwhitesub
Let>newpdf=c:\ScrapeLOS\temp\%LoanNumber%-%sectif%.pdf
Let>Author=%License%
Let>lib=c:\ScrapeLOS\Image2PDF StdCall.dll
LibLoad>lib,crepdf
LibFunc>crepdf,I2PDF_License,result,IPD-BB3Z-SF6BZ-MB0T8K-00V66XC
LibFunc>crepdf,I2PDF_AddImage,result,%sectiontomake%
LibFunc>crepdf,I2PDF_SetPermissions,result,15
LibFunc>crepdf,I2PDF_SetDPI,result,72
Let>errbuf=
Let>errbuf_SIZE=255
LibFunc>crepdf,I2PDF_MakePDF,result2,%newpdf%,0,errbuf,255
Label>ColorAppraisal
LibFree>crepdf
END>blackandwhitesub
SRT>compile
Label>freememory
Change Directory>C:\ScrapeLos\Temp
IffileExists>C:\ScrapeLOS\Temp\templist.txt
DeleteFile>C:\ScrapeLOS\Temp\templist.txt
ENDif
If>FileExists>C:\ScrapeLOS\temp\headings.txt
Deletefile>C:\ScrapeLOS\temp\headings.txt
ENDif
If>FileExists>C:\ScrapeLOS\temp\pages.txt
Deletefile>C:\ScrapeLOS\temp\pages.txt
ENDif
Let>RP_Wait=1
Let>RP_WINDOWMODE=0
Run Program>cmd /c mbtpdfasm.exe -m%LoanNumber%*.*\.pdf -gHFN >pages.txt
StringReplace>%LoanNumber%,-,,LoanNumber
Let>bm=1
Let>bmorder=0
Let>tpdfpages=1
Label>startbm
ReadLn>C:\ScrapeLOS\temp\pages.txt,bm,bmline
If>bmline=##EOF##,finishbm
If>bm=1,skipheader
Let>filefirstpart=.\%LoanNumber%-
StringReplace>%bmline%,%filefirstpart%,,newline
StringReplace>%newline%,.pdf,,newline
Separate>bmline,;,headerfile_names
If>headerfile_names_count=0,rhEND
Let>hn=0
Repeat>hn
Let>hn=hn+1
If>hn=1
Let>pdftempname=headerfile_names_%hn%
Let>filefirstpart=.\%LoanNumber%-
StringReplace>%pdftempname%,%filefirstpart%,,newline
StringReplace>%newline%,.pdf,,bookmark
ENDif
If>hn=2
Let>pdfpages=headerfile_names_%hn%
ENDif
Let>headingline=%bmorder% 0 %bmorder% %tpdfpages% %bookmark%
Until>hn,headerfile_names_count
Label>rhEND
Label>skipheader
Let>bmorder=bmorder+1
ENDif
If>bm=1,skipone
SRT>skipone
Let>bm=bm+1
Goto>startbm
END>skipone
Let>templistline=c:\Scrapelos\temp\%LoanNumber%-%newline% *
WriteLn>C:\ScrapeLOS\temp\headings.txt,result,%headingline%
WriteLn>C:\ScrapeLOS\Temp\templist.txt,result,%templistline%
Let>bm=bm+1
Let>tpdfpages=tpdfpages+pdfpages
Goto>startbm
Label>finishbm
Let>RP_Wait=1
Let>RP_WINDOWMODE=0
Run Program>mbtpdfasm.exe -d%LoanNumber%.pdf -sC:\ScrapeLOS\Temp\templist.txt -oC:\ScrapeLOS\Temp\headings.txt
Label>AppraisalOnly
CopyFile>C:\ScrapeLOS\Temp\%LoanNumber%.pdf,%one.mpdfarchivepath%\
DeleteFile>C:\ScrapeLOS\Temp\*.pdf
/ExecuteFile>C:\ScrapeLOS\Temp\%LoanNumber%.pdf
END>compile
Label>EOF
EXIT
SubRoutine not returning
Moderators: JRL, Dorian (MJT support)
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Have you tried debugging this? What about the log files? Something in your script is causing execution flow to change. Will not be able to help without debugging it. You need to open the debugger, open the watch list and sit in front of it and step through line by line and watch what happens. Keep an eye on the watch list. Feel free to send script and detailed log files to support, but you should try debugging it first. Log files may help us but the best way for us to help would be to link up to your machine and sit in front of it and debug it for you.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
Debug and log file
I have pressed f8 and watched it for hours that is how I know it bails on the last subroutine. I didn't get much out of the log files as they just seem to display what is on the watch list.
I would appriecate it if you would log into my PC and take a look as the only thing I can think of at this point is to compile the last subroutine and run it as an executable file from the script and then return to the script.
Just let me know what I need to do on my end for you to login.
I would appriecate it if you would log into my PC and take a look as the only thing I can think of at this point is to compile the last subroutine and run it as an executable file from the script and then return to the script.
Just let me know what I need to do on my end for you to login.
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Give me a call on the phone and we'll set it up. You'll find contact numbers at http://www.mjtnet.com/contact.htm
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
For anyone following this the problem turned out to be a nested subroutine within a loop within which was a Goto which branched out of the subroutine into the parent subroutine but execution was never able to return to the subroutine to complete it. Therefore the stack would grow with repeated calls to the same subroutine which never returned.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?