home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 March / Chip_1998-03_cd.bin / tema / jpcad / MACRO / JPCAD.JM_ / JPCAD.JM
Text File  |  1998-01-21  |  4KB  |  183 lines

  1. $AMOEBA
  2.  
  3. ' COMMENTS:
  4. ' * Cannot use contants from ACC lib, you have to type them as numbers,
  5. ' and you have to type them as signed numbers!
  6. ' * Don't know how to exit in the middle of script, Goto not supported
  7.  
  8. '******************
  9. $COMMAND=handle
  10. $COMMENT=Get handle of entity
  11.  
  12. Option Explicit
  13.  
  14. DoIt ' Call the function
  15.  
  16. Private Sub DoIt
  17. Dim Point, Entity
  18.  
  19. If 2 <> ACCLib.GetEnt("Select entity", "", "", Entity, Point) Then
  20.     ACCLib.Prompt Chr(10) + "Bad selection"
  21.     Exit Sub
  22. End If
  23.  
  24. ACCLib.Prompt Chr(10) + "Handle is: 0x" + Hex(Entity)
  25. End Sub
  26.  
  27. '******************
  28. $COMMAND=highlite
  29. $COMMENT=Highlite entity with given handle
  30.  
  31. Option Explicit
  32.  
  33. DoIt ' Call the function
  34.  
  35. Private Sub DoIt
  36. Dim Handle, Dummy
  37.  
  38. If 2 <> ACCLib.GetLong("Entity handle (decimal)", "", "", Handle) Then
  39.     ACCLib.Prompt Chr(10) + "Bad handle"
  40.     Exit Sub
  41. End If
  42.  
  43. If 0 <> ACCLib.Draw(Handle, 2) Then
  44.     ACCLib.Prompt Chr(10) + "Bad handle"
  45.     Exit Sub
  46. End If
  47.  
  48. ACCLib.GetLong "Press enter to continue", "", "", Dummy
  49.  
  50. ACCLib.Draw Handle, 0
  51.  
  52. End Sub
  53.  
  54. '*******************
  55. $COMMAND=makeline
  56. $COMMENT=Create line
  57.  
  58. Option Explicit
  59.  
  60. DoIt ' Call the function
  61.  
  62. Private Sub DoIt
  63. Dim StartP, EndP, Line
  64.  
  65. If 2 <> ACCLib.GetPoint("Get start point", "", "", StartP) Then
  66.     ACCLib.Prompt Chr(10) + "Bad point"
  67.     Exit Sub
  68. End If
  69.  
  70. If 2 <> ACCLib.GetPoint("Get end point", "", "", EndP) Then
  71.     ACCLib.Prompt Chr(10) + "Bad point"
  72.     Exit Sub
  73. End If
  74.  
  75. ACCLib.LINE_Make StartP, EndP, -2147483645, -2147483645, -2147483645, 0.0, 0, Line
  76.  
  77. ACCLib.Prompt Chr(10) + "Handle of line: 0x" + Hex(Line)
  78. End Sub
  79.  
  80. '******************
  81. $COMMAND=getvar
  82. $COMMENT=Get value of any variable
  83. Option Explicit
  84.  
  85. DoIt ' Call the function
  86.  
  87. Private Sub DoIt
  88. Dim VarName, VarT, Variable, String
  89.  
  90. If 2 <> ACCLib.GetString("Variable name", "", VarName) Then
  91.     ACCLib.Prompt Chr(10) + "Bad name"
  92.     Exit Sub
  93. End If
  94.  
  95. If 0 > ACCLib.V_Get(VarName, VarT, Variable) Then
  96.     ACCLib.Prompt Chr(10) + "Variable doesn't exist"
  97.     Exit Sub
  98. End If
  99.  
  100. Select Case VarT
  101.     Case 1
  102.         String = "String: " + Variable
  103.     Case 2
  104.         String = "Double: " + CStr(Variable)
  105.     Case 3
  106.         String = "Integer: " + CStr(Variable)
  107.     Case 4
  108.         String = "Point: (" + CStr(Variable.x) + ", " + CStr(Variable.y) + ")"
  109.     Case Else
  110.         String = "Unknown"
  111. End Select
  112.  
  113. ACCLib.Prompt Chr(10) + String
  114.  
  115. End Sub
  116.  
  117. '*******************
  118. $COMMAND=graph
  119. $COMMENT=Draw graph
  120.  
  121. Option Explicit
  122.  
  123. DoIt ' Call the function
  124.  
  125. Private Sub DoIt
  126. Dim FromX, ToX, StepX, X, LastY, Result
  127. Dim StartP, EndP, OriginP
  128.  
  129. Set StartP = CreateObject("ACC.Point")
  130. Set EndP = CreateObject("ACC.Point")
  131. Set OriginP = CreateObject("ACC.Point")
  132.  
  133. Result = ACCLib.GetDouble("From x", "", "-10", FromX)
  134. If Result = 3 Then
  135.     FromX = -10.0
  136. ElseIf Result <> 2 Then
  137.     ACCLib.Prompt Chr(10) + "Bad value"
  138.     Exit Sub
  139. End If
  140.  
  141. Result = ACCLib.GetDouble("To x", "", "10", ToX)
  142. If Result = 3 Then
  143.     ToX = 10.0
  144. ElseIf Result <> 2 Then
  145.     ACCLib.Prompt Chr(10) + "Bad value"
  146.     Exit Sub
  147. End If
  148.  
  149. Result = ACCLib.GetDouble("Step", "", "0.1", StepX)
  150. If Result = 3 Then
  151.     StepX = 0.1
  152. ElseIf Result <> 2 Then
  153.     ACCLib.Prompt Chr(10) + "Bad value"
  154.     Exit Sub
  155. End If
  156.  
  157. Result= ACCLib.GetPoint("Origin", "", "0,0", OriginP)
  158. If Result = 3 Then
  159.     OriginP.x = 0.0
  160.     OriginP.y = 0.0
  161. ElseIf Result <> 2 Then
  162.     ACCLib.Prompt Chr(10) + "Bad value"
  163.     Exit Sub
  164. End If
  165.  
  166. StartP.x = OriginP.x + FromX
  167. StartP.y = OriginP.y + Func(FromX)
  168. For X = FromX+StepX To ToX Step StepX
  169.     Dim Line
  170.     EndP.x = X
  171.     EndP.y = Func(X)
  172.     EndP = ACCLib.G_AddVV(EndP, OriginP)
  173.     ACCLib.LINE_Make StartP, EndP, -2147483645, -2147483645, -2147483645, 0.0, 0, Line
  174.     StartP.x = EndP.x
  175.     StartP.y = EndP.y
  176. Next
  177.  
  178. End Sub
  179.  
  180. ' place your function here
  181. Private Function Func(X)
  182.     Func = Sin(X) * X
  183. End Function