REM > BootEditCode:DragEnd

DEF FNDragEnd
LOCAL List%, YPos%, Item%, File$, In%, Out%, Line$, Move%, Pos%, Done%

List% = FNHeap_Find(0, "BootList")
IF !List% = 0 THEN =0

SYS"Wimp_GetPointerInfo",, B%

 IF B%!12 = FNObject_Hand(0, "BootPane", 0) THEN

  IF (Boot_Editing% = 2) OR (Boot_Editing% = 4) THEN VDU7: =0
  IF Boot_Editing% = 1 THEN File$ = "PreDesktop" ELSE File$ = "Desktop"

  SYS"Wimp_GetWindowState",, B% + 12
  YPos% = (-(B%!04 + (B%!36 - B%!28)) / List_High%) + 0.5

  In% = OPENIN(Boot_Path$ + ".Choices.Boot." + File$)
  Out% = OPENOUT("<Wimp$ScrapDir>.BootEdit")

   FOR Item% = 1 TO !List%

     IF Item% - 1 = YPos% THEN
      Pos% = PTR#In%
      PTR#In% = 0

       FOR Move% = 1 TO !List%

         REPEAT
          Line$ = GET$#In%
         UNTIL LEFT$(Line$, 6) = "|Start"

         IF !(List% + 4 + 80 * (Move% - 1) + 00) AND 1 THEN
          BPUT#Out%, Line$
           REPEAT
            Line$ = GET$#In%
            BPUT#Out%, Line$
           UNTIL Line$ = "|End"
         ENDIF

       NEXT

      Done% = TRUE

      PTR#In% = Pos%
     ENDIF

     REPEAT
      Line$ = GET$#In%
     UNTIL LEFT$(Line$, 6) = "|Start"

     IF (!(List% + 4 + 80 * (Item% - 1) + 00) AND 1) = 0 THEN
      BPUT#Out%, Line$
       REPEAT
        Line$ = GET$#In%
        BPUT#Out%, Line$
       UNTIL Line$ = "|End"
     ENDIF

   NEXT

   IF NOT Done% THEN
    PTR#In% = 0

     FOR Move% = 1 TO !List%

       REPEAT
        Line$ = GET$#In%
       UNTIL LEFT$(Line$, 6) = "|Start"

       IF !(List% + 4 + 80 * (Move% - 1) + 00) AND 1 THEN
        BPUT#Out%, Line$
         REPEAT
          Line$ = GET$#In%
          BPUT#Out%, Line$
         UNTIL Line$ = "|End"
       ENDIF

     NEXT

   ENDIF

  CLOSE#In%
  CLOSE#Out%

  OSCLI"Copy <Wimp$ScrapDir>.BootEdit " + Boot_Path$ + ".Choices.Boot." + File$ + " ~CDFL~V"
   IF File$ = "PreDesktop" THEN
    OSCLI"SetType " + Boot_Path$ + ".Choices.Boot." + File$ + " FEB"
   ELSE
    OSCLI"SetType " + Boot_Path$ + ".Choices.Boot." + File$ + " FEA"
   ENDIF

  PROCBoot_Scan

 ELSE

  VDU 7

 ENDIF

=0
