File: do_SaveAs.sci

package info (click to toggle)
scilab 2.4-1
  • links: PTS
  • area: non-free
  • in suites: potato, slink
  • size: 55,196 kB
  • ctags: 38,019
  • sloc: ansic: 231,970; fortran: 148,976; tcl: 7,099; makefile: 4,585; sh: 2,978; csh: 154; cpp: 101; asm: 39; sed: 5
file content (78 lines) | stat: -rw-r--r-- 1,509 bytes parent folder | download
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
function [scs_m,edited]=do_SaveAs()
//
// Copyright INRIA
tit=['For saving in binary file use .cos extension,';
    'for saving in ascii file use .cosf extension']
fname=xgetfile('*.cos*',emptystr(),tit)
if fname==emptystr() then return,end

[path,name,ext]=splitfilepath(fname)
select ext
case 'cos' then
  ok=%t
  frmt='unformatted'
case 'cosf' then
  ok=%t
  frmt='formatted'
else
  message('Only *.cos binary or cosf ascii files allowed');
  return
end


// open the selected file
[u,err]=file('open',fname,'unknown',frmt)
if err<>0 then
  message('Directory write access denied')
  return
end

if ~super_block&~pal_mode then
//update cpr data structure to make it coherent with last changes
if needcompile==4 then
  cpr=list()
else
  [cpr,state0,needcompile,ok]=do_update(cpr,state0,needcompile)
  if ~ok then return,end
  cpr(1)=state0
end
else
  cpr=list()
end

drawtitle(scs_m(1))  //erase the old title
scs_m;
scs_m(1)(2)=[name,path] // Change the title

// save
if ext=='cos' then
  save(u,scicos_ver,scs_m,cpr)
else
  disablemenus()

  errcatch(-1,'continue')

  write(u,sci2exp(scicos_ver,'scicos_ver'),'(a)')
  errcatch(-1)
    if iserror(-1)==1 then
    errclear(-1)
    x_message('Directory write access denied')
    file('close',u)
    return
    end
  cos2cosf(u,do_purge(scs_m))
  enablemenus()
end
file('close',u)

drawtitle(scs_m(1))  // draw the new title

edited=%f
if pal_mode then 
  graph=path+'/'+name+'.pal'
  xsave(graph)
  update_scicos_pal(path,scs_m(1)(2)(1),fname),
end