I'm not a big proponent of modifying multiple documents to change their order in a view, as it raises the likelihood of replication/save conflicts if there are multiple simultaneous users of the database or if there's a single user who likes to work on multiple documents simultaneously.
However, if you want to do it, assuming the priorities are already unique and sequential, the easiest way is probably to create a view action button with the following formula:
current_priority := Priority; REM {or whatever the fieldname is if not Priority};
priority_all := @DbColumn("":"NoCache"; ""; @Subset(@ViewTitle; -1); 1);
REM {above assumes the column with the priority number is number 1};
priority_choices := @Trim(@Replace(@Text(priority_all); @Text
(current_priority); ""));
new_priority := @Prompt([OkCancelList]; "Reprioritize"; "Select new priority
for this document. NOTE: make sure none of these documents is open in another
window."; ""; priority_choices);
ENVIRONMENT param1 := @Text(current_priority) + ":" + new_priority;
@Command
([ToolsRunMacro]; "(Adjust Priorities)")
Then create an agent named "(Adjust Priorities)" that runs on all documents in
view. Here's the formula for that agent:
oldPri := @TextToNumber(@Left(@Environment("param1"); ":"));
newPri := @TextToNumber(@Right(@Environment("param1"); ":"));
min := @Min(oldPri; newPri);
max := @Max(oldPri; newPri);
SELECT Priority >= min & Priority <= max;
FIELD Priority :=
@If(Priority = oldPri;
newPri;
Priority > oldPri;
Priority - 1;
Priority + 1
) This was first published in June 2003