with String_Utilities;
with Work_Order_Implementation;
with Form;
with Work_Order;
with Direct_Io;
with Window_Io;
separate (Cm_Generic)
procedure Create_Work_Order (Title : String := ">>NOTES<<") is
    package Dio is new Direct_Io (Integer);
    package Woi renames Work_Order_Implementation;
    use Woi;
    Work_Number : Natural;
    Wo_Index    : constant String := Work_Order_Path & ".wo_index";

    Order_Id : Woi.Work_Order_Id;
    Status   : Woi.Status;

    Spr_Handle : Dio.File_Type;
begin

    Dio.Open (File => Spr_Handle,
              Mode => Dio.Inout_File,
              Name => Wo_Index,
              Form => "");

    Dio.Read (File => Spr_Handle, Item => Work_Number, From => 1);
    Work_Number := Work_Number + 1;

    declare
        Work_Order_Name : constant String :=
           Work_Order_Path & ".wo_" &
              String_Utilities.Strip
                 (String_Utilities.Number_To_String (Work_Number));
    begin


        Work_Order.Create (Order_Name => Work_Order_Name,
                           Notes      => Title,
                           On_List    => Task_List,
                           On_Venture => Venture_Path);

        Work_Order_Control.Find (Work_Order_Name, Order_Id, Success => Status);
        if Status = 0 then
            Dio.Write (Spr_Handle, Work_Number, To => 1);
        end if;
    end;  
    Dio.Close (Spr_Handle);
end Create_Work_Order;