REM > JLibraries:Wimp.6
REM © James Bursa, 1997

REM JB  17 Nov 1997     created
REM JB  27 Nov 1997     PROCWimp_StartDrag now supports text/sprite icons
REM JB  28 Nov 1997     removed PROCWimp_ReadMessages
REM JB  06 Dec 1997     works with Mess.2
REM JB  13 Dec 1997     PROCWimp_LoadFile: OS_File 17 -> OS_File 23
REM JB  27 Dec 1997     fixed 'Unknown territory number' bug


DEF PROCWimp_Init
LOCAL Size%, Numb%, PFlg%

DIM B% 511

SYS"Wimp_Initialise", 310, &4B534154, Task_Name$, 0 TO , Task_Hand%
SYS"WimpExt_Initialise", 16, Task_Hand%, %11100011000
PROCHeap_Init(50)

SYS"OS_ReadVarVal", Task_Name$ + "$Dir", B%, 512 TO ,, Size%
B%?Size%   = 13
Task_Path$ = $B% + "."
Task_Res1$ = Task_Path$ + "Resources."

SYS"XOS_ReadVarVal", Task_Name$ + "$Language",, -1 TO ,, Size%
 IF Size% = 0 THEN
  SYS"Territory_Number" TO Numb%
  SYS"XTerritory_NumberToName", Numb%, B%, 512 TO ;PFlg%
   IF (PFlg% AND 1) THEN
    Task_Res2$ = Task_Res1$ + "UK."
   ELSE
    Task_Res2$ = Task_Res1$ + FNWimp_GetString(B%) + "."
   ENDIF
 ELSE
  SYS"OS_ReadVarVal", Task_Name$ + "$Language", B%, 512 TO ,, Size%
  B%?Size%   = 13
  Task_Res2$ = Task_Res1$ + $B% + "."
 ENDIF
IF NOT FNWimp_FileExists(LEFT$(Task_Res2$)) THEN Task_Res2$ = Task_Res1$ + "UK."

Erro_Info% = &F0000
Erro_Warn% = &F0000 + 1
Erro_Ques% = &F0000 + 2
Erro_Memo% = &F0000 + 3
Erro_ERR%  = -1
PROCObject_Init
File_Mess% = FNMess_Open(Task_Res2$ + "Messages", FALSE)
File_Help% = FNMess_Open(Task_Res2$ + "Help"    , FALSE)
Erro_Erro$ = FNMess_Lookup("Erro_Erro", File_Mess%)
Erro_Quit$ = FNMess_Lookup("Erro_Quit", File_Mess%)
Erro_Memo$ = FNMess_Lookup("Erro_Memo", File_Mess%)
Task_PollMask% = &1831
Task_PollIdle% = 0
Task_LastPoll% = 0
Task_LastTemp% = 0
Task_Quit% = FALSE
Task_Slab% = FALSE
Menu_Open% = FALSE
Menu_Fast% = FALSE
ENDPROC

REM ˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜

DEF FNWimp_IconBarIcon(Sprt$, SLen%, Text$, TLen%, Side%)
LOCAL Vali%, Text%, Hand%

DIM Vali% SLen% + 1
DIM Text% TLen% + 1
$Vali% = "S" + Sprt$
$Text% = Text$

B%!400 = Side%
B%!404 = -(10 * TLen% - 4)
B%!408 = -16
B%!412 = 68 + (10 * TLen% - 4)
B%!416 = 80
B%!420 = &1700310B
B%!424 = Text%
B%!428 = Vali%
B%!432 = TLen%
SYS"Wimp_CreateIcon",, B% + 400 TO Hand%
=Hand%

REM ˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜

DEF FNWimp_IconBarSprite(Sprt$, SLen%, Area%, Side%, Size%)
LOCAL Sprt%, Hand%

DIM Sprt% SLen%
$Sprt% = Sprt$

B%!400 = Side%
B%!404 = 68 - Size%
B%!408 = 68 - Size%
B%!412 = 68 + (Size% - 68)
B%!416 = 68 + (Size% - 68)
B%!420 = &1700311A
B%!424 = Sprt%
B%!428 = Area%
B%!432 = SLen%
SYS"Wimp_CreateIcon",, B% + 400 TO Hand%
=Hand%

REM ˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜

DEF PROCWimp_Poll
LOCAL Reas%, Temp%, Call$, Menu$, Time%, More%, Loop%, Key$, Temp$

SYS"WimpExt_PrePoll"
 IF Task_PollIdle% THEN
  SYS"OS_ReadMonotonicTime" TO Time%
   WHILE (Time% - Task_LastPoll%) > 0
    Task_LastPoll% += Task_PollIdle%
   ENDWHILE
  SYS"Wimp_PollIdle", Task_PollMask%, B%, Task_LastPoll% TO Reas%
 ELSE
  SYS"Wimp_Poll", Task_PollMask%, B% TO Reas%
 ENDIF
SYS"WimpExt_Action", Task_Hand%, B%, Reas% TO Reas%
SYS"Hourglass_On"

@% = "+g10.9"

 CASE Reas% OF
  WHEN  0: Call$ = "NullEvent"
  WHEN  1: Call$ = "Redraw_"+FNObject_Name(0, !B%, 0)
  WHEN  2: Call$ = "Open_"+FNObject_Name(0, !B%, 0)
  WHEN  3: Call$ = "Close_"+FNObject_Name(0, !B%, 0)
  WHEN  4: Call$ = "Leave_"+FNObject_Name(0, !B%, 0)
  WHEN  5: Call$ = "Enter_"+FNObject_Name(0, !B%, 0)
  WHEN  6: X% = B%!0: Y% = B%!4: Z% = B%!8: W% = B%!12: I% = B%!16
            IF W% = -2 THEN
             Call$ = "Click_IBar_"+STR$Z%
            ELSE
             Call$ = "Click_"+FNObject_Name(0, W%, 0)+"_"+FNObject_Name(1, I%, W%)
            ENDIF
  WHEN  7: Call$ = "DragEnd"
  WHEN  8: W% = B%!0: I% = B%!4: K% = B%!24
           Call$ = "Key_"+FNObject_Name(0, W%, 0)+"_"+STR$~K%
  WHEN  9: Menu% = Menu_Current%
           Item% = B%!0
           Loop% = 4
            WHILE B%!Loop% <> -1
             Menu% = Menu%!(28 + 24 * Item% + 4)
             Item% = B%!Loop%
             Loop% += 4
            ENDWHILE
           Call$ = "Menu_"+FNObject_Name(2, Menu%, 0)+"_"+FNObject_Name(3, Item%, Menu%)
  WHEN 10: Call$ = "Scroll_"+FNObject_Name(0, !B%, 0)
  WHEN 11: Call$ = "LoseC_"+FNObject_Name(0, !B%, 0)
  WHEN 12: Call$ = "GainC_"+FNObject_Name(0, !B%, 0)
  WHEN 13: Call$ = "PollWord"
  WHEN 17: Call$ = "MessUser_"+STR$~(B%!16)
  WHEN 18: Call$ = "MessRec_"+STR$~(B%!16)
  WHEN 19: Call$ = "MessAck_"+STR$~(B%!16)
  OTHERWISE: Call$ = "PollReason_"+STR$~Reas%
 ENDCASE

 CASE Reas% OF
  WHEN  1: SYS"Wimp_RedrawWindow",,B% TO More%
           IF FNWimp_Do(Call$+"_Pre")
            WHILE More%
             IF FNWimp_Do(Call$)
             SYS"Wimp_GetRectangle",,B% TO More%
            ENDWHILE
           IF FNWimp_Do(Call$+"_Post")
  WHEN  2: IF NOT FNWimp_Do(Call$) THEN SYS"WimpExt_OpenLinked",,B%
  WHEN  3: IF NOT FNWimp_Do(Call$) THEN SYS"WimpExt_CloseLinked",,B%
  WHEN  6: IF W% <> -2 THEN IF FNWimp_Do("Click_"+FNObject_Name(0, W%, 0))
           IF FNWimp_Do(Call$)
           IF Task_Slab% THEN SYS"WimpExt_SetIcon",,, Slab_Wind%, Slab_Icon%, 0: Task_Slab% = FALSE
  WHEN  7: IF NOT FNWimp_Do(Call$) THEN SYS"XDragASprite_Stop"
  WHEN  8: Key$ = FNMess_XLookup(Call$, File_Mess%)
            IF Key$ = "" THEN
             IF (FNWimp_Do("Key_"+FNObject_Name(0, W%, 0))=0 AND FNWimp_Do(Call$)=0) THEN SYS"Wimp_ProcessKey",B%!24
            ELSE
              IF Key$ = "+Help" THEN
               PROCWimp_SupplyHelp
              ELSE
               I% = FNObject_Hand(1, Key$, W%)
               B%!08 = 4
               B%!12 = W%
               B%!16 = I%
               Task_Slab% = FALSE
               SYS"Wimp_GetIconState",, B% + 12
REM             IF NOT shaded AND NOT deleted
                IF (B%!36 AND (%11<<22)) = 0 THEN
REM               IF ESG = 0
                  IF ((B%!36 AND (%11111<<16)) = 0) THEN
REM                 IF ButtonType = Radio
                    IF (((B%!36 AND (%1111<<12))>>12) = 11) THEN
                     SYS"WimpExt_SetIcon",,, W%, I%, 1 - ((B%!36 AND (1<<21))>>21)
                    ENDIF
REM                 IF ButtonType = Click once AND indirected AND bordered AND text
                    IF (((B%!36 AND (%1111<<12))>>12) = 3) AND ((B%!36 AND (%100000101)) <> 0) THEN
                     Temp$ = FNWimp_GetString(B%!44)
REM                   IF button is 3d action
                      IF INSTR(Temp$, "r5") OR INSTR(Temp$, "R5") OR INSTR(Temp$, "r6") OR INSTR(Temp$, "R6") THEN
                       SYS"WimpExt_SetIcon",,, W%, I%, 1
                       Task_Slab% = TRUE
                       Slab_Wind% = W%
                       Slab_Icon% = I%
                      ENDIF
                    ENDIF
                  ELSE
                   SYS"WimpExt_SetIcon",,, W%, I%, 1
                  ENDIF
                 SYS"Wimp_SendMessage", 6, B%, Task_Hand%
                ENDIF
              ENDIF
            ENDIF
  WHEN  9: IF (FNWimp_Do("Menu_"+FNObject_Name(2, Menu_Current%, 0))=0 AND FNWimp_Do(Call$)=0) THEN PROCMenu_Adjust(Menu_Current$)
  WHEN 17, 18:
            CASE B%!16 OF
             WHEN     &0: IF NOT FNWimp_Do(Call$) THEN Task_Quit% = TRUE
             WHEN   &502: IF NOT FNWimp_Do(Call$) THEN PROCWimp_SendHelp
             OTHERWISE  : IF FNWimp_Do(Call$)
            ENDCASE
  OTHERWISE: IF FNWimp_Do(Call$)
 ENDCASE

SYS"Hourglass_Smash"
ENDPROC

REM ˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜

DEF FNWimp_Do(Func$)
LOCAL ERROR
ON ERROR LOCAL RESTORE ERROR: =FNWimp_DoError
=EVAL("FN" + Func$)

REM ˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜

DEF FNWimp_DoError
IF Task_Slab% THEN SYS"WimpExt_SetIcon",,, Slab_Wind%, Slab_Icon%, 0: Task_Slab% = FALSE
IF (ERR = 29) AND (Erro_ERR% = -1) THEN =FALSE
 IF Erro_ERR% = -1 THEN
  Erro_ERL%    = ERL
  Erro_REPORT$ = REPORT$
  Erro_ERR%    = ERR
 ENDIF
ERROR ERR, REPORT$
=FALSE

REM ˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜

DEF PROCWimp_Close
SYS"WimpExt_CloseDown", Task_Hand%
SYS"Wimp_CloseDown", Task_Hand%, &4B534154
SYS"XOS_CLI", "Unset " + Task_Name$ + "$Objects"
ENDPROC

REM ˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜

DEF FNWimp_Error
LOCAL Quit%, Text$
LOCAL ERROR
ON ERROR LOCAL ON ERROR OFF: ERROR EXT 0, (REPORT$+" in Error Handler (Code "+STR$ERL+"); must exit.")

SYS"Hourglass_Smash"

 IF Erro_ERR% = -1 THEN
  Erro_ERR%    = ERR
  Erro_ERL%    = ERL
  Erro_REPORT$ = REPORT$
 ENDIF

 CASE Erro_ERR% OF

  WHEN Erro_Memo%
   Quit% = FNWimp_ReportError(Erro_Memo$, Erro_Warn%)

  WHEN Erro_Info%, Erro_Warn%
    IF LEFT$(Erro_REPORT$, 1) = "%" THEN
     Erro_REPORT$ = FNMess_Lookup(MID$(Erro_REPORT$, 2), File_Mess%)
    ENDIF
   Quit% = FNWimp_ReportError(Erro_REPORT$, Erro_ERR%)

  OTHERWISE
   @% = "+g20.20"
   SYS"WimpExt_SubstituteArgs", Erro_Erro$, B%, Erro_REPORT$, STR$Erro_ERL%, STR$~Erro_ERR%, 0, 0 TO ,Text$
   Quit% = FNWimp_ReportError(Text$, 1)
   IF Quit% THEN Quit% = FNWimp_ReportError(Erro_Quit$, Erro_Ques%)

 ENDCASE

Erro_ERR% = -1

=Quit%

REM ˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜

DEF FNWimp_ReportError(Text$, Type%)
LOCAL Flag%, Clck%

B%!00 = 1
$(B% + 04) = Text$

 CASE Type% OF
  WHEN Erro_Info%: Flag% = %001100000001
  WHEN Erro_Warn%: Flag% = %010100000001
  WHEN Erro_Ques%: Flag% = %100100000011
  OTHERWISE      : Flag% = %000100000011
 ENDCASE

SYS"Wimp_ReportError", B%, Flag%, Task_Name$ TO ,Clck%
=(Clck% = 2)

REM ˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜

DEF FNWimp_GetString(Addr%)
LOCAL Text$, a%
 WHILE Addr%?a% > 31
  Text$ += CHR$(Addr%?a%)
  a% += 1
 ENDWHILE
=Text$

REM ˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜

DEF PROCWimp_ScreenSize(RETURN Wide%, RETURN High%)
LOCAL a%, b%

B%!400 = 130
B%!404 = 131
B%!408 = -1
SYS"OS_ReadVduVariables", B% + 400, B% + 400
SYS"OS_ReadModeVariable", -1, 4 TO ,, a%
SYS"OS_ReadModeVariable", -1, 5 TO ,, b%
Wide% = ((B%!400) + 1) * 2 ^ a%
High% = ((B%!404) + 1) * 2 ^ b%

ENDPROC

REM ˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜

DEF PROCWimp_StartDrag
LOCAL Sprt$, Temp%

B%!00 = W%
B%!04 = I%
SYS"Wimp_GetIconState",, B%
 IF (B%!24 AND %10) THEN
   CASE (B%!24 AND 1) + ((B%!24 AND 1<<8)>>7) OF
    REM   IT
    WHEN %00, %01: SYS"WimpExt_DragIcon", %100000101, 1, W%, I%, B% + 28
    WHEN %10: SYS"WimpExt_DragIcon", %100000101, 1, W%, I%, B%!28
    WHEN %11
     Vali$ = FNWimp_GetString(B%!32)
      IF (LEFT$(Vali$, 1) = "s") OR (LEFT$(Vali$, 1) = "S") THEN
       Sprt$ = MID$(Vali$, 2)
      ELSE
       Temp% = INSTR(Vali$, ";s")
       IF Temp% = 0 THEN Temp% = INSTR(Vali$, ";S")
       Sprt$ = MID$(Vali$, Temp% + 2)
      ENDIF
     IF INSTR(Sprt$, ";") THEN Sprt$ = LEFT$(Sprt$, INSTR(Sprt$, ";") - 1)
     SYS"WimpExt_DragIcon", %100000101, 1, W%, I%, Sprt$
   ENDCASE
 ELSE
  SYS"WimpExt_DragIcon", %101, 0, W%, I%
 ENDIF
ENDPROC


 CASE
  SYS"WimpExt_DragIcon", %100000101, 1, W%, I%, B%!28
 ELSE
  SYS"WimpExt_DragIcon", %100000101, 1, W%, I%, B%+28
 ENDIF
ENDPROC

REM ˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜

DEF FNWimp_GetLeaf(Text$)
IF INSTR(Text$, ".") = 0 THEN =Text$
 WHILE INSTR(Text$, ".")
  Text$ = MID$(Text$, INSTR(Text$, ".") + 1)
 ENDWHILE
=Text$

REM ˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜

DEF PROCWimp_SendHelp
LOCAL Buff%, Help%, Obje$, Mess$, Temp%, Menu%, Item%

 IF B%!32 = -2 THEN
  Mess$ = "IBar"
  Help% = FNWimp_Do("Help_"+Mess$)
  IF Help% = 0 THEN Help% = FNMess_XAdr(Mess$, File_Help%)

 ELSE
   Obje$ = FNObject_Name(0, B%!32, 0)

   IF Obje$ = "None" THEN
    SYS"Wimp_GetMenuState", 0, B% + 80
    Menu% = Menu_Current%
    Item% = B%!80
    Loop% = 84
     WHILE B%!Loop% <> -1
      Menu% = Menu%!(28 + 24 * Item% + 4)
      Item% = B%!Loop%
      Loop% += 4
     ENDWHILE
    Mess$ = "Menu_"+FNObject_Name(2, Menu%, 0)+"_"+FNObject_Name(3, Item%, Menu%)
    Help% = FNWimp_Do("Help_"+Mess$)
    IF Help% = 0 THEN Help% = FNMess_XAdr(Mess$, File_Help%)
    Mess$ = "Menu_"+FNObject_Name(2, Menu%, 0)
    IF Help% = 0 THEN Help% = FNWimp_Do("Help_"+Mess$)
    IF Help% = 0 THEN Help% = FNMess_XAdr(Mess$, File_Help%)
    Mess$ = "Menu_"+FNObject_Name(2, Menu_Current%, 0)
    IF Help% = 0 THEN Help% = FNWimp_Do("Help_"+Mess$)
    IF Help% = 0 THEN Help% = FNMess_XAdr(Mess$, File_Help%)

   ELSE
    Mess$ = "Wind_"+Obje$+"_"+FNObject_Name(1, B%!36, B%!32)
    Help% = FNWimp_Do("Help_"+Mess$)
    IF Help% = 0 THEN Help% = FNMess_XAdr(Mess$, File_Help%)
    Mess$ = "Wind_"+Obje$
    IF Help% = 0 THEN Help% = FNWimp_Do("Help_"+Mess$)
    IF Help% = 0 THEN Help% = FNMess_XAdr(Mess$, File_Help%)
   ENDIF
 ENDIF

IF Help% = 0 THEN Help% = FNMess_XAdr("Default", File_Help%)
SYS"WimpExt_SendHelp", Help%, B%

ENDPROC

REM ˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜

DEF PROCWimp_LoadFile(File$, Word%, Name$)
LOCAL File%, Type%, Siz1%, Siz2%, Siz3%, Sqsh%, Work%

SYS"OS_File", 23, File$ TO File%,,,, Siz1%,, Type%
IF File% = 0  THEN ERROR Erro_Warn%, FNMess_Global1("NoFile", File$)
IF File% <> 1 THEN ERROR Erro_Warn%, FNMess_Global1("IsntFil", File$)

 CASE Type% OF
  WHEN &FCA
   IF NOT FNHeap_Grab(Siz1%, Word%, "_Sqsh") THEN ERROR Erro_Memo%, "NoMem"
   Sqsh% = FNHeap_Find(Word%, "_Sqsh")
   SYS"OS_File", 16, File$, Sqsh%
   Siz2% = Sqsh%!04
  OTHERWISE
   Siz2% = Siz1%
 ENDCASE

IF NOT FNHeap_Grab(Siz2% + 4, Word%, Name$) THEN ERROR Erro_Memo%, "NoMem"
File% = FNHeap_Find(Word%, Name$)

 CASE Type% OF
  WHEN &FCA
   SYS"Squash_Decompress", %1000, Siz2% TO Siz3%
   IF NOT FNHeap_Grab(Siz3%, Word%, "Work") THEN ERROR Erro_Memo%, "NoMem"
   Work% = FNHeap_Find(Word%, "Work")
   SYS"Squash_Decompress", %100, Work%, Sqsh% + 20, Siz1% - 20, File% + 4, Siz2%
   PROCHeap_Lose(Word%, "_Sqsh")
   PROCHeap_Lose(Word%, "Work")
  OTHERWISE
   SYS"OS_File", 16, File$, File% + 4
 ENDCASE
File%!00 = Siz2%

SYS"WimpExt_Heap", 6
ENDPROC

REM ˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜

DEF PROCWimp_SaveFile(File$, Word%, Name$, Type%)
LOCAL File%
File% = FNHeap_Find(Word%, Name$)
SYS"OS_File", 10, File$, Type%,, File% + 4, File% + 4 + !File%
ENDPROC

REM ˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜

DEF PROCWimp_SupplyHelp
SYS"Wimp_StartTask", "Filer_Run Resources:$.Apps.!Help"
ENDPROC

REM ˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜

DEF FNWimp_TempFile
@% = "+g10.10"
Task_LastTemp% = TIME
=Task_Temp$+STR$TIME

REM ˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜

DEF FNWimp_FileExists(Path$)
LOCAL Found%
SYS"OS_File", 17, Path$ TO Found%
=(Found% <> 0)

REM ˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜

DEF PROCWimp_IBoxVers
LOCAL File_Vers%

SYS"OS_File", 23, Task_Path$ + "!RunImage" TO ,, B%!04, B%!00
SYS"Territory_ConvertDateAndTime", -1, B%, B% + 08, 503, FNMess_Lookup("IBox_Date", File_Mess%) + CHR$0

PROCWimp_LoadFile(Task_Path$ + "!Version", -1, "_Vers")
File_Vers% = 4 + FNHeap_Find(-1, "_Vers")
@% = "+f20.2"

PROCWind_SetText("IBox", "Vers", FNMess_Get2("IBox_Vers", File_Mess%, STR$(File_Vers%!00 / 100), FNWimp_GetString(B% + 08)))

PROCHeap_Lose(-1, "_Vers")
ENDPROC