AnsweredAssumed Answered

vrf Imported UserFunctions

Question asked by VRFuser on May 20, 1997

     A simple way around this problem is to ensure that private functions
     use unique names.  I recently completed a large project where I wrote
     a number of common function libraries for a number instruments while
     another group was doing the same for other instruments.  We worked
     under a coding standard that required all private functions to be
     named as follows:
    
        <library name>_<function name>_private
    
     The <library name> ensures that the function name is unique and the
     _private suffix makes it obvious that the function is a local private
     function.  If everybody follows the same rules, problems such as yours
     can be avoided.
    
     ----_/----------------------------------------------------------------
        _/             Bruce Wenner                /  Hewlett-Packard
       _/_/_/  _/_/_/  Custom Solution Specialist /   2025 W Larpenteur Ave
      _/  _/  _/  _/   Tel: 612-603-2818         /    St. Paul, MN  55113
     _/  _/  _/_/_/    FAX: 612-603-3016         
            _/         E:Mail: Bruce_Wenner@hp.com
     ------_/--------------------------------------------------------------



______________________________ Reply Separator _________________________________
Subject: vrf Imported UserFunctions
Author:  Non-HP-peter.larsson (peter.larsson@space.se) at HP-USA/o2=mimegw3
Date:    5/20/97 6:44 AM


I have appearently not defined the problem well enough.
Let me give you an example:

In a department there are two employees writing VEE-code.
Let's call them Mr. A and Mr. B.

Mr. A has written a library, LIB1.vee, with a function Plus and
Mr. B has written a library, LIB2.vee, with a function Minus.

Both Mr. A and Mr. B has, unfortunally, named a function: calculate
witch in Mr. A's case makes an add and in Mr. B's case a subtraction.

The thoughts of Mr.A:

LIB1.vee        :The name of his library
LIB1_Plus      :The name of his exported public (global) function
  Calculate     :The name of what he thouht was a private (local) function
                 only to be used in LIB1_Plus

And Mr.B

LIB2.vee        :The name of his library
LIB2_Minus     :The name of his public (global) function
  Calculate     :The name if what he thought was a private (local) function
                 only to be used in LIB2_Minus

When the department tried to integrate both their librarys in a program
the following happened:

Main            :The main program
LIB1           :Imports Mr. A's library
  LIB1_Plus     :and recieves the function LIB1_Plus...
  Calculate     :...and a function Calculate with no references to it's own
                 library
LIB2           :Imports Mr. B's library
  LIB2_Minus    :and recieves the function LIB2_Minus...
  Calculate     :... and an other function Calculate

The main program is first trying to add two numbers together, using LIB1_Plus,
and display the answer then trying to subtract two numbers, using LIB2_Minus.
In both cases VEE uses the first function Calculate and the result will be
the same.

I'll send you the VEE code of the example above. This code can only be used in
VEE 4.0.

In a department the problems can be solved by just telling Mr. A and B witch
names they are allowed to use but suppose you want to buy two librarys from
two different companies. If the two librarys are doing about the same thing
the risk of finding two identicaly named functions are imminent.

In VEE 4.0 you have taken care of the problem with local and global variables.
I believe that the step of making private / public function isn't far away.


/Peter Larsson


Save this as C:DUMMYLIB1.vee ------------------------------------------------

(saveFormat "2.3")
(date "Fri 16/May/1997 16:13:09 ")
(veerev "4.0")
(platform "PC")
(execMode compatible)
(filterNAN 0)
(workspaceStackingOrder F1 F0 M)
(SaveCF no)
(device 0 ROOTCONTEXT
(properties
(trigMode deg)
(nextID 11)
(popupTitleText "Untitled")
(popupMoveable 1))
(deviceList
(UserFunctions
(nextID 2)
(context 0
(properties
(name "Calculate")
(trigMode deg)
(nextID 1)
(popupTitleText "Plus"))
(interface
(input 1
(name "A")
(optional yes))
(input 2
(name "B")
(optional yes))
(output 1
(type data)
(name "X")
(lock constraints)
(optional yes)))
(deviceList
(device 0 FORMULA
(properties
(expr 1 "A+B"))
(interface
(input 1
(name "A")
(optional yes))
(input 2
(name "B")
(optional yes))
(output 1
(name "Result")
(tag "Result")
(lock name constraints)
(optional yes))))
(configuration
(connect I1:1 D0:1)
(connect I2:1 D0:2)
(connect D0:1 O1:1)))
(contextCarrier
(wndOrigin 2 654)
(wndRestoredOrigin 42 42)
(wndRestoredExtent 269 132)
(wndState min)
(active detail)
(detail
(extent 269 132)
(anchorPt 112 77)
(configuration
(devCarrierFor 0
(active open)
(icon
(extent 57 0))
(open
(extent 72 42))
(terminals on)
(pinCenter -10 0))
(connect I1:1 D0:1
(points 4 -112 -52 -101 -52 -101 -10 -79 -10))
(connect I2:1 D0:2
(points 4 -112 28 -101 28 -101 10 -79 10))
(connect D0:1 O1:1
(points 4 78 0 99 0 99 -12 156 -12))))))
(context 1
(properties
(name "LIB1_Plus")
(trigMode deg)
(nextID 3)
(popupTitleText "plus3n4"))
(interface
(input 1
(name "A")
(optional yes))
(input 2
(name "B")
(optional yes))
(output 1
(type data)
(name "X")
(lock constraints)
(optional yes)))
(deviceList
(device 2 CALL
(properties
(name "Call Calculate")
(callFunc "Calculate")
(parmMode rev30))
(interface
(input 1
(name "A")
(optional yes))
(input 2
(name "B")
(optional yes))
(output 1
(name "X")
(lock name constraints)
(optional yes))))
(configuration
(connect I1:1 D0:1)
(connect I2:1 D0:2)
(connect D0:1 O1:1)))
(contextCarrier
(wndOrigin 162 654)
(wndRestoredOrigin 22 22)
(wndRestoredExtent 590 271)
(wndState min)
(active detail)
(detail
(extent 590 271)
(anchorPt 71 70)
(configuration
(devCarrierFor 2
(active open)
(icon
(extent 95 0))
(open
(extent 196 53))
(terminals on)
(pinCenter 250 60))
(connect I1:1 D0:1
(points 4 -71 -5 -60 -5 -60 50 119 50))
(connect I2:1 D0:2
(points 4 -71 135 -60 135 -60 70 119 70))
(connect D0:1 O1:1
(points 4 380 60 400 60 400 65 518 65)))))))
(device 6 CALL
(properties
(name "Call LIB1_Plus")
(callFunc "LIB1_Plus")
(parmMode rev30))
(interface
(input 1
(name "A")
(optional yes))
(input 2
(name "B")
(optional yes))
(output 1
(name "X")
(lock name constraints)
(optional yes))))
(device 7 START25)
(device 8 TEXTDISPLAY
(interface
(input 1
(name "Data"))))
(device 9 CONSTANT
(properties
(name "Integer"))
(interface
(output 1
(name "Int32")
(lock name constraints)))
(implementation
(value Int32
(data  3))
(initValue Int32
(data  0))))
(device 10 CONSTANT
(properties
(name "Integer"))
(interface
(output 1
(name "Int32")
(lock name constraints)))
(implementation
(value Int32
(data  4))
(initValue Int32
(data  0))))
(configuration
(connect D1:0 D0:0)
(connect D3:1 D0:1)
(connect D4:1 D0:2)
(connect D0:1 D2:1)))
(contextCarrier
(wndOrigin 2 2)
(wndState res)
(active detail)
(detail
(extent 946 560)
(anchorPt 344 173)
(configuration
(devCarrierFor 6
(active open)
(icon
(extent 100 0))
(open
(extent 196 53))
(terminals on)
(pinCenter 0 0))
(devCarrierFor 7
(active open)
(icon)
(open
(extent 47 22))
(title off)
(pinCenter 0 -90))
(devCarrierFor 8
(active open)
(icon)
(open
(extent 131 28))
(pinCenter 250 0))
(devCarrierFor 9
(active open)
(icon)
(open
(extent 84 30)
(showFormat int))
(pinCenter -260 -50))
(devCarrierFor 10
(active open)
(icon)
(open
(extent 84 30)
(showFormat int))
(pinCenter -260 30))
(connect D1:0 D0:0
(points 2 0 -77 0 -47))
(connect D3:1 D0:1
(points 4 -216 -50 -200 -50 -200 -10 -131 -10))
(connect D4:1 D0:2
(points 4 -216 30 -200 30 -200 10 -131 10))
(connect D0:1 D2:1
(points 2 130 0 182 0)))
(stackingOrder 1 2 0 3 4))
(numberFormats
(realFormat standard)
(realSigDigits 4)
(realRadixSpec 4)
(integerBase decimal))))

cut here-----------------------------------------------------------------------
Save this as C:DUMMYLIB2.vee ------------------------------------------------

(saveFormat "2.3")
(date "Fri 16/May/1997 16:17:12 ")
(veerev "4.0")
(platform "PC")
(execMode compatible)
(filterNAN 0)
(workspaceStackingOrder F1 F0 M)
(SaveCF no)
(device 0 ROOTCONTEXT
(properties
(trigMode deg)
(nextID 12)
(popupTitleText "Untitled")
(popupMoveable 1))
(deviceList
(UserFunctions
(nextID 2)
(context 0
(properties
(name "Calculate")
(trigMode deg)
(nextID 1)
(popupTitleText "Plus"))
(interface
(input 1
(name "A")
(optional yes))
(input 2
(name "B")
(optional yes))
(output 1
(type data)
(name "X")
(lock constraints)
(optional yes)))
(deviceList
(device 0 FORMULA
(properties
(expr 1 "A-B"))
(interface
(input 1
(name "A")
(optional yes))
(input 2
(name "B")
(optional yes))
(output 1
(name "Result")
(tag "Result")
(lock name constraints)
(optional yes))))
(configuration
(connect I1:1 D0:1)
(connect I2:1 D0:2)
(connect D0:1 O1:1)))
(contextCarrier
(wndOrigin 2 654)
(wndRestoredOrigin 42 42)
(wndRestoredExtent 269 132)
(wndState min)
(active detail)
(detail
(extent 269 132)
(anchorPt 122 66)
(configuration
(devCarrierFor 0
(active open)
(icon
(extent 57 0))
(open
(extent 72 42))
(terminals on)
(pinCenter -10 0))
(connect I1:1 D0:1
(points 4 -122 -41 -110 -41 -110 -10 -79 -10))
(connect I2:1 D0:2
(points 4 -122 39 -110 39 -110 10 -79 10))
(connect D0:1 O1:1
(points 4 78 0 112 0 112 -1 146 -1))))))
(context 1
(properties
(name "LIB2_Minus")
(trigMode deg)
(nextID 3)
(popupTitleText "plus3n6"))
(interface
(input 1
(name "B")
(optional yes))
(input 2
(name "A")
(optional yes))
(output 1
(type data)
(name "X")
(lock constraints)
(optional yes)))
(deviceList
(device 2 CALL
(properties
(name "Call Calculate")
(callFunc "Calculate")
(parmMode rev30))
(interface
(input 1
(name "A")
(optional yes))
(input 2
(name "B")
(optional yes))
(output 1
(name "X")
(lock name constraints)
(optional yes))))
(configuration
(connect I1:1 D0:1)
(connect I2:1 D0:2)
(connect D0:1 O1:1)))
(contextCarrier
(wndOrigin 162 654)
(wndRestoredOrigin 83 273)
(wndRestoredExtent 576 209)
(wndState min)
(active detail)
(detail
(extent 576 209)
(anchorPt 70 70)
(configuration
(devCarrierFor 2
(active open)
(icon
(extent 95 0))
(open
(extent 196 53))
(terminals on)
(pinCenter 240 30))
(connect I1:1 D0:1
(points 4 -70 -16 -60 -16 -60 20 109 20))
(connect I2:1 D0:2
(points 4 -70 84 -60 84 -60 40 109 40))
(connect D0:1 O1:1
(points 4 370 30 390 30 390 34 505 34)))))))
(device 6 CALL
(properties
(name "Call LIB2_Minus")
(callFunc "LIB2_Minus")
(parmMode rev30))
(interface
(input 1
(name "B")
(optional yes))
(input 2
(name "A")
(optional yes))
(output 1
(name "X")
(lock name constraints)
(optional yes))))
(device 7 START25)
(device 9 TEXTDISPLAY
(interface
(input 1
(name "Data"))))
(device 10 CONSTANT
(properties
(name "Integer"))
(interface
(output 1
(name "Int32")
(lock name constraints)))
(implementation
(value Int32
(data  3))
(initValue Int32
(data  0))))
(device 11 CONSTANT
(properties
(name "Integer"))
(interface
(output 1
(name "Int32")
(lock name constraints)))
(implementation
(value Int32
(data  6))
(initValue Int32
(data  0))))
(configuration
(connect D1:0 D0:0)
(connect D3:1 D0:1)
(connect D4:1 D0:2)
(connect D0:1 D2:1)))
(contextCarrier
(wndOrigin 2 2)
(wndState res)
(active detail)
(detail
(extent 946 328)
(anchorPt 342 217)
(configuration
(devCarrierFor 6
(active open)
(icon
(extent 111 0))
(open
(extent 196 53))
(terminals on)
(pinCenter 0 0))
(devCarrierFor 7
(active open)
(icon)
(open
(extent 47 22))
(title off)
(pinCenter 0 -80))
(devCarrierFor 9
(active open)
(icon)
(open
(extent 131 28))
(pinCenter 220 0))
(devCarrierFor 10
(active open)
(icon
(extent 48 16))
(open
(extent 84 30)
(showFormat int))
(pinCenter -210 -40))
(devCarrierFor 11
(active open)
(icon
(extent 48 16))
(open
(extent 84 30)
(showFormat int))
(pinCenter -210 30))
(connect D1:0 D0:0
(points 2 0 -67 0 -47))
(connect D3:1 D0:1
(points 4 -166 -40 -150 -40 -150 -10 -131 -10))
(connect D4:1 D0:2
(points 4 -166 30 -150 30 -150 10 -131 10))
(connect D0:1 D2:1
(points 2 130 0 152 0)))
(stackingOrder 2 1 4 3 0))
(numberFormats
(realFormat standard)
(realSigDigits 4)
(realRadixSpec 4)
(integerBase decimal))))

cut here-----------------------------------------------------------------------
Save this as C:DUMMYSAMENAME.vee --------------------------------------------

(saveFormat "2.3")
(date "Tue 20/May/1997 11:19:13 ")
(veerev "4.0")
(platform "PC")
(execMode compatible)
(filterNAN 0)
(workspaceStackingOrder M)
(SaveCF no)
(device 0 ROOTCONTEXT
(properties
(trigMode deg)
(nextID 16)
(popupTitleText "Untitled")
(popupMoveable 1))
(deviceList
(device 0 IMPORT
(properties
(name "Import LIB1")
(libType userFunction)
(libName "LIB1")
(fileName "c:\DUMMY\LIB1.VEE"))
(implementation))
(device 1 IMPORT
(properties
(name "Import LIB2")
(libType userFunction)
(libName "LIB2")
(fileName "c:\DUMMY\LIB2.VEE"))
(implementation))
(device 2 START25)
(device 3 CALL
(properties
(name "Call LIB1.LIB1_Plus")
(callFunc "LIB1.LIB1_Plus")
(parmMode rev30))
(interface
(input 1
(name "A")
(optional yes))
(input 2
(name "B")
(optional yes))
(output 1
(name "X")
(lock name constraints)
(optional yes))))
(device 5 TEXTDISPLAY
(interface
(input 1
(name "Data"))))
(device 6 CALL
(properties
(name "Call LIB2.LIB2_Minus")
(callFunc "LIB2.LIB2_Minus")
(parmMode rev30))
(interface
(input 1
(name "B")
(optional yes))
(input 2
(name "A")
(optional yes))
(output 1
(name "X")
(lock name constraints)
(optional yes))))
(device 7 TEXTDISPLAY
(interface
(input 1
(name "Data"))))
(device 8 CONSTANT
(properties
(name "Integer"))
(interface
(output 1
(name "Int32")
(lock name constraints)))
(implementation
(value Int32
(data  3))
(initValue Int32
(data  0))))
(device 9 CONSTANT
(properties
(name "Integer"))
(interface
(output 1
(name "Int32")
(lock name constraints)))
(implementation
(value Int32
(data  4))
(initValue Int32
(data  0))))
(configuration
(connect D2:0 D0:0)
(connect D0:0 D1:0)
(connect D1:0 D3:0)
(connect D7:1 D3:1)
(connect D8:1 D3:2)
(connect D3:1 D4:1)
(connect D3:0 D5:0)
(connect D7:1 D5:1)
(connect D8:1 D5:2)
(connect D5:1 D6:1)))
(contextCarrier
(wndOrigin 1 1)
(wndState res)
(active detail)
(detail
(extent 606 263)
(anchorPt 300 -29)
(configuration
(devCarrierFor 0
(active icon)
(icon
(extent 78 16))
(open
(extent 301 85))
(pinCenter 0 80))
(devCarrierFor 1
(active icon)
(icon
(extent 78 16))
(open
(extent 301 85))
(pinCenter 0 110))
(devCarrierFor 2
(active open)
(icon)
(open
(extent 47 22))
(title off)
(pinCenter 0 50))
(devCarrierFor 3
(active open)
(icon
(extent 135 0))
(open
(extent 196 53))
(terminals on)
(pinCenter 0 170))
(devCarrierFor 5
(active open)
(icon)
(open
(extent 131 28))
(pinCenter 220 170))
(devCarrierFor 6
(active open)
(icon
(extent 146 0))
(open
(extent 196 53))
(terminals on)
(pinCenter 0 250))
(devCarrierFor 7
(active open)
(icon)
(open
(extent 131 28))
(pinCenter 220 250))
(devCarrierFor 8
(active open)
(icon)
(open
(extent 84 30)
(showFormat int))
(pinCenter -240 160))
(devCarrierFor 9
(active open)
(icon)
(open
(extent 84 30)
(showFormat int))
(pinCenter -240 260))
(connect D2:0 D0:0
(points 2 0 63 0 69))
(connect D0:0 D1:0
(points 2 0 90 0 99))
(connect D1:0 D3:0
(points 2 0 120 0 123))
(connect D7:1 D3:1
(points 2 -196 160 -131 160))
(connect D8:1 D3:2
(points 4 -196 260 -170 260 -170 180 -131 180))
(connect D3:1 D4:1
(points 2 130 170 152 170))
(connect D3:0 D5:0
(points 2 0 199 0 203))
(connect D7:1 D5:1
(points 4 -196 160 -180 160 -180 240 -131 240))
(connect D8:1 D5:2
(points 2 -196 260 -131 260))
(connect D5:1 D6:1
(points 2 130 250 152 250)))
(stackingOrder 5 3 1 0 2 4 6 7 8))
(numberFormats
(realFormat standard)
(realSigDigits 4)
(realRadixSpec 4)
(integerBase decimal))))

cut here-----------------------------------------------------------------------
Best Regards !

PETER
----------------------------------------
Peter Larsson, T/RA-PL

Microwave Design
Saab Ericsson Space AB, S-40515 GOTEBORG, SWEDEN

Tel:            +46-31-335 44 15 
Fax:            +46-31-335 95 20
E-mail:         rapl@space.se
                         
http://www.combitech.se/combitspace.html
----------------------------------------

Outcomes