home *** CD-ROM | disk | FTP | other *** search
/ Enigma Amiga Life 109 / EnigmaAmiga109CD.iso / software / musica / getcddb / source / getcdd~1.bb2 < prev    next >
Text File  |  2000-01-07  |  6KB  |  256 lines

  1. ;GetCDDB_MiscFuncs.bb2
  2.  
  3. XINCLUDE GetCDDB_Consts.bb2
  4.  
  5. ;-----------------------------------------------------------------
  6. ; My Misc Funcs
  7. ;-----------------------------------------------------------------
  8.  
  9. Statement ErrorReq{error$}
  10.   SHARED noreq.b
  11.   If NOT noreq
  12.     Request "Error",error$,"OK"
  13.   EndIf
  14. End Statement
  15.  
  16. Statement SetStatus{stat$}
  17.   SHARED noreq.b
  18.   If NOT noreq.b
  19.     GTSetString #_MAIN_WIN,#_STATUS_TEXT,stat$
  20.   EndIf
  21. End Statement
  22.  
  23. ;-----------------------------------------------------------------
  24. ; Returns value of #_DISC_PATH string
  25.  
  26. Function.s GetDiscPath{}
  27.   discpath$=GTGetString(0,#_DISC_STRING)
  28.   If Right$(discpath$,1)<>":" AND Right$(discpath$,1)<>"/"
  29.     discpath$+"/"
  30.   EndIf
  31.   Function Return discpath$
  32. End Function
  33.  
  34. ;-----------------------------------------------------------------
  35. ; Other Misc Funcs
  36. ;-----------------------------------------------------------------
  37.  
  38. Function.s ASLPathRequest{title$,pathname$}
  39.   *scr.Screen=Peek.l(Addr Screen(Used Screen))
  40.  
  41.   top.w=0
  42.   left.w=0
  43.   width.w=ScreenWidth/2 ; remove /2 for full-screen requester! ;)
  44.   height.w=ScreenHeight
  45.  
  46.   Dim Tags.TagItem(9)
  47.   Tags(0)\ti_Tag=#ASLFR_Screen,*scr
  48.   Tags(1)\ti_Tag=#ASLFR_TitleText,&title$
  49.   Tags(2)\ti_Tag=#ASLFR_InitialDrawer,&pathname$
  50.   Tags(3)\ti_Tag=#ASLFR_InitialLeftEdge,left
  51.   Tags(4)\ti_Tag=#ASLFR_InitialTopEdge,top
  52.   Tags(5)\ti_Tag=#ASLFR_InitialWidth,width
  53.   Tags(6)\ti_Tag=#ASLFR_InitialHeight,height
  54.   Tags(7)\ti_Tag=#ASLFR_DrawersOnly,-1
  55.   Tags(8)\ti_Tag=#TAG_END,0
  56.  
  57.  *filereq.FileRequester=AllocAslRequest_(#ASL_FileRequest,&Tags(0))
  58.   If *filereq
  59.     ok.l=AslRequest_(*filereq,&Tags(0))
  60.     If ok
  61.       f$=Peek.s(*filereq\fr_Drawer)
  62.       If Len(f$)>0 Then If Right$(f$,1)<>":" AND Right$(f$,1)<>"/" Then f$+"/"
  63.       f$=f$+Peek.s(*filereq\fr_File)
  64.     Else
  65.       f$="nil:" ; an impossible/unusable case!
  66.     EndIf
  67.     FreeAslRequest_(*filereq)
  68.   EndIf
  69.   Function Return f$
  70. End Function
  71. ;
  72.  
  73. ;-----------------------------------------------------------------
  74.  
  75. ; Function : ProgsDir {}
  76.  
  77. ; Author : Nick Clover - nick@bauk.freeserve.co.uk
  78.  
  79. ; Returns a string with the program's directory.
  80.  
  81. ; IMPORTANT! Only works with compiled executables,as
  82. ; Compiling & Running doesn't use a directory (obviously ;)
  83.  
  84. ; **** REPLACEMENT by Nick Clover ****
  85. ; Now returns program directory when run from WB as well!
  86. ; Cool :)
  87.  
  88. ; UPDATE - renamed to ProgsDir, to keep in line with ProgsName,
  89. ;          because ProgDir is a Blitz Support Suite command.
  90.  
  91. Function.s ProgsDir{}
  92.  
  93.   MaxLen path$=200
  94.   NameFromLock_ GetProgramDir_(),&path$,200
  95.   path$=Peek$(&path$)
  96.   If Right$(path$,1)<>":" AND Right$(path$,1)<>"/"
  97.     path$+"/"
  98.   EndIf
  99. Function Return path$
  100. End Function
  101.  
  102. ;-----------------------------------------------------------------
  103.  
  104. Function.s ProgsName{}
  105.  
  106. If FromCLI=-1
  107.  
  108.   *stringbuffer = AllocMem_(255, 0)
  109.   suc.l=GetProgramName_(*stringbuffer,255)
  110.  
  111.   If suc
  112.     pname$=Peek$(*stringbuffer)
  113.   EndIf
  114.  
  115.   FreeMem_ *stringbuffer,255
  116.  
  117. Else pname$=Peek$(Peek.l(FindTask_(0)+$B0)+4)
  118. EndIf
  119.  
  120. Function Return pname$
  121.  
  122. End Function
  123.  
  124. ; Function : ToolString { icon, tooltype }
  125.  
  126. ; Author : James L Boyd - jamesboyd@all-hail.freeserve.co.uk
  127. ; - adapted from someone else's source!
  128.  
  129. ; Returns tooltype's contents (if any)...
  130.  
  131. Function.s ToolString {icon$,tool$}
  132.  
  133. *Icon.DiskObject=GetDiskObject_(&icon$)
  134.  
  135. ; *Icon.DiskObject=GetDiskObjectNew_(&icon$)
  136. ; ^ this uses the default-type icon if there isn't one...
  137.  
  138. If *Icon
  139.   a.l=FindToolType_(*Icon\do_ToolTypes,&tool$)
  140.   If a
  141.     a$=Peek$(a)
  142.   Else a$=""
  143.   EndIf
  144.   FreeDiskObject_ *Icon
  145. Else
  146.   Request "o","moo","blob"
  147.  Function Return ""
  148. EndIf
  149.  
  150. End Function
  151. ;-----------------------------------------------------------------
  152.  
  153. ; Function : Value { number as string }
  154.  
  155. ; Author : Curt Esser - camge@ix.netcom.com
  156.  
  157. ; This function returns correct values
  158. ; for very large numbers - Blitz doesn't!
  159.  
  160. ; Probably saves quite a bit on executable size too.
  161.  
  162. Function.l  Value {input$}
  163.   valu.l=0
  164.   chars.w=StrToLong_(&input$,&valu)
  165.   Function Return valu
  166. End Function
  167.  
  168. ; demo :
  169.  
  170. ; test$="1087504386"
  171.  
  172. ; NPrint "Blitz's Val      : ",Val(test$)
  173. ; NPrint "Value{} function : ",Value{test$}
  174.  
  175. ; MouseWait
  176. ; End
  177.  
  178. ;-----------------------------------------------------------------
  179.  
  180. ; Function : LockWindow { window }
  181.  
  182. ; Locks the specified window, puts up busy pointer.
  183.  
  184. ; Unlocked with the UnLockWindow {} statement.
  185.  
  186. ; IMPORTANT!!! You should store the result as a long
  187. ; variable, as in the demo - this is needed for the
  188. ; UnLockWindow {} statement!
  189.  
  190. Function.l LockWindow {win.l}
  191.   lock.l=AllocMem_(SizeOf .Requester,1)
  192.   If lock
  193.     win=Peek.l(Addr Window(win))
  194.     InitRequester_(lock)
  195.     If Request_(lock,win)
  196.       *_exec.Library=Peek.l(4)
  197.       If *_exec\lib_Version=>39
  198.         Dim tag.TagItem(1)
  199.         tag(0)\ti_Tag=#WA_BusyPointer,-1
  200.         tag(1)\ti_Tag=#TAG_END
  201.         SetWindowPointerA_ win,&tag(0)
  202.       EndIf
  203.     Else
  204.       FreeMem_ lock,SizeOf .Requester
  205.       lock=0
  206.     EndIf
  207.   EndIf
  208.   Function Return lock
  209. End Function
  210.  
  211. ;-----------------------------------------------------------------
  212.  
  213. ; Statement : UnLockWindow { window, lock }
  214.  
  215. ; Unlocks a window locked with the LockWindow {} function.
  216.  
  217. ; IMPORTANT!!!! The "lock" parameter is the value returned
  218. ; from LockWindow {} , eg. lock.l=LockWindow {0}
  219.  
  220. ; You supply this value to this statement.
  221.  
  222. Statement UnlockWindow{win.l,lock.l}
  223.   win=Peek.l(Addr Window(win))
  224.   *_exec.Library=Peek.l(4)
  225.   If *_exec\lib_Version=>39
  226.     Delay_ 5
  227.     Dim tag.TagItem(0)
  228.     tag(0)\ti_Tag=#TAG_END
  229.     SetWindowPointerA_ win,&tag(0)
  230.   EndIf
  231.   EndRequest_ lock,win
  232.   FreeMem_ lock,SizeOf .Requester
  233. End Statement
  234.  
  235. ; demo :
  236.  
  237. ; FindScreen 0
  238.  
  239. ; Window 0,0,0,640,100,$40f,"Delayed for 2 seconds",1,2
  240. ; GTButton 0,0,0,0,200,10,"Click me!",0
  241.  
  242. ; AttachGTList 0,0
  243.  
  244. ; lock.l=LockWindow {0}
  245.  
  246. ;   Delay_ 100
  247.  
  248. ; If lock Then UnlockWindow {0,lock}
  249.  
  250. ;   Delay_ 100
  251.  
  252. ; End
  253.  
  254.  
  255.  
  256.