Unanswered: Script freezes during normal activation but not when debugging
I am experiencing a really strange behavior. I have a script that is activated via a button. I have records for 36 individuals and can run this report for each person when I select their record and press the button. Most of the time, the script executes perfectly; however, there are occasions when the script runs and it freezes up Brilliant Database and this is AFTER the script is complete. It does this only for certain individuals and it always freezes for these same people. When I select an individual where it has been freezing up on and debug the script manually through each line of script and it does not freeze anything... it just does it when I activate it normally through clicking on the button.
I have spent hours last night and today examining the records and everything is intact but I cannot find why Brilliant Database freezes during normal script execution and NOT when stepping through the script line by line. Has anyone else experienced this sort of odd behavior?
More details... If I place a 'Show Message' command at the end of each loop it works right EVERY time even on those individuals that caused the program to freeze earlier. I am not understanding why the program is behaving so oddly. Currently, there are about 12 'For Each... Next' loops so having to acknowledge the message each time is not a realistic solution (nor is stepping through the script one line at a time) but that is the only way that Brilliant Database does not freeze up. This is a peculiar issue and I undoubtedly am not the first to encounter this (I hope!). Has this happened to any of you BD professionals?
Can't actually help but if no one has an answer you could post a copy of your file with script if contents not too sensitive. An email attachment to selected members can be an alternative if no progress.
Sounds like a timing issue (bug?) but only guessing - wondering if a delaying action that really does nothing might help (something like refresh field or select same current folder as experiment).
James and David,
I tried delaying the timing using James' suggestion yet it still freezes (see attached screenshot). During normal execution the folders turn gray for a couple seconds; however, when it freezes the folders remain gray and there is no control over the program - see blue arrow on screenshot. At that point I have to do a Ctrl+Alt+Delete to close Brilliant Database.
Another odd this is that elsewhere in the program I have the exact same function but it looks at everyone (36 doctors) and it ALWAYS works flawlessly... and the script is identical - exactly identical. The only different is that the Recordset variable has only one name on the screen that freezes whereas the Recordset variable for the other function can have the full 36 doctors. That variable is global and is defined outside the script. I am truly at a loss as to what is making it freeze... it always freezes on the same people but not every time it is run on those individuals.
i had buggie behaibor in old versions of brilliant.
1. check if you can update to the news brilliant version
2. try to delete the record had gives you problems, run your script to see if without the record it stills frezes, if it does not frezes then try to enter again manually the information of the deleted record.
3. check if in some point of your script you are using the function "Close window" (i got some issues with this function in older versions, when i stoped using the window stuff the scripts worked)
4. check if you are using the "change folder" function, try not to use it, or on the other hand, include it inside your loop, when you see that the loop fails, use the change folder function (go to a folder and then get back to your working folder)
(i have had this sort of behaivor in brilliant and it is a pain in the "#$ i tottaly understand your situation)
In trying to pinpoint exactly what is happening, I wrote a query to pull up all the records of one of the doctors where the program seizes. Next, I added a step to the query to change the doctor's name from the original (whose name caused the program to freeze) to another doctor's name as to see if the data itself caused the freezing. After doing this, I re-ran the script and it worked without an issue so this should confirm that the issue does not lie within the data.
I have deleted the data and re-entered it and it still freezes. I have not used the 'Close window' nor the 'change folder' commands. I have deleted the 'problem' doctors out and added their data back and it still freezes up Brilliant Database. I will try updating to V10.54 to see if that helps (as I do not know what else to check...).
The script actually completes running and provides the exact answers - yet it freezes then and locks up Brilliant Database. I am dumbfounded!!!
Update: On a whim, I tried to test out another avenue. I pulled up my same query that I mentioned and changed the name back to the original doctor (this is the one that caused the freezing) and it ran perfectly. Something is definitely unstable though I cannot figure out where or what is causing the freezing issue.
Last edited by fireant911; 06-25-14 at 16:16.
Reason: added update with testing results
The code for your button “Calculate Objectives Completed” seems to have some issues.
Take line 16 for example. Your pushing a list of all the “Completed Activities” for the selected person into a variable called $completed_activities. This is never going to work as a variable has a limited amount of memory.
Viewed alphabetically the first person in your “Completed Activities” folder already has 1063 records that are all trying to be loaded into a single variable. Some people currently have much less records which is why your script is working for some, random for others and not at all for some people.
If you need to find records using a query and work with that list of records found, there is no need at all to use a “For each record” loop. A query has the ability all on it's own to process every record it finds without the need for any variables and is therefore able to work with an unlimited amount of records.
If you take a look at the query editor, on the Actions tab you will see a option to “execute as script for each record”. You need to work that function into your database instead of populating a variable with a query to ensure your database will work with an unlimited amount of records.
James may be on to something here with variables. A few weeks back I was experimenting and found when the items in a variable went past the 1000 or so mark the data seemed to be truncated.
I have no knowledge about the exact details about how many records the Recordset variable can or should hold but I do have a little experience. In my problem, some Recordset variables had well over 4,000 records and these work perfectly. The issue I was seeing was that problems arose when the person was selected that had the fewer records (the usage of 'fewer' is somewhat subjective as the least records I had was 1,016 and the most was 4,426). Those with less than 1,500 typically failed whereas the ones in excess of 2,500 seemed to always work. The process did not exactly 'fail'... it produced the correct answers but froze up Brilliant Database AFTER the solution was presented. I spent hours manually tabulating the results for both the smaller and larger volumes of records so I know that the results were right.
I will follow James' recommendation and reduce that volume of records that the Recordset is holding because that is just good advice (when James speaks, people listen!!! - I know that I do) and good programming practice. It is the absence of such information that creates these (potential) problems.
Your comment was spot on. There is really no source of information regarding such practices with Brilliant Database... except for this forum. I have never seen any reference to any of this in the User's Manual. I usually start out with some fake data, write some scripting and test it out, and, if it appears to work, I move on. Because data was not available when I started my project, I just made up records and it all worked great in this 'imaginary environment'. It was when I received the real data (just last week) did I discover that something was amiss. I, too, have learned a HUGE lesson with this... I must go now as I have a lot of scripting to redo!
Pat Phelan is one of the administrators here on dBforums and although he says that he is not savvy with Brilliant Database, he is quite active here.