Project

General

Profile

delete_static_resource.p

tests static resource deletion - Constantin Asofiei, 10/21/2013 07:35 AM

Download (1.9 KB)

 
1
def temp-table tt1 field f1 as int.
2
def var h as handle.
3
def var i as int.
4
def var j as char.
5

    
6
create tt1.
7
tt1.f1 = 10.
8

    
9
open query q for each tt1.
10

    
11
display i j view-as text with frame f1.
12

    
13
function getMsg returns char(input type as char).
14
   def var msg as char.
15
   msg = "Static handle type " + type + " given to DELETE PROCEDURE or DELETE OBJECT statement. (5428)".
16
   return msg.
17
end.
18

    
19
procedure tryDelete.
20
   def input param h as handle.
21
   def input param err as log.
22
   def input param type as char.
23
   def var msg as char.
24
   
25
   delete object h no-error.
26
   if error-status:error <> err
27
      then message "For case" msg "ERROR-STATUS:ERROR is" string(error-status:error) "and expected is" string(err) ".".
28

    
29
   if (type <> "QUERY" and type <> "BUFFER" and type <> "TEMP-TABLE")
30
   then do:
31
      if error-status:num-messages <> 1
32
         then message "For case" msg "ERROR-STATUS:NUM-MESSAGES is" string(error-status:num-messages) "and expected is 1.".
33

    
34
      msg = getMsg(type).
35
      if error-status:get-message(1) <> msg
36
         then message "For case" type "ERROR-STATUS:GET-MESSAGE(1) is" error-status:get-message(1) "and expected is" msg.
37
   end.
38
   else do:
39
      if error-status:num-messages <> 0
40
         then message "For case" msg "ERROR-STATUS:NUM-MESSAGES is" string(error-status:num-messages) "and expected is 0.".
41
   end.
42
end.
43

    
44
h = frame f1:handle.
45
run tryDelete(h, yes, "FRAME").
46

    
47
h = i:handle in frame f1.
48
run tryDelete(h, yes, "FILL-IN").
49

    
50
h = j:handle in frame f1.
51
run tryDelete(h, yes, "TEXT").
52

    
53
release tt1.
54
find first tt1.
55
h = temp-table tt1:handle.
56
run tryDelete(h, no, "TEMP-TABLE").
57
if not avail(tt1) then message "BUFFER was deleted!".
58

    
59
release tt1.
60
find first tt1.
61
h = buffer tt1:handle.
62
run tryDelete(h, no, "BUFFER").
63
if not avail(tt1) then message "BUFFER was deleted!".
64

    
65
release tt1.
66
get next q.
67
h = query q:handle.
68
run tryDelete(h, no, "QUERY").
69
if not avail(tt1) then message "QUERY was deleted!".