SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 3 of 3
  1. #1
    Junior Member
    Join Date
    Sep 2008
    Posts
    5
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Recusive Function - losing boolean value

    I have written a recursive function, that will perform binary comparison on objects in a folder directory/hierarchy. What happens is that if a binary comparison fails, the test case will fail. If the binary comparison passes, the test case will pass. I have set up a Boolean variable and assigned it to the binary comparison. Obviously I initialised the variable and set it to FALSE. When the binary comparison is taken place, the value of the Boolean variable will change accordingly.

    Now what is happening is that even though all of the binary comparisons are returning TRUE, the Boolean variable in the end is returning FALSE.

    When debugging I found out that somewhere the Boolean value gets lost and returns to the original state, but I canít figure out why.

    Here is the function:
    [-] BOOLEAN VerifyExport(STRING sObj, STRING sTestCaseNumber, STRING sRecActDir optional, STRING sRecBaseDir optional)
    [ ] INTEGER iFolders
    [ ] INTEGER iItems
    [ ] INTEGER iTotal
    [ ] STRING sRecActual
    [ ] STRING sRecBase
    [ ] STRING sBase
    [ ] STRING sActual
    [ ] BOOLEAN bBinary
    [ ] LIST OF FILEINFO lfActual
    [ ] INTEGER iCount
    [ ]
    [-] do
    [ ] bBinary = NULL
    [ ]
    [-] switch(sObj)
    [-] case("Modules")
    [-] if(bRecursion == FALSE)//no recursion
    [ ] sBase = "{cs_stBaseMod}\Export_Import\{sTestCaseNumber }"
    [ ] sActual = cs_stActMod
    [-] else//recursion is involved
    [ ] sBase = sRecBaseDir
    [ ] sActual = sRecActDir
    [-] case("Combinations")
    [-] if(bRecursion == FALSE)//no recursion
    [ ] sBase = "{cs_stBaseComb}\Export_Import\{sTestCaseNumbe r}\"
    [ ] sActual = cs_stActComb
    [-] else//recursion is involved
    [ ] sBase = sRecBaseDir
    [ ] sActual = sRecActDir
    [-] case("Reports")
    [-] if(bRecursion == FALSE)//no recursion
    [ ] sBase = "{cs_stBaseRep}\Export_Import\{sTestCaseNumber }\"
    [ ] sActual = cs_stActRep
    [-] else//recursion is involved
    [ ] sBase = sRecBaseDir
    [ ] sActual = sRecActDir
    [-] default
    [ ] CommonFun.MsgLogFun.OptLogFailure("Wrong object entered, was expected either, Module, Combination or Report. Instead got '{sObj}'")
    [ ] //check to see if there are any objects
    [ ] iFolders = CommonFun.UtilFun.OptGetDirCount(sActual, "Folders", FALSE)
    [ ] iItems = CommonFun.UtilFun.OptGetDirCount(sActual, "Items", FALSE)
    [ ] iTotal = iFolders + iItems
    [ ]
    [-] if(iTotal <= 0)
    [ ] CommonFun.MsgLogFun.OptLogError("There are no objects in location: {sActual}")
    [-] else
    [ ] CommonFun.MsgLogFun.OptLogInfo("The directory that you are setting is {sActual}")
    [ ] SYS_SetDir(sActual)
    [ ] lfActual = CommonFun.UtilFun.OptGetObj(sActual)
    [ ]
    [-] for iCount = 1 to ListCount(lfActual)
    [-] if(lfActual[iCount].bIsDir ==FALSE)//item
    [ ] bRecursion = FALSE
    [ ] STRING sItem = lfActual[iCount].sName
    [ ] CommonFun.MsgLogFun.OptLogInfo("Performing a binary comparision on the following {sObj}: {cs_st_NewLine}{sBase}\{sItem} {cs_st_NewLine}Against {cs_st_NewLine}{sActual}\{sItem}")
    [ ] bBinary = CommonFun.UtilFun.OptCompareBinary("{sBase}\{sItem }","{sActual}\{sItem}")
    [-] for iCount = 1 to ListCount(lfActual)
    [-] if((lfActual[iCount].bIsDir ==TRUE) && (lfActual[iCount].iAttributes != 18))//&&(lfActual[iCount].sName != ".") &&(lfActual[iCount].sName != ".." ))//Folders not including hidden folders
    [ ] STRING sFolder = lfActual[iCount].sName
    [ ] //comparison of the folder --> check if the folder exists within the actual area.
    [ ] BOOLEAN bFolder = CommonFun.UtilFun.OptFolderExists("{sActual}\{sFol der}", FALSE)
    [ ]
    [-] if(bFolder == TRUE)
    [ ] bRecursion = TRUE
    [ ] CommonFun.MsgLogFun.OptLogInfo("Checking the folder: {sActual}\{sFolder}")
    [ ] sRecActual = "{sActual}\{sFolder}"
    [ ] sRecBase = "{sBase}\{sFolder}"
    [ ] OptimaFun.Windows.VerifyExport(sObj,sTestCaseNumbe r, sRecActual, sRecBase)
    [-] else
    [ ] CommonFun.MsgLogFun.OptLogError("Directory '{sActual}\{sFolder}' does not exist.")
    [ ] return bBinary
    [-] except
    [ ] CommonFun.ErrorFun.OptExcept()


    Any help would be greatly appreciated.

    Thanks

  2. #2
    Member
    Join Date
    Sep 2006
    Location
    Germany, Dresden
    Posts
    181
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Recusive Function - losing boolean value

    Use code tag to post your code

  3. #3
    Member
    Join Date
    Sep 2006
    Location
    Germany, Dresden
    Posts
    181
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Recusive Function - losing boolean value

    Perhaps OptCompareBinary is incorrect.

    Try
    bBinary = CommonFun.UtilFun.OptCompareBinary("{sBase}\{sItem }","{sActual}\{sItem}")
    print (bBinary)
    to see if bBinary always TRUE

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 11.54%
vBulletin Optimisation provided by vB Optimise v2.6.4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.2.8 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 04:13 AM.

Copyright BetaSoft Inc.