ghengis Posted July 29, 2007 Share Posted July 29, 2007 Hi, I have a file with 100 records. I would like to create a random number and then mark every 2nd record starting from the random record. I know how to create a random record (see below) GetNthRecord ( CountAndMark::ContactID ; Int ( Random * Get (FoundCount ) ) ) but I'm have trouble looping through all 100 records starting from the random number and marking every second. Please help. Thanks in advance Ghengis Link to comment Share on other sites More sharing options...
ghengis Posted July 29, 2007 Author Share Posted July 29, 2007 sorry I posted this in the wrong section Link to comment Share on other sites More sharing options...
mr_vodka Posted July 29, 2007 Share Posted July 29, 2007 (edited) Well after going to that specific record, you would need to script it so that it loops through the remainder of your records. Go to Record [ Get ( RecordNumber ) + 2 ] will make you go the record 2 records down. Set Variable [ $randomrec; Int ( Random * Get ( FoundCount ) + 1 ] Go to Record [ $randomrec ] Loop Go to record [ Get ( RecordNumber ) + 2 ] Set Field [ mark; 1 ] Exit Loop If [ Get ( RecordNumber ) > Get ( FoundCount ) - 2 ) End Loop Edited July 29, 2007 by Guest Made changes to loop Link to comment Share on other sites More sharing options...
Genx Posted July 29, 2007 Share Posted July 29, 2007 Exit Loop If [ Get ( RecordNumber ) <= Get ( FoundCount ) - 2 ) Should be: Exit Loop If [ Get ( RecordNumber ) > Get ( FoundCount ) - 2 ) Link to comment Share on other sites More sharing options...
mr_vodka Posted July 29, 2007 Share Posted July 29, 2007 Yes. I just realized that. Thanks for the correction. Thats what I get for posting while laying down on my couch. ;) Link to comment Share on other sites More sharing options...
Genx Posted July 29, 2007 Share Posted July 29, 2007 I'm sure you would've done the same for me if I was lying on my couch ;) Link to comment Share on other sites More sharing options...
ghengis Posted July 29, 2007 Author Share Posted July 29, 2007 Thanks for the quick response. I must be doing something wrong, it's not working for me. Script just gets to the 100th record and stops. Link to comment Share on other sites More sharing options...
Lee Smith Posted July 29, 2007 Share Posted July 29, 2007 The position on the couch should have no barring on the quality of the post, maybe on the length of it........zzzzzzzzzzzzzzzzzz Link to comment Share on other sites More sharing options...
Genx Posted July 29, 2007 Share Posted July 29, 2007 (edited) Thanks for the quick response. I must be doing something wrong, it's not working for me. Script just gets to the 100th record and stops. Isn't that what you asked for? Edited July 29, 2007 by Guest Link to comment Share on other sites More sharing options...
ghengis Posted July 29, 2007 Author Share Posted July 29, 2007 I want to include all 100 records in the calc. say for example the random number is 98 I would like the loop to begin from the 98th record and end on the 98th record (full circle) not end on the 100th. Sorry to be a pain, as you can tell I'm new to this. Link to comment Share on other sites More sharing options...
Genx Posted July 29, 2007 Share Posted July 29, 2007 So really what you're saying is you want to pick an odd or even number, mark ever second record and return to your original record? Link to comment Share on other sites More sharing options...
ghengis Posted July 29, 2007 Author Share Posted July 29, 2007 yes that's correct. Link to comment Share on other sites More sharing options...
ghengis Posted July 29, 2007 Author Share Posted July 29, 2007 I would say that the problem is the "exit loop if" step Exit Loop If [ Get ( RecordNumber ) > Get ( FoundCount ) - 2 ) This exits the at record 100 Link to comment Share on other sites More sharing options...
Genx Posted July 29, 2007 Share Posted July 29, 2007 (edited) Not really... This should probably work: Freeze Window Set Variable [ $recNum ; Get(RecordNumber) ] Go to Record [ 1 + Mod( Round( Random * 10 ; 0) ; 2 ) ] Loop Set Field [ mark; 1 ] Exit Loop If [ Get ( RecordNumber ) > Get ( FoundCount ) - 2 ] Go to record [ Get ( RecordNumber ) + 2 ] End Loop Go To Record[$recNum] Edited July 29, 2007 by Guest Link to comment Share on other sites More sharing options...
ghengis Posted July 29, 2007 Author Share Posted July 29, 2007 Thanks for your help. I will see if this works. Link to comment Share on other sites More sharing options...
ghengis Posted July 29, 2007 Author Share Posted July 29, 2007 Thats great it works!! Easy when you know how. I still don't understand everything you did. I have alot to learn. What about if I wanted to mark every 7th record? Once again thank you Link to comment Share on other sites More sharing options...
Genx Posted July 29, 2007 Share Posted July 29, 2007 Freeze Window Set Variable [ $recNum ; Get(RecordNumber) ] Set Variable [ $recInterval ; 7 ] Go to Record [ 1 + Mod( Round( Random * 10 ; 0) ; 2 ) ] Loop Set Field [ mark; 1 ] Exit Loop If [ Get ( RecordNumber ) > Get ( FoundCount ) - $recInterval ] Go to record [ Get ( RecordNumber ) + $recInterval ] End Loop Go To Record[$recNum] Link to comment Share on other sites More sharing options...
mr_vodka Posted July 29, 2007 Share Posted July 29, 2007 The position on the couch should have no barring on the quality of the post, maybe on the length of it........zzzzzzzzzzzzzzzzzz Sure it does. It makes me reverse the operator sign. ;) Link to comment Share on other sites More sharing options...
Recommended Posts
This topic is 6109 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