SoftTree Technologies SoftTree Technologies
Technical Support Forums
RegisterSearchFAQMemberlistUsergroupsLog in
nested loops

 
Reply to topic    SoftTree Technologies Forum Index » 24x7 Scheduler, Event Server, Automation Suite View previous topic
View next topic
nested loops
Author Message
martin



Joined: 20 Sep 2000
Posts: 14

Post nested loops Reply with quote

I am getting an error:

"Invalid nesting, nested construct must not overlap parent construct

boundaries"

on a nested loop. The inner loop makes one pass successfully, but the
subsequent pass causes this error.

The documentation says nested loops are supported. In another part of
the help file, it says it is not. ??? I am on version 2.4.0.

The script:

Dim dTodaysDate date
Dim sYearMonth string
Dim nFileNum1 number
Dim nFileNum2 number
Dim nFileNum3 number
Dim bEOF1 boolean
Dim bEOF2 boolean
Dim bNEOF2 boolean
Dim sEmail string
Dim sEmailSave string
Dim sRecordIn string
Dim sFirst2Char string
//Dim bNewMBU boolean
Dim sMBU string
Dim sMBUs string
//Dim bNewEmail string
Dim bFileOpen boolean
Dim bFileWrite boolean
Dim nSeqNbr number
Dim sFileName string
//
//--------------------------------------------initialize variables
Set( bEOF1, "false" )
Set( bEOF2, "false" )
Set( bNEOF2, "true" )
//Set( bNewMBU, "false" )
Set( bFileOpen, "false" )
Set( bFileWrite, "false" )
//--------------------------------------------Get the year/month reporting date
Today( dTodaysDate )
Format( dTodaysDate, "yymm", sYearMonth )
//
//--------------------------------------------set working directory-------------
CD( "d:\chargeback" )
//--------------------------------open the email list file as read only---------
FileOpen( "email.txt", "LineMode", "Read", "False", nFileNum1 )
//
//--------------------------------------------loop through the email list file-
LoopUntil( bEOF1, Exit_Main_Loop )

FileRead( nFileNum1, sEmail )
//--------------------------------------------check for end of file------------

EOF( nFileNum1, bEOF1 )
//--------------------------------------------reset variables------------------

Set( nFileNum2, "" )

Set( nFileNum3, "" )

Set( bFileWrite, "false" )
//--------------------------------------------open the bills file------------

FileOpen( "bill.txt", "LineMode", "Read", "False", nFileNum2 )

FileCopy( "null.txt", "temp_bill.txt" )

FileOpen( "temp_bill.txt", "LineMode", "Write", "True", nFileNum3 )
//--------------------------------------------loop through the bill file-------

LoopUntil( bEOF2, Exit_Inner_Loop )

FileRead( nFileNum2, sRecordIn )

EOF( nFileNum2, bEOF2 )
//--------------------------------------------move the first 2 to a var--------

Left( sRecordIn, 2, sFirst2Char )
//--------------------------------------------test the first 2 positions----

ChooseCase( sFirst2Char, Case_Else )
//----------------------------------- beginning of a new bill/MBU-------------

Case "~~"
//--------------------------------------------save the MBU name---------------

Mid( sRecordIn, 3, 8, sMBU )
//--------------------------------------------if we have a file write ind----

IfThen( bFileWrite, Write_Page_Break)

Continue

Write_Page_Break:

FileWrite( nFileNum3, "zzz_page_break" )
//--------------------------------------------reset the file write indicator

Set( bFileWrite, "false" )

Continue
//--------------------------------------------if it's equal to ^^----

Case "^^"
//--------------------------------------------first, test if we already found

IfThen( bFileWrite, Exit_Case )

IsEqual( sRecordIn, sEmail, bFileWrite )
//--------------------------------------------if email matches, set the file

IfThen( bFileWrite, Parse_EMail )

Continue

Parse_EMail:

Mid( sEmail, 3, 50, sEmailSave )

FileWrite( nFileNum3, sEmailSave )

Continue

Exit_Case:

Continue
//--------------------------------------------if neither ~~ nor ^^,

Case_Else:

IfThen( bFileWrite, Write_File )

IfThen( bEOF2, Exit_Inner_Loop )

Continue

Write_File:

FileWrite( nFileNum3, sRecordIn )

IfThen( bEOF2, Exit_Inner_Loop )

Continue
//--------------------------------------------when the inner loop is done

Exit_Inner_Loop:

FileClose( nFileNum2 )

FileClose( nFileNum3 )

Set( bEOF2, "false" )

Set( bFileWrite, "false" )

Add( nSeqNbr, 1, nSeqNbr )

Concat( sFileName, "temp_bill", sFileName )

Concat( sFileName, nSeqNbr, sFileName )

Concat( sFileName, ".txt", sFileName )

FileRename( "temp_bill.txt", sFileName )
// Continue
//
Exit_Main_Loop:
Exit

Thu Apr 05, 2001 6:11 pm View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7948

Post Re: nested loops Reply with quote

I guess it is a result of automatic HTML formatting that causes collapsing of spaces and tabs in the script making the pasted text difficult to read.

Anyway, nested loops are supported. The error you get does not mean that here is a problem with nested loops. It could be also result of incorrectly nested IFThen IFThenElse and ChooseCase constructs.

Especially suspicious is the following line
ChooseCase( sFirst2Char, Case_Else )

Should it be ChooseCase( sFirst2Char, Exit_Case ) ?

Make sure that Case_Else in your script goes before Exit_Case.

By the way, I highly recommend upgrading to 2.4.10 as a more stable version.

: I am getting an error: "Invalid nesting, nested construct must not
: overlap parent construct

: boundaries"

: on a nested loop. The inner loop makes one pass successfully, but the
: subsequent pass causes this error.

: The documentation says nested loops are supported. In another part of
: the help file, it says it is not. ??? I am on version 2.4.0.

: The script: Dim dTodaysDate date
: Dim sYearMonth string
: Dim nFileNum1 number
: Dim nFileNum2 number
: Dim nFileNum3 number
: Dim bEOF1 boolean
: Dim bEOF2 boolean
: Dim bNEOF2 boolean
: Dim sEmail string
: Dim sEmailSave string
: Dim sRecordIn string
: Dim sFirst2Char string
: //Dim bNewMBU boolean
: Dim sMBU string
: Dim sMBUs string
: //Dim bNewEmail string
: Dim bFileOpen boolean
: Dim bFileWrite boolean
: Dim nSeqNbr number
: Dim sFileName string
: //
: //--------------------------------------------initialize variables
: Set( bEOF1, "false" )
: Set( bEOF2, "false" )
: Set( bNEOF2, "true" )
: //Set( bNewMBU, "false" )
: Set( bFileOpen, "false" )
: Set( bFileWrite, "false" )
: //--------------------------------------------Get the year/month reporting
: date
: Today( dTodaysDate )
: Format( dTodaysDate, "yymm", sYearMonth )
: //
: //--------------------------------------------set working
: directory-------------
: CD( "d:\chargeback" )
: //--------------------------------open the email list file as read
: only---------
: FileOpen( "email.txt", "LineMode", "Read",
: "False", nFileNum1 )
: //
: //--------------------------------------------loop through the email list
: file-
: LoopUntil( bEOF1, Exit_Main_Loop )

: FileRead( nFileNum1, sEmail )
: //--------------------------------------------check for end of
: file------------

: EOF( nFileNum1, bEOF1 )
: //--------------------------------------------reset
: variables------------------

: Set( nFileNum2, "" )

: Set( nFileNum3, "" )

: Set( bFileWrite, "false" )
: //--------------------------------------------open the bills file------------

: FileOpen( "bill.txt", "LineMode", "Read",
: "False", nFileNum2 )

: FileCopy( "null.txt", "temp_bill.txt" )

: FileOpen( "temp_bill.txt", "LineMode", "Write",
: "True", nFileNum3 )
: //--------------------------------------------loop through the bill
: file-------

: LoopUntil( bEOF2, Exit_Inner_Loop )

: FileRead( nFileNum2, sRecordIn )

: EOF( nFileNum2, bEOF2 )
: //--------------------------------------------move the first 2 to a
: var--------

: Left( sRecordIn, 2, sFirst2Char )
: //--------------------------------------------test the first 2 positions----

: ChooseCase( sFirst2Char, Case_Else )
: //----------------------------------- beginning of a new
: bill/MBU-------------

: Case "~~"
: //--------------------------------------------save the MBU
: name---------------

: Mid( sRecordIn, 3, 8, sMBU )
: //--------------------------------------------if we have a file write ind----

: IfThen( bFileWrite, Write_Page_Break)

: Continue

: Write_Page_Break: FileWrite( nFileNum3, "zzz_page_break" )
: //--------------------------------------------reset the file write indicator

: Set( bFileWrite, "false" )

: Continue
: //--------------------------------------------if it's equal to ^^----

: Case "^^"
: //--------------------------------------------first, test if we already found

: IfThen( bFileWrite, Exit_Case )

: IsEqual( sRecordIn, sEmail, bFileWrite )
: //--------------------------------------------if email matches, set the file

: IfThen( bFileWrite, Parse_EMail )

: Continue

: Parse_EMail: Mid( sEmail, 3, 50, sEmailSave )

: FileWrite( nFileNum3, sEmailSave )

: Continue

: Exit_Case: Continue
: //--------------------------------------------if neither ~~ nor ^^,

: Case_Else: IfThen( bFileWrite, Write_File )

: IfThen( bEOF2, Exit_Inner_Loop )

: Continue

: Write_File: FileWrite( nFileNum3, sRecordIn )

: IfThen( bEOF2, Exit_Inner_Loop )

: Continue
: //--------------------------------------------when the inner loop is done

: Exit_Inner_Loop: FileClose( nFileNum2 )

: FileClose( nFileNum3 )

: Set( bEOF2, "false" )

: Set( bFileWrite, "false" )

: Add( nSeqNbr, 1, nSeqNbr )

: Concat( sFileName, "temp_bill", sFileName )

: Concat( sFileName, nSeqNbr, sFileName )

: Concat( sFileName, ".txt", sFileName )

: FileRename( "temp_bill.txt", sFileName )
: // Continue
: //
: Exit_Main_Loop: Exit

Thu Apr 05, 2001 10:39 pm View user's profile Send private message
Malcolm Wise



Joined: 26 Jan 2000
Posts: 22

Post Re: nested loops Reply with quote

I too am getting the same error! I have a ChooseCase nested within a LoopUntil. I get the error when the condition to exit the LoopUntil has been met. I can't see any obvious problem with my code. If I remove the ChooseCase, I no longer get the error. I've also tried removing the 'If' within the LoopUntil, but this makes no difference. I am on version 2.4.10. Here is the script:

Dim nRc Number
Dim nLen Number
Dim bEOF Boolean
Dim bAttachFile Boolean
Dim bFileFound Boolean
Dim sMailEventmailId String
Dim sSubject String
Dim sRecipients String
Dim sMessage String
Dim sMsgType String
Dim sFile String
Dim sRecord String
Dim sSQL String
Dim sHeader String

DatabaseConnect "Excalibur"
DatabaseRetrieve "exec usp_sel_mail_event_mail", nRc

NotFileExists "c:\mail.txt", bFileFound

IfThen bFileFound, SAVE_DATA

FileDelete "c:\mail.txt"

SAVE_DATA:
DatabaseSave "c:\mail.txt", "TXT", nRc

FileReadAll "c:\mail.txt", sFile
Set bEOF, FALSE

LoopUntil bEOF, END_LOOP

GetToken "\t", sFile, sMailEventMailId

GetToken "\t", sFile, sSubject

GetToken "\n", sFile, sRecipients

Set sSQL, "select MESSAGE from dbo.MAIL_EVENT_MAIL where MAIL_EVENT_MAIL_ID = "

ConcatEx sSQL, sMailEventMailId, sSQL

DatabaseRetrieve sSQL, nRc

DatabaseGet 1, 1, sMessage

Left sMessage, 2, sMsgType

IsEqual, "\\", sMsgType, bAttachFile

If bAttachFile SEND_FILE, CHECK_SQL

SEND_FILE:

MailSendWithAttachment "Excalibur", "", "malcolm.wise@sde.eu.sony.com", sSubject, "Please see attached", sMessage

GoTo END_CHOOSE

CHECK_SQL:

Set sMsgType, sMessage

GetToken " ", sMsgType, sMsgType

Upper sMsgType, sMsgType

ChooseCase sMsgType, END_CHOOSE

Case "SELECT", "EXEC", "EXECUTE"

DatabaseRetrieve sMessage, nRc

DatabaseSave "c:\result.txt", "TXT", nRc

DatabaseDescribe sHeader

MailSendWithAttachment "Excalibur", "", "malcolm.wise@sde.eu.sony.com", sSubject, "Please see attached", "c:\result.txt"

FileDelete "c:\result.txt"

CaseElse

MailSend "Excalibur", "", "malcolm.wise@sde.eu.sony.com", sSubject, sMessage

END_CHOOSE:

Length sFile, nLen

IsEqual nLen, 0, bEOF
END_LOOP:
DatabaseDisconnect
Exit

: I guess it is a result of automatic HTML formatting that causes collapsing of
: spaces and tabs in the script making the pasted text difficult to read.

: Anyway, nested loops are supported. The error you get does not mean that here
: is a problem with nested loops. It could be also result of incorrectly
: nested IFThen IFThenElse and ChooseCase constructs.

: Especially suspicious is the following line
: ChooseCase( sFirst2Char, Case_Else )

: Should it be ChooseCase( sFirst2Char, Exit_Case ) ?

: Make sure that Case_Else in your script goes before Exit_Case.

: By the way, I highly recommend upgrading to 2.4.10 as a more stable version.

Wed Apr 18, 2001 10:12 am View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7948

Post Re: nested loops Reply with quote

First try adding another label after END_CHOOSE and changing GoTo END_CHOOSE to GoTo new_label_here

It looks like you are using default "\" as a spceial ASCII character prefix. If this is true, you should change everywhere "c:\result.txt" to "c:\\result.txt"

: I too am getting the same error! I have a ChooseCase nested within a
: LoopUntil. I get the error when the condition to exit the LoopUntil has
: been met. I can't see any obvious problem with my code. If I remove the
: ChooseCase, I no longer get the error. I've also tried removing the 'If'
: within the LoopUntil, but this makes no difference. I am on version
: 2.4.10. Here is the script: Dim nRc Number
: Dim nLen Number
: Dim bEOF Boolean
: Dim bAttachFile Boolean
: Dim bFileFound Boolean
: Dim sMailEventmailId String
: Dim sSubject String
: Dim sRecipients String
: Dim sMessage String
: Dim sMsgType String
: Dim sFile String
: Dim sRecord String
: Dim sSQL String
: Dim sHeader String

: DatabaseConnect "Excalibur"
: DatabaseRetrieve "exec usp_sel_mail_event_mail", nRc

: NotFileExists "c:\mail.txt", bFileFound

: IfThen bFileFound, SAVE_DATA

: FileDelete "c:\mail.txt"

: SAVE_DATA: DatabaseSave "c:\mail.txt", "TXT", nRc

: FileReadAll "c:\mail.txt", sFile
: Set bEOF, FALSE

: LoopUntil bEOF, END_LOOP

: GetToken "\t", sFile, sMailEventMailId

: GetToken "\t", sFile, sSubject

: GetToken "\n", sFile, sRecipients

: Set sSQL, "select MESSAGE from dbo.MAIL_EVENT_MAIL where
: MAIL_EVENT_MAIL_ID = "

: ConcatEx sSQL, sMailEventMailId, sSQL

: DatabaseRetrieve sSQL, nRc

: DatabaseGet 1, 1, sMessage

: Left sMessage, 2, sMsgType

: IsEqual, "\\", sMsgType, bAttachFile

: If bAttachFile SEND_FILE, CHECK_SQL

: SEND_FILE: MailSendWithAttachment "Excalibur", "",
: "malcolm.wise@sde.eu.sony.com", sSubject, "Please see
: attached", sMessage

: GoTo END_CHOOSE

: CHECK_SQL: Set sMsgType, sMessage

: GetToken " ", sMsgType, sMsgType

: Upper sMsgType, sMsgType

: ChooseCase sMsgType, END_CHOOSE

: Case "SELECT", "EXEC", "EXECUTE"

: DatabaseRetrieve sMessage, nRc

: DatabaseSave "c:\result.txt", "TXT", nRc

: DatabaseDescribe sHeader

: MailSendWithAttachment "Excalibur", "",
: "malcolm.wise@sde.eu.sony.com", sSubject, "Please see
: attached", "c:\result.txt"

: FileDelete "c:\result.txt"

: CaseElse

: MailSend "Excalibur", "",
: "malcolm.wise@sde.eu.sony.com", sSubject, sMessage

: END_CHOOSE: Length sFile, nLen

: IsEqual nLen, 0, bEOF
: END_LOOP: DatabaseDisconnect
: Exit

Wed Apr 18, 2001 12:10 pm View user's profile Send private message
Malcolm Wise



Joined: 26 Jan 2000
Posts: 22

Post Re: nested loops Reply with quote

Adding another label did not make any difference. Thanks for pointing out the "c:\result.txt" error. I found out the hard way!

: First try adding another label after END_CHOOSE and changing GoTo END_CHOOSE
: to GoTo new_label_here

: It looks like you are using default "\" as a spceial ASCII
: character prefix. If this is true, you should change everywhere
: "c:\result.txt" to "c:\\result.txt"

Thu Apr 19, 2001 5:32 am View user's profile Send private message
Malcolm Wise



Joined: 26 Jan 2000
Posts: 22

Post Re: nested loops Reply with quote

Has there been any progress on this? I've just upgraded to 2.4.11 and the error is still there. Is it a bug? I need to get this working asap!
Thanks

: Adding another label did not make any difference. Thanks for pointing out the
: "c:\result.txt" error. I found out the hard way!

Tue Apr 24, 2001 5:08 am View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7948

Post Re: nested loops Reply with quote

It hasn't been fixed yet.

I would like to suggest a workaround for this problem. I checked your code and think the following line should help if inserted just before the END_LOOP label

IfThen bEOF, DONE

Add DONE label at the end of the script or after .

: Has there been any progress on this? I've just upgraded to 2.4.11 and the
: error is still there. Is it a bug? I need to get this working asap!
: Thanks

Tue Apr 24, 2001 7:58 am View user's profile Send private message
Malcolm Wise



Joined: 26 Jan 2000
Posts: 22

Post Re: nested loops Reply with quote

Thanks, the workaround works fine.

: It hasn't been fixed yet.

: I would like to suggest a workaround for this problem. I checked your code
: and think the following line should help if inserted just before the
: END_LOOP label

: IfThen bEOF, DONE

: Add DONE label at the end of the script or after .

Thu Apr 26, 2001 3:30 am View user's profile Send private message
Display posts from previous:    
Reply to topic    SoftTree Technologies Forum Index » 24x7 Scheduler, Event Server, Automation Suite All times are GMT - 4 Hours
Page 1 of 1

 
Jump to: 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


 

 

Powered by phpBB © 2001, 2005 phpBB Group
Design by Freestyle XL / Flowers Online.