home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 1 / ARM_CLUB_CD.iso / contents / apps / desktop / a / appensure / Source / AppEnsure (.txt) next >
Encoding:
RISC OS BBC BASIC V Source  |  1993-06-19  |  4.3 KB  |  132 lines

  1.   >AppEnsure
  2.     Execute * command if application not active
  3.      
  4.  Cy Booker 1993
  5.  "Source:Constants"
  6.  "Source:MakeUtil"
  7. $ + " ["+ 
  8. )+ "]"
  9. code_size% = 2*1024
  10.  code% code_size%-1
  11. debug_AppEnsure = 
  12. _Define_Constants
  13. _Make_Code("AppEnsure", "AppEnsure", &FF8)
  14. _Test_AppEnsure
  15. *********************************************************************
  16. **************************** AppEnsure **********************************
  17. *********************************************************************
  18. _Test_AppEnsure
  19.  debug_AppEnsure 
  20.  B% 256
  21. B    $B% = """Debug viewer"" <pd>.Desktop.Utils.!BugView"+ 
  22.  A% 1024
  23. '    
  24. ("BreakSet "+ 
  25. ~(code%+break))
  26.  code%
  27. _assemble_AppEnsure
  28.  loop, lp, cmp
  29.   bufsiz% = 512
  30.   argsiz% = 256
  31. [OPT pass%
  32. \Cy J Booker
  33. (/\12.06.1993 - Wrote (as utility --- failed)
  34. )#\19.06.1993 - as an application
  35. +>\ Syntax. *AppEnsure [-Title] <title> [-Command] <command>
  36. ;       Note - no stack!
  37.         ADR     R12, buffer
  38. /9        SUB     R0, R12, #&8000 - (argsiz% + bufsiz%)
  39.         MVN     R1, #0
  40. 1K        SWI     "XWimp_SlotSize"                ; Ensure buffer exists!
  41. 2         SWIvc   "XOS_GetEnv"
  42.         Bvs     error
  43. 4         LDRB    R2, [R0, #0]
  44.         CMP     R2, #
  45. (" ")
  46. 67        Bls     help                    \ Give help
  47.         MOV     R1, R0
  48.         ADR     R0, args
  49.         MOV     R2, R12
  50. :         MOV     R3, #bufsiz%
  51. ;"        SWI     "XOS_ReadArgs"
  52.         Bvs     help
  53.         MOV     R0, #0
  54. >%.loop   ADD     R1, R12, #argsiz%
  55. ?         MOV     R2, #bufsiz%
  56. @1        SWI     "XTaskManager_EnumerateTasks"
  57.         Bvs     error
  58. B*        ADD     R3, R12, #argsiz% - 16
  59. Cd.lp     ADD     R3, R3, #16                     ; pointer to 16-byte word-aligned block for task
  60.         CMP     R3, R1
  61. E$        Bhs     enumerated_chunk
  62. FJ        LDR     R4, [R3, #4]                    ; pointer to task name
  63. GF        LDR     R5, [R12, #4]                   ; pointer to title
  64. H .cmp    LDRB    R6, [R4], #1
  65. I         LDRB    R7, [R5], #1
  66.         CMP     R6, #
  67.         Blo     endcmp
  68.         TEQ     R6, R7
  69.         Beq     cmp
  70.         B       lp
  71. .endcmp
  72.         CMP     R7, #
  73.         Bhs     lp
  74. .quit   MOV     R0, #0
  75. S"        LDR     R1, value_ABEX
  76.         MOV     R2, #0
  77.         SWI     "OS_Exit"
  78. .value_ABEX
  79.         EQUS    "ABEX"
  80. .value_TASK
  81.         EQUS    "TASK"
  82. .enumerated_chunk
  83.         CMP     R0, #0
  84.         Bgt     loop
  85.         MOV     R0, #300
  86.         ADD     R0, R0, #10
  87. _"        LDR     R1, value_TASK
  88.         ADR     R2, title
  89. a         ADR     R3, messages
  90. bH        SWI     "XWimp_Initialise"              ; R1 --> task handle
  91.         Bvs     error
  92. dE        LDR     R0, [R12, #8]                   ; Execute command
  93. e%        SWI     "XWimp_StartTask"
  94.         MOVvs   R2, R0
  95.         MOV     R3, pc
  96.         MOV     R0, R1
  97. i"        LDR     R1, value_TASK
  98. j%        SWI     "XWimp_CloseDown"
  99.         MOVvc   R0, R2
  100.         TEQvcP  R3, #0
  101.         Bvc     quit
  102. n".error  LDR     R1, value_ABEX
  103.         MOV     R2, #1
  104.         SWI     "OS_Exit"
  105. .messages
  106.         EQUD    0
  107. t#.title  EQUS    "AppEnsure"+ 
  108. u..args   EQUS    "/a,Title/a,Command/a"+ 
  109.         ALIGN
  110. x!.help   ADR     R0, help_text
  111. yC        MOV     R1, #0                  \ Use system dictionary
  112. z!        ADR     R2, help_name
  113. {%        SWI     "XOS_PrettyPrint"
  114.         Bvc     quit
  115.         B       error
  116. .help_name
  117.         EQUS    "AppEnsure"
  118.         EQUB    0
  119. .help_text
  120. V        EQUS    "*"+ name$+ " will load the Wimp task using the given command if "
  121. X        EQUS    "that task is not already loaded. <title> is the name as listed in "
  122. W        EQUS    "the task manager window, and <command> is something that will be "
  123. W        EQUS    "Wimp_StartTask'ed if necessary (<command is usually the diretory "
  124. *        EQUS    "of the application)."
  125.         EQUS    nl$
  126. E        EQUS    syntax$+ " [-Title] <title> [-Command] <command>"
  127.         EQUS    nl$
  128.         EQUB    0
  129.         ALIGN
  130. .buffer
  131.     ]:= 0
  132.