ezpc_rox Posted May 28, 2008 Posted May 28, 2008 ok.. trying again.. using this script below New Script Go to Layout [ “Layout #36” (nasd_NOTE__cno) ] Perform Find [ Specified Find Requests: Find Records; Criteria: nasd_NOTE__cno::Tried: “Tried” ] [ Restore ] Loop If [ nasd_NOTE__cno::ndate < nasd_NOTE__cno::st_date ] Omit Record End If If [ nasd_NOTE__cno::en_date > nasd_NOTE__cno::ndate ] Omit Record End If End Loop what i want this to do is find all records with the "tried" field filled in, but i want it to only add the ones in the date range to the found set, it ignores both if lines and stays in the loop until i hit esc.. what gives?
Fitch Posted May 28, 2008 Posted May 28, 2008 You haven't specified any exit condition for the loop. How is it supposed to know when to stop? You want something like this: Loop If [ nasd_NOTE__cno::ndate < nasd_NOTE__cno::st_date ] Omit Record Else If [ nasd_NOTE__cno::en_date > nasd_NOTE__cno::ndate ] Omit Record Else Go to record (next; exit after last) End If Exit Loop If( Get( FoundCount ) = 0 ) // in case all records are omitted End Loop
ezpc_rox Posted May 28, 2008 Author Posted May 28, 2008 (edited) that makes sense, thank you for the feedback.. so i edited my script as you described, i think i need different criteria for the loop to end though, since it finds 11000 matches, it just continues on..i think it may be ignoring my date range also.. would turning error capture on make it report script errors to me? maybe help me diagnose whats not working? New Script Go to Layout [ “Layout #36” (nasd_NOTE__cno) ] Perform Find [ Specified Find Requests: Find Records; Criteria: nasd_NOTE__cno::Tried: “Tried” ] [ Restore ] Loop If [ nasd_NOTE__cno::ndate < nasd_NOTE__cno::st_date ] Omit Record Else If [ nasd_NOTE__cno::ndate > nasd_NOTE__cno::en_date ] Omit Record End If Exit Loop If [ (Get ( FoundCount ) = 0) ] End Loop also, just to provide more info, this table is a notes portal, ndate is the date of the note st_date is a global field i added to a new layout for this report I'm trying to produce, en_date is the end date, also a global field (i tried using a date field on a previous attempt) the script seems to be ignoring both if statements, i get the same number of results no matter what date i enter. Edited May 28, 2008 by Guest
ezpc_rox Posted May 28, 2008 Author Posted May 28, 2008 doh! i see it now, sorry about that.. it does now exit the loop, i just have to figure out why it doesn't like my dates, thanks New Script Go to Layout [ “Layout #36” (nasd_NOTE__cno) ] Set Error Capture [ On ] Perform Find [ Specified Find Requests: Find Records; Criteria: nasd_NOTE__cno::Tried: “Tried” ] [ Restore ] Go to Record/Request/Page [ First ] Loop If [ nasd_NOTE__cno::ndate < nasd_NOTE__cno::st_date ] Omit Record Else If [ nasd_NOTE__cno::ndate > nasd_NOTE__cno::en_date ] Omit Record Else If [ nasd_NOTE__cno::initials ≠ nasd_NOTE__cno::rpt_initials ] Omit Record End If Go to Record/Request/Page [ Next; Exit after last ] Exit Loop If [ (Get ( FoundCount ) = 0) ] End Loop
Fitch Posted May 28, 2008 Posted May 28, 2008 You really, really need to look again at my example and do it this way: ELSE Go to next END IF The way you've done it is a classic mistake: - it omits record A, - you'll be on record B, - it will go to the next record C - i.e., record B is never checked.
ezpc_rox Posted May 30, 2008 Author Posted May 30, 2008 you were right about the loop not evaluating all the records the way i had it, but when i try to add in the "else" before the exit, i get a never ending loop, this script looks different then the one i originally posted, but the if/then structure is basically the same recruit stats Go to Record/Request/Page [ First ] Loop If [ nasd_NOTE__cno::Tried ≠ "tried" ] Omit Record Else If [ nasd_NOTE__cno::TT ≠ "TT" ] Omit Record End If Go to Record/Request/Page [ Next; Exit after last ] End Loop Go to Record/Request/Page [ First ] Loop If [ nasd_NOTE__cno::initials = "KAT" and nasd_NOTE__cno::Tried = "Tried" ] Set Variable [ $kattried; Value:$kattried+1 ] Else If [ nasd_NOTE__cno::initials = "KAT" and nasd_NOTE__cno::TT = "TT" ] Set Variable [ $kattt; Value:$kattt+1 ] Else If [ nasd_NOTE__cno::initials = "DAP" and nasd_NOTE__cno::Tried = "Tried" ] Set Variable [ $daptried; Value:$daptried+1 ] Else If [ nasd_NOTE__cno::initials = "DAP" and nasd_NOTE__cno::TT = "TT" ] Set Variable [ $daptt; Value:$daptt+1 ] Else If [ nasd_NOTE__cno::initials = "JID" and nasd_NOTE__cno::Tried = "Tried" ] Set Variable [ $jidtried; Value:$jidtried+1 ] Else If [ nasd_NOTE__cno::initials = "JID" and nasd_NOTE__cno::TT = "TT" ] Set Variable [ $jidtt; Value:$jidtt+1 ] Else If [ nasd_NOTE__cno::initials = "HML" and nasd_NOTE__cno::Tried = "Tried" ] Set Variable [ $hmltried; Value:$hmltried+1 ] Else If [ nasd_NOTE__cno::initials = "HML" and nasd_NOTE__cno::TT = "TT" ] Set Variable [ $hmltt; Value:$hmltt+1 ] Else Go to Record/Request/Page [ Next; Exit after last ] End If End Loop Set Field [ nasd_NOTE__cno::zc_katcount; $kattried + $kattt ] Set Field [ nasd_NOTE__cno::zc_tt_katcount; $kattt ] Set Field [ nasd_NOTE__cno::zc_jidcount; $jidtried + $jidtt ] Set Field [ nasd_NOTE__cno::zc_tt_jidcount; $jidtt ] Set Field [ nasd_NOTE__cno::zc_dapcount; $daptried + $daptt ] Set Field [ nasd_NOTE__cno::zc_tt_dapcount; $daptt ] Set Field [ nasd_NOTE__cno::zc_hmlcount; $hmltried + $hmltt ] Set Field [ nasd_NOTE__cno::zc_tt_hmlcount; $hmltt ] did i do the else/exit wrong?
Fitch Posted May 30, 2008 Posted May 30, 2008 Now you have two loops. You still haven't done the first loop the way I showed you, so some records will be skipped over and not evaluated, as I explained in my last post. Your second loop does not perform any Omit, so by putting the go to next/exit following the else, you've created an endless loop. Remove the else from the second loop. Insert an else in the first loop.
Recommended Posts
This topic is 6022 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now