Load script question

I have a script made of multiple records (kind of a database script) which returns the records on run. I’m loading that script into my main script and everything works fine when running my main script from Script Editor. But as soon as I save my main script as run-only applet, it will run as expected except for that error message it throws me at the end “Could not save changes to this script because of a scripting system (OSA) error. -2707” I’m new to the load script concept. Also if someone could suggest me a better sorting algorythm (maybe shell script based) the one I’m using is pretty slow for my 400+ records that will eventually exceed 1000. Thank you guys. Here’s my main script code:

set script_path to ((path to desktop as string) & “Script compilés 4 mars 2009:base de donnee journaux.scpt”)
set my_script_variablelibrary to load script file script_path
tell my_script_variablelibrary to run

set nom_journaux to {}
repeat with this_item in all_journaux
set nom_journaux to nom_journaux & (get nom of this_item)
end repeat

–sorting routine
set the index_list to {}
set the sorted_list to {}
set jobcount to count every item in nom_journaux
repeat jobcount times
set the low_item to “”
repeat with i from 1 to jobcount
if i is not in the index_list then
set this_item to item i of nom_journaux as text
if the low_item is “” then
set the low_item to this_item
set the low_item_index to i
else if this_item comes before the low_item then
set the low_item to this_item
set the low_item_index to i
end if
end if
end repeat
set the end of sorted_list to the low_item
set the end of the index_list to the low_item_index
end repeat
set nom_journaux to sorted_list
–end of sorting routine

set journal_choisi to (choose from list nom_journaux) as string

repeat with this_item in all_journaux
if this_item contains {nom:journal_choisi} then set this_paper to this_item
end repeat
set province to province of this_paper
set langue to langue of this_paper
set contact to contact of this_paper
set nombre_de_colonnes to nombre_de_colonnes of this_paper
set nombre_de_lignes to nombre_de_lignes of this_paper
set liste_des_colonnes to liste_des_colonnes of this_paper
set representant to representant of this_paper
set dialogue_information to "Journal choisi: " & journal_choisi & return & "Province: " & province & return & "Contact: " & contact & return & "Langue: " & langue & return & "Représentant: " & representant & return & "Nombre de colonnes maximum: " & nombre_de_colonnes & return & "Nombre de lignes maximum: " & nombre_de_lignes
display dialog "Date de mise à jour: " & date_modif & return & return & dialogue_information & return & return & "Nombre de journaux dans la liste: " & i

I can’t answer your external script problem, but the best sorting routine I’ve ever used is one by Nigel Garvey & Arthur Knapp in Code Exchange.

Will have a look at it. Thank you Adam.

Did another test, if I place my main script instructions inside my database-records script (without the load script-run script instructions of course) and save as run-only applet, I don’t get that error anymore…

I’ve encountered ‘load script’ problems with run-only scripts, but in the sense of loading a run-only script into a script running in Script Editor while looking at the event log (typically shows the script code as it runs, and if the loaded script is run-only it throws an error to prevent revealing what was saved to be unrevealing). This might be the same thing.

I’ve had better luck with a ‘load script’ script events or properties when used directly, rather than running the whole script after it’s loaded into another script; ie; if the script of records is this:

--records stored or formed in the 'base de donnee journaux.scpt' script to be loaded
property record1 : {aKey:"0", aValue:"something"}
property record2 : {aKey:"1", aValue:"something else"}

on getRecords()
	set listOfRecords to {}
	copy record1 to end of listOfRecords
	copy record2 to end of listOfRecords
	return listOfRecords
end getRecords

Then I can load that script into another and use it’s handlers or it’s properties directly, thus:

set script_path to ((path to desktop as string) & "Script compilés 4 mars 2009:base de donnee journaux.scpt")
set my_script_variablelibrary to load script file script_path
set listOfRecords to my_script_variablelibrary's getRecords()
set aRecord to my_script_variablelibrary's record1

In your script it may have to do with running the ‘base de donnee journaux.scpt’ instead of just using (loading) it, and any properties or values the run-only script tries to save when it’s run can neither be read nor written.