home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 4 / DATAFILE_PDCD4.iso / utilities / utilsf / jfshared / Modules / TextCopy / Source111 < prev    next >
Encoding:
Text File  |  1995-08-20  |  18.0 KB  |  592 lines

  1. App  TextCopy
  2. In   -
  3. Out  TextCopy
  4. Type Module
  5. Ver  1.11b
  6.  
  7. Define Workspace
  8.  Name    DragBox
  9.  Default r9
  10.  Prefix  db_
  11.   `left        !    left of icon
  12.   `bottom      !    bottom of icon
  13.   `right       !    right of icon
  14.   `top         !    top of icon
  15.  Name    workspace
  16.  Default r12
  17.   `filehandle  !    handle of file to save to
  18.   `window      !    window being dragged to/from
  19.   `icon        !    icon being dragged to/from
  20.   `left        !    left of icon
  21.   `bottom      !    bottom of icon
  22.   `right       !    right of icon
  23.   `top         !    top of icon
  24.   `flags       !    icon flags
  25.   `str         !    string pointer
  26.   `valid       !    validation pointer
  27.   `length      !    length of string
  28.   `eventtype   !    Temporary store for event type
  29.   `saveaddr    !    Address of text to save out
  30.   `savelen     !    Length of text to save out
  31.   `dragbox     ^DragBox
  32.   `userblock   !    Pointer to users block
  33.   `ptrblock    !    Block for pointer information, and x co-ordinate of mouse
  34.   `mousey      !    y co-ordinate of mouse
  35.   `mouseb      !    button state of mouse
  36.   `mousew      !    window mouse is over
  37.   `mousei      !    icon mouse is over
  38.   `dragging    !    marker showing the current dragging state
  39. End Workspace
  40.  
  41. Define Module
  42.  Name    TextCopy
  43.  Help    Text Copy
  44.  Author  Justin Fletcher
  45.  Init    InitCode
  46.  Commands
  47.   Name   TextCopy
  48.   Help   ...
  49.     The TextCopy allows you to drag text files directly on to writable
  50.     icons. This is done by use of filters, so this may clash with
  51.     applications which process text files dragged onto writeable icons.
  52.     If multiple writable icons are present, then the text will span
  53.     these.|M
  54.     Holding down Shift when dragging will copy the filename into the icon.
  55.     |M|MDragging of writable icons is also possible for type 15 icons and
  56.     for all icons if the AllWCD module is present.|M|M
  57.     Holding down Ctrl when dragging will bypass the both patches.
  58.  End Commands
  59.  Workspace `len_workspace
  60.  PostFilter
  61.   Name   Text Copy
  62.   Code   filtercode
  63.   Task   -
  64.   Accept Null
  65.   Accept DragDropped
  66.   Accept MouseClick
  67.   Accept Message
  68.   Accept MessageRec
  69.   Accept MessageAck
  70.  End Filter
  71. End Module
  72.  
  73. # REM OFF
  74. .InitCode
  75.    STMFD  (sp)!,{r0,link}
  76.    MOV    r0,#0
  77.    STRW   r0,`dragging
  78.    LDMFD  (sp)!,{r0,pc}
  79.  
  80. .filtercode
  81.    STMFD   (sp)!,{r1-r2,link}
  82.    CMP     r0,#0
  83.    BEQ     checknullevent
  84.    CMP     r0,#6
  85.    BEQ     ismouseclick
  86.    CMP     r0,#7
  87.    BEQ     isdragdone
  88.    CMP     r0,#17
  89.    CMPNE   r0,#18
  90.    BEQ     ismessage
  91.    CMP     r0,#19
  92.    BEQ     ismessageack
  93.    LDMFD   (sp)!,{r1-r2,pc}
  94.  
  95. .ismessageack
  96.    STRW    r0,`eventtype
  97.    REM     "%c04%c30Acknowledged"
  98.    LDR     r2,[r1,#16]
  99.    CMP     r2,#1
  100.    BEQ     isNoDataSaveAck           ; Nobody loves me, so transfer dies…
  101.    B       exitevent
  102. .ismessage
  103.    STRW    r0,`eventtype
  104.    LDR     r2,[r1,#16]
  105.    REM     "%c04%c30Message %&2"
  106.    CMP     r2,#1
  107.    BEQ     isDataSave                ; Initial message, can I save to you ?
  108.    CMP     r2,#3
  109.    BEQ     isDataLoad                ; Please load this data from me…
  110.    CMP     r2,#2
  111.    BEQ     isDataSaveAck             ; I want your data, give it to me now…
  112. .exitevent
  113.    LDRW    r0,`eventtype
  114.    LDMFD   (sp)!,{r1-r2,pc}
  115.  
  116. .isDataSaveAck
  117.    LDRW    r0,`dragging
  118.    CMP     r0,#2
  119.    BNE     exitevent
  120.    REM     "Data save initiated..."
  121.    MOV     r0,#10
  122.    ADD     r1,r1,#44                     ; address in block of filename
  123.    REM     "File name to save as %$1"
  124.    LMOV    r2,#&FFF                      ; filetype
  125.    LDRW    r4,`saveaddr                  ; start address
  126.    LDRW    r5,`savelen                   ; length
  127.    ADD     r5,r5,r4                      ; end address
  128.    REM     "Save memory %&4 - %&5"
  129.    SWI     "OS_File"                     ; save file
  130.    SUB     r1,r1,#44                     ; restore block pointer
  131.    MOV     r0,#3                         ; acknowledge sending of data
  132.    STR     r0,[r1,#16]                   ; store in block
  133.    LDR     r0,[r1,#8]                    ; get their ref
  134.    STR     r0,[r1,#12]                   ; store in our ref to mark as reply
  135.    LDR     r2,[r1,#4]                    ; task to return to
  136.    MOV     r0,#17
  137.    SWI     "Wimp_SendMessage"            ; tell them...
  138.    MOV     r0,#0
  139.    STRW    r0,`dragging                  ; mark as not dragging
  140.    LDMFD   (sp)!,{r1-r2,pc}              ; Return from call
  141.  
  142. .isNoDataSaveAck
  143.    LDRW    r0,`dragging
  144.    CMP     r0,#2
  145.    BNE     exitevent
  146.    MOV     r0,#0
  147.    STRW    r0,`dragging                  ; mark as not dragging
  148.    LDMFD   (sp)!,{r1-r2,pc}              ; Return from call
  149.  
  150. .isDataSave
  151. ; check for the correct icon
  152.    REM    "Check icon"
  153.    BL     checkctrl
  154.    BEQ    exitevent
  155.    LDR    r2,[r1,#40]
  156.    ADD    r2,r2,#1
  157.    CMP    r2,#&1000
  158.    BNE    exitevent
  159.    BL     checkshift      ; is shift pressed ?
  160.    BEQ    exitevent       ; if so then exit, 'cos we can't deal with it here
  161.    LDR    r3,[r1,#20]     ; window
  162.    LDR    r4,[r1,#24]     ; icon
  163.    BL     isdragok
  164.    CMP    r0,#0
  165.    BEQ    exitevent
  166.    LDMFD  (sp),{r1}
  167. ; end of check
  168.    MVN    r2,#NOT -1
  169.    STR    r2,[r1,#36]   ; data not safe
  170.    MOV    r2,#128
  171.    STR    r2,[r1,#0]    ; length of block
  172.    MOV    r2,#2
  173.    STR    r2,[r1,#16]   ; ok save file message
  174.    LDR    r2,[r1,#8]
  175.    STR    r2,[r1,#12]   ; note message number
  176.    LADR   r3,`ourfilename
  177.    ADD    r4,r1,#44     ; start of filename
  178. $DSfilenameloop
  179.    LDRB   r2,[r3],#1
  180.    STRB   r2,[r4],#1
  181.    CMP    r2,#31
  182.    BGT    $DSfilenameloop
  183.    MOV    r0,#17
  184.    LDR    r2,[r1,#4]
  185.    SWI    "Wimp_SendMessage"
  186.    MOV    r0,#0
  187.    LDMFD  (sp)!,{r1-r2,pc}
  188.  
  189. .isDataLoad
  190. ; check for the correct icon
  191.    REM    "DataLoad"
  192.    BL     checkctrl
  193.    BEQ    exitevent
  194.    BL     checkshift      ; is shift pressed ?
  195.    BNE    $notshift
  196.    LDREQ  r2,[r1,#36]     ; if so then is this data safe ?
  197.    CMNEQ  r2,#1           ; is it -1 (unsafe ?)
  198.    BEQ    exitevent
  199.    B      $oktoload
  200. $notshift
  201.    LDR    r2,[r1,#40]
  202.    ADD    r2,r2,#1
  203.    CMP    r2,#&1000
  204.    BNE    exitevent
  205. $oktoload
  206.    LDR    r3,[r1,#20]   ; window
  207.    LDR    r4,[r1,#24]   ; icon
  208.    BL     isdragok
  209.    CMP    r0,#0
  210.    BEQ    exitevent
  211. ; end of check
  212.    LDMFD  (sp),{r1}
  213.    LDRW   r3,`str
  214.    LDRW   r4,`length
  215.    ADD    r1,r1,#44   ; filename
  216.    BL     checkshift  ; is shift drag ?
  217.    BEQ    doshiftdrag ; if so then only copy filename…
  218.    MOV    r0,#&40     ; opening file for input
  219.    SWI    "OS_Find"   ; open file
  220.    STRW   r0,`filehandle
  221.    REM    "Handle %r0"
  222. $DLreaddataiconloop
  223.    LDRW   r3,`str
  224.    LDRW   r4,`length
  225. $DLreaddataloop
  226.    LDRW   r1,`filehandle
  227.    MOV    r0,#&7F     ; check EOF
  228.    SWI    "OS_Byte"
  229.    CMP    r1,#0
  230.    BNE    $DLeof
  231.    CMP    r4,#1       ; is this last char
  232.    BEQ    $DLnexticon ; if so, next icon
  233.    LDRW   r1,`filehandle
  234.    SWI    "XOS_BGet"
  235.    STRB   r0,[r3],#1
  236.    CMP    r0,#31       ; is this terminator
  237.    BLE    $DLnexticon  ; if so, next icon
  238.    SUB    r4,r4,#1
  239.    B      $DLreaddataloop
  240. $DLnexticon
  241.    BL     updateicon
  242.    MOV    r0,#0
  243.    STRB   r0,[r3],#1
  244.    LDRW   r4,`icon
  245.    ADD    r4,r4,#1
  246.    STRW   r4,`icon     ; next icon
  247.    LDRW   r3,`window
  248.    BL     isdragok
  249.    CMP    r0,#0       ; is next icon valid
  250.    BEQ    $DLnomore
  251.    B      $DLreaddataiconloop
  252. $DLeof
  253.    LDRW   r4,`str
  254.    CMP    r4,r3          ; have we stored anything yet ?
  255.    MOVNE  r0,#0
  256.    STRNEB r0,[r3],#1
  257.    BLNE   updateicon     ; and only update if we have changed it...
  258. $DLnomore
  259.    LDRW   r1,`filehandle
  260.    MOV    r0,#0       ; r0=0 close file
  261.    SWI    "OS_Find"
  262. ._DLconfirm
  263.    LDMFD  (sp),{r1}
  264.    MOV    r0,#4
  265.    STR    r0,[r1,#16]
  266.    LDR    r0,[r1,#8]
  267.    STR    r0,[r1,#12]
  268.    LDR    r2,[r1,#4]
  269.    MOV    r0,#17
  270.    SWI    "Wimp_SendMessage"
  271.    MOV    r0,#0
  272.    LDMFD  (sp)!,{r1-r2,pc}
  273.  
  274. .doshiftdrag
  275. ; > r1=filename
  276. ;   r3=store location
  277. ;   r4=length of string
  278. $loop
  279.    CMP    r4,#1         ; how much space left ?
  280.    BLE    $exit         ; is terminator then exit
  281.    LDRB   r0,[r1],#1    ; get byte of filename
  282.    STRB   r0,[r3],#1    ; store in block
  283.    CMP    r0,#31        ; is this terminator
  284.    BLE    $exit         ; if so, then exit
  285.    SUB    r4,r4,#1
  286.    B      $loop
  287. $exit
  288.    BL     updateicon
  289.    B      _DLconfirm
  290.  
  291. .isdragok
  292.    STMFD  (sp)!,{r1-r4,link}
  293.    REM    "Win  = %&3"
  294.    REM    "Icon = %&4"
  295.    STRW   r3,`window
  296.    STRW   r4,`icon
  297.    ADRW   r1,`window
  298.    SWI    "XWimp_GetIconState"
  299.    BVS    $notdragok
  300.    LDRW   r2,`flags
  301.    TST    r2,#(1<<8)    ; is it indirected
  302.    BEQ    $notdragok
  303.    AND    r3,r2,#(15<<12)
  304.    CMP    r3,#(14<<12)     ; write/click/drag
  305.    CMPNE  r3,#(15<<12)     ; writeable
  306.    BNE    $notdragok
  307.    MOV    r0,#1
  308.    REM    "Icon valid"
  309.    LDMFD  (sp)!,{r1-r4,pc}
  310. $notdragok
  311.    MOV    r0,#0
  312.    REM    "Icon not valid"
  313.    LDMFD  (sp)!,{r1-r4,pc}
  314.  
  315. .updateicon
  316.    STMFD   (sp)!,{r0-r5,link}            ; Stack registers
  317.    REM     CHR$4+"%IUpdating icon"
  318.    ADRW    r1,`window
  319.    SWI     "Wimp_GetIconState"
  320.    ADD     r1,r1,#8                      ; remove first two words
  321.    LDMIA   r1,{r1-r4}                    ; read lbrt into r1,r2,r3,r4
  322.    LDRW    r0,`window
  323.    SWI     "Wimp_ForceRedraw"
  324.    LDMFD   (sp)!,{r0-r5,pc}              ; Return from call
  325.  
  326. ; Check if the shift key is pressed
  327. ; < EQ if pressed
  328. .checkshift
  329.    STMFD   (sp)!,{r0-r2,link}
  330.    MOV     r0,#&79             ; Keyboard scan OS_Byte code
  331.    MOV     r1,#&80             ; SHIFT key code
  332.    SWI     "XOS_Byte"          ; Call OS_Byte to read status
  333.    TEQ     r1,#&FF             ; is it pressed ?
  334.    LDMFD   (sp)!,{r0-r2,pc}
  335. ; Check if the ctrl key is pressed
  336. ; < EQ if pressed
  337. .checkctrl
  338.    STMFD   (sp)!,{r0-r2,link}
  339.    MOV     r0,#&79             ; Keyboard scan OS_Byte code
  340.    MOV     r1,#&81             ; CTRL key code
  341.    SWI     "XOS_Byte"          ; Call OS_Byte to read status
  342.    TEQ     r1,#&FF             ; is it pressed ?
  343.    LDMFD   (sp)!,{r0-r2,pc}
  344.  
  345. .`ourfilename:EQUS "<Wimp$Scrap>":EQUB 0:ALIGN
  346.  
  347. .ismouseclick
  348.    STMFD   (sp)!,{r3-r9}    ; Stack registers
  349.    LDR     r0,[r1,#8]
  350.    REM     "Button event = %&0"
  351.    BL      checkctrl
  352.    LDRNE   r0,[r1,#8]       ; get buttons if ctrl not pressed…
  353.    TSTNE   r0,#&40          ; …is this a select drag ?
  354.    BEQ     $exit            ; if either then exit
  355. ;    SWI     &104
  356.    REM     "Checking drag is ok"
  357.    LDR     r3,[r1,#12]      ; window
  358.    LDR     r4,[r1,#16]      ; icon
  359.    BL      isdragok
  360.    CMP     r0,#0
  361.    BEQ     $exit
  362. $isdrag
  363.    LDRW    r2,`window
  364.    MVN     r3,#NOT -1
  365.    MOV     r0,#19
  366.    SWI     "XWimp_SendMessage"  ; find the task handle
  367.    BVS     $exit
  368.    MOV     r6,r2                ; r6=task handle
  369.    MOV     r8,#0                ; r8=pointer to rma
  370.    MOV     r7,#0                ; r7=length of area (0 bytes)
  371.    ADR     r2,`textfile         ; large text file icon to drag
  372.    BL      setdrag
  373.    BL      addline
  374. ;    SWI     &104
  375.    REM     "Is one of our drag requests!!!"
  376.    MOV     r0,#1
  377.    STRW    r0,`dragging
  378.    STRW    r8,`saveaddr
  379.    STRW    r7,`savelen
  380.    REM     "Data is length %r7, containing %$8"
  381.    B       $noaction
  382. $noaction
  383.    MOV     r0,#0
  384.    LDMFD   (sp)!,{r3-r9}              ; Restore registers
  385.    LDMFD   (sp)!,{r1-r2,pc}           ; Return from call
  386. $exit
  387.    MOV     r0,#6
  388.    LDMFD   (sp)!,{r3-r9}              ; Restore registers
  389.    LDMFD   (sp)!,{r1-r2,pc}           ; Return from call
  390.  
  391. .`textfile
  392.    EQUS    "File_FFF"+CHR$0
  393. .`smallfile
  394.    EQUS    "Small_FFF"+CHR$0
  395.    ALIGN
  396.  
  397. ; set the drag icon
  398. .setdrag
  399.    STMFD   (sp)!,{r0-r5,link}            ; Stack registers
  400.    CMP     r8,#0                ; is the current pointer set ?
  401.    SWINE   "DragASprite_Stop"   ; if not then stop the current drag
  402.    ADRW    r1,`dragbox
  403.    SWI     "Wimp_GetPointerInfo"
  404.    LDMIA   r1,{r0-r1}
  405.    SUB     r0,r0,#34            ; x0=x-34 (½ width of box)
  406.    SUB     r1,r1,#34            ; y0=y-34 (½ height of box)
  407.    ADD     r2,r0,#34*2          ; x1=x0+64 (width of box)
  408.    ADD     r3,r1,#34*2          ; y1=y0+64 (height of box)
  409.    ADRW    r5,`dragbox
  410.    STMIA   r5,{r0-r3}           ; store drag box in block in WS
  411.    LDR     r2,[sp,#8]           ; r2=sprite name
  412.    MOV     r0,#%11000101        ; centre, constrain pointer, do shadow
  413.    MOV     r1,#1                ; use Wimp sprite area
  414.    MOV     r3,r5                ; r3=dragbox pointer
  415.    SWI     "DragASprite_Start"
  416.    REM     "Starting drag"
  417.    LDMFD   (sp)!,{r0-r5,pc}              ; Return from call
  418.  
  419. .wait
  420.    STMFD   (sp)!,{r0-r1,link}            ; Stack registers
  421.    SWI     "OS_ReadMonotonicTime"
  422.    ADD     r1,r0,#5         ; r1=time now + delay
  423. $loop
  424.    SWI     "OS_ReadMonotonicTime"
  425.    CMP     r0,r1            ; have we exceeded delay ?
  426.    BLT     $loop            ; if not then keep checking…
  427.    LDMFD   (sp)!,{r0-r1,pc}              ; Return from call
  428.  
  429. ; Add a line from the icon pointed to by the block
  430. .addline
  431.    STMFD   (sp)!,{r0-r5,link}            ; Stack registers
  432.    LDRW    r0,`str                       ; r0=string
  433.    BL      lenctrl                       ; how long is the string
  434.    REM     "Checking length = %r1, current block = %&8"
  435. ;    REM     "String located at %&0"
  436. ;    LDMFD   (sp)!,{r0-r5,pc}              ; Return from call
  437. ;
  438.    CMP     r8,#0                         ; is this the first call ?
  439.    MOVEQ   r0,#6                         ; if so then claim new block
  440.    MOVNE   r0,#13                        ; otherwise extend it
  441.    MOVNE   r2,r8
  442.    MOV     r3,r1                         ; r3=amount to claim/extend
  443.    ADD     r3,r1,#1                      ; add extra byte for LF
  444.    SWI     "OS_Module"                   ; claim/extend
  445.    MOV     r8,r2                         ; r8=new area pointer
  446.    ADD     r1,r2,r7                      ; r2=end of previous area
  447.    LDRW    r0,`str                       ; r0=pointer to string to copy
  448.    REM     "Moving %&0 to %&1"
  449.    BL      movectrl                      ; copy it to the new area
  450.    ADD     r7,r7,r3                      ; increment amount to copy
  451.    MOV     r0,#10                        ; LF to add to end of line!
  452.    SUB     r1,r7,#1                      ; store as last byte
  453.    STRB    r0,[r8,r1]                    ; and store in memory
  454.    LDMFD   (sp)!,{r0-r5,pc}              ; Return from call
  455.  
  456. .isdragdone
  457.    STMFD   (sp)!,{r3-r9}                 ; Stack registers
  458.    LDRW    r0,`dragging
  459.    CMP     r0,#1
  460.    CMPNE   r0,#3
  461.    BNE     $exit
  462.    REM     "%c04Drag done, in state %r0"
  463.    SWI     "DragASprite_Stop"
  464.    SWI     "Wimp_GetPointerInfo"
  465.    LDMIA   r1,{r2,r3,r4,r5,r6}
  466.    REM     "%R"
  467.    STR     r5,[r1,#20]      ; store mx
  468.    STR     r6,[r1,#24]      ; store my
  469.    STR     r2,[r1,#28]      ; store mw
  470.    STR     r3,[r1,#32]      ; store mi
  471.    MOV     r2,#56           ; block length
  472.    MOV     r3,#0            ; to
  473.    MOV     r4,#0            ; ref
  474.    MOV     r5,#0            ; ref
  475.    MOV     r6,#1            ; message
  476.    STMIA   r1,{r2-r6}       ; store in block
  477.    ADR     r0,`estlen       ; address of estimated length
  478.    LDMIA   r0,{r2-r6}
  479.    ADD     r0,r1,#36
  480.    STMIA   r0,{r2-r6}       ; copy into block
  481.    MOV     r0,#18           ; send recorded delivery…
  482.    LDR     r2,[r1,#20]      ; get window to send to
  483.    LDR     r3,[r1,#24]      ; get icon to send to
  484.    REM     "Sending to %&2"
  485.    SWI     "XWimp_SendMessage"
  486.    MOVVS   r0,#0            ; not dragging if error
  487.    MOVVC   r0,#2            ; if no error then on to save data message
  488.    STRW    r0,`dragging
  489.    REM     "Message sent, ok = %r0"
  490. $noaction
  491.    MOV     r0,#0
  492.    LDMFD   (sp)!,{r1-r9,pc}              ; Return from call
  493. $exit
  494.    MOV     r0,#7
  495.    LDMFD   (sp)!,{r1-r9,pc}              ; Return from call
  496.  
  497. .`estlen
  498.    EQUD    -1 ; data not safe
  499. .`texttype
  500.    EQUD    &FFF
  501. .`savename
  502.    EQUS    "Icontext"+CHR$0
  503.  
  504. .checknullevent
  505.    LDRW    r2,`dragging
  506.    REM     "%c04%c30Current state = %r2"
  507.    CMP     r2,#1
  508.    BEQ     isnullevent
  509.    CMP     r2,#3
  510.    LDMNEFD (sp)!,{r1-r2,pc}         ; return if not a small drag
  511.    STMFD   (sp)!,{r3-r9}            ; Stack registers
  512.    ADRW    r1,`ptrblock
  513.    SWI     "Wimp_GetPointerInfo"
  514.    LDRW    r0,`mouseb
  515.    TST     r0,#4
  516.    BEQ     $dropped                 ; if you drop, but still hold adjust
  517.    TST     r0,#1                    ; adjust ?
  518.    BNE     $exit                    ; if still pressed then exit
  519.    BL      wait
  520.    LDRW    r8,`saveaddr             ; get save address
  521.    ADR     r2,`textfile             ; swap back to biggy
  522.    BL      setdrag
  523.    MOV     r0,#1
  524.    STRW    r0,`dragging
  525.    MOV     r0,#0
  526. $exit
  527.    LDMFD   (sp)!,{r3-r9}
  528.    LDMFD   (sp)!,{r1-r2,pc}         ; Return from call
  529. $dropped
  530.    LDMFD   (sp)!,{r3-r9}
  531.    MOV     r0,#0
  532.    B       isdragdone
  533.  
  534. .isnullevent
  535.    STMFD   (sp)!,{r3-r9}            ; Stack registers
  536.    STRW    r1,`userblock
  537.    ADRW    r1,`ptrblock
  538.    SWI     "Wimp_GetPointerInfo"
  539.    LDRW    r0,`mouseb
  540.    TST     r0,#1                    ; adjust ?
  541.    BEQ     $exit
  542.    LDRW    r3,`mousew
  543.    LDRW    r4,`mousei
  544.    BL      isdragok
  545.    CMP     r0,#0                    ; is it a valid icon to add ?
  546.    BEQ     $exit
  547.    MOV     r0,#5                    ; read current task handle
  548.    SWI     "Wimp_ReadSysInfo"
  549.    MOV     r9,r0                    ; r9=current task
  550. ; read task handle we are over
  551.    LDRW    r1,`userblock
  552.    MOV     r2,r3
  553.    MOV     r3,r4
  554.    MOV     r0,#19
  555.    SWI     "XWimp_SendMessage"  ; find the task handle
  556.    REM     CHR$4+"%ICurrent = %&9, over = %&2, win = %&3, icon=%&4"
  557.    CMP     r2,r9                ; are they the same task ?
  558.    BEQ     $gotarea             ; if they are then `str is in right place
  559.    MOV     r0,r2                ; r0=source (over)
  560.    LDRW    r1,`str              ; r1=source data (in over)
  561.    MOV     r2,r9                ; r2=dest (current)
  562.    LDRW    r3,`userblock        ; r3=dest data (in current - users block!)
  563.    MOV     r4,#256              ; r4=length
  564.    REM     "Move from T%&0 to T%&2, from A%&1 to A%&3"
  565.    SWI     "Wimp_TransferBlock"
  566.    MOV     r0,#0
  567.    STRB    r0,[r3,#255]         ; add a terminator in case the string is long
  568.    STRW    r3,`str              ; store in block so that addline can find it
  569. $gotarea
  570.    LDRW    r3,`str
  571.    REM     "Is one of ours, is %$3"
  572.    LDRW    r7,`savelen
  573.    LDRW    r8,`saveaddr
  574.    REM     "Currently says %$8"
  575.    BL      addline
  576.    STRW    r8,`saveaddr
  577.    STRW    r7,`savelen
  578.    LADR    r2,`smallfile
  579.    BL      setdrag
  580.    MOV     r0,#3
  581.    STRW    r0,`dragging         ; mark as currently dragging small
  582. $exit
  583.    MOV     r0,#0
  584.    LDMFD   (sp)!,{r3-r9}                 ; Restore registers
  585.    LDMFD   (sp)!,{r1-r2,pc}              ; Return from call
  586.  
  587. #Library "Strings",lenctrl.movectrl
  588. # POST
  589. # RUN <CODE>
  590. # END
  591.  
  592.