Thursday, June 5, 2008

Select A Process

QUEST has a pretty powerful construct that I haven't really seen in any other simulation packages: processes. A process is a data structure in QUEST that holds pretty much all the information you need to run a process in a simulation.

SCL exposes a lot of the information in a process, which you can see in the SCL documentation. However, selecting a process interactively in SCL is not built in (as far as I can tell). So here's a routine for selecting a process in a QUEST model.

routine select_a_process() : Process
Const
max_process 200
Var
result , the_process : Process
num_processes_found , pick_process , list_picked : Integer
the_processes : Array[ max_process ] of String
Begin

num_processes_found = 0
the_process = first_process
while( the_process <> NULL and num_processes_found < max_process ) do
the_processes[ num_processes_found ] = the_process->name
num_processes_found = num_processes_found + 1
the_process = the_process->next
endwhile
list_picked = item_pop_up( 'Select a process' , the_processes , pick_process )
return get_process( the_processes[ pick_process ] )
End


Basically the macro traverses the QUEST model's linked list of processes and adds them to an array. Then we use the item_pop_up routine to select a process from a list generated by our array. The item_pop_up returns the index of the selected process in the array, and we return that process pointer. You can use this routine to select a process that you want to act on in a SCL macro.

No comments: