File: ex09intf.f

package info (click to toggle)
scilab 2.6-4
  • links: PTS
  • area: non-free
  • in suites: woody
  • size: 54,632 kB
  • ctags: 40,267
  • sloc: ansic: 267,851; fortran: 166,549; sh: 10,005; makefile: 4,119; tcl: 1,070; cpp: 233; csh: 143; asm: 135; perl: 130; java: 39
file content (136 lines) | stat: -rw-r--r-- 3,335 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
       subroutine intex9f1(fname)
c      --------------------------
c      Get a pointer to a Scilab variable with name "param"
       character*(*) fname
       logical checkrhs,checklhs
       include 'stack.h'
       logical cmatptr,createvar
c     
       minrhs = 0
       maxrhs = 0
       maxlhs = 1
       minlhs = 1
c     
       if(.not.checkrhs(fname,minrhs,maxrhs)) return
       if(.not.checklhs(fname,minlhs,maxlhs)) return
c     
c      get matrix ptr
c      param is m x n and param(1), param(2) ...
c      is equal to        stk(lp),  stk(lp+1), ...
       if(.not.cmatptr('param'//char(0),m,n,lp)) return 

c      Creating a Scilab variable (#1) of type double (matrix)
c      with m rows and n columns (l1 is the output of createvar).
       if(.not.createvar(1,'d',m,n,l1)) return
c 
c      Copy m*n entries from lp to l1:
c      stk(l1)=stk(lp), stk(l1+1)=stk(lp+1), ...    
       call dcopy(m*n,stk(lp),1,stk(l1),1)
       lhsvar(1)=1
       return
       end
c

      subroutine intex9f2(fname)
      include 'stack.h'
c  -------------------------------
c
c   Accessing the Scilab Stack :
c   Creation of a Scilab Matrix "C"
c   from a name and an array of data
c
      character*(*) fname
      logical cwritemat
      logical checklhs,checkrhs

      double precision C(3)

      minlhs=1
      maxlhs=1
      minrhs=0
      maxrhs=0

      if(.not.checkrhs(fname,minrhs,maxrhs)) return
      if(.not.checklhs(fname,minlhs,maxlhs)) return

      nrows=1
      ncols=3
      C(1)=10.0d0
      C(2)=20.0d0
      C(3)=30.0d0

c  Sending array C to Scilab as variable "C" (size [1,3]) 
      if(.not.cwritemat("C"//char(0), nrows, ncols, C)) return

c  No output
      lhsvar(1) = 0
      return
      end


      subroutine intex9f3(fname)
      include 'stack.h'
c ------------------------------------
      character*(*) fname
      logical creadchain
      logical checklhs,checkrhs
      character*(30) str
      character*(40) message
      integer strl
      strl=30

      minlhs=1
      minrhs=0
      maxlhs=1
      maxrhs=0

      if(.not.checkrhs(fname,minrhs,maxrhs)) return
      if(.not.checklhs(fname,minlhs,maxlhs)) return
c   We search a Scilab Object named Mystr, check that 
c   it is a string and store the string in str. 
c    strl is used on entry to give the maximum number 
c    of characters which can be stored in str 
c   After the call strl contains the number of 
c    copied characters
      if(.not.creadchain("Mystr"//char(0), strl, str)) return
c
      message="Mystr="//str(1:strl)//"  Its length is ..."
      call basout(io, wte, message)
c     No output
      lhsvar(1) = 0
      return
      end

      subroutine intex9f4(fname)
      include 'stack.h'
c ------------------------------------
      character*(*) fname
      logical checklhs, checkrhs, cwritechain
      character*(54) str
      integer strl
c
c   Creation of a Scilab variable Str of type string
c   from a name and an a Fortran string 

      minrhs=0
      maxrhs=0
      minlhs=1
      maxlhs=1
c
      if(.not.checkrhs(fname,minrhs,maxrhs)) return
      if(.not.checklhs(fname,minlhs,maxlhs)) return

      str='Pilgrim said he, where can it be this land of Eldorado'
      strl=len(str)
      if(.not.cwritechain('Str', strl, str)) return

c   No output
      lhsvar(1)=0
      return
      end