TriOS-alt/system/regnatix/copy.spin

202 lines
15 KiB
Plaintext
Raw Normal View History

2010-03-22 21:49:23 +01:00
<EFBFBD><EFBFBD>{{
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Autor: Ingo Kripahle %
% Copyright (c) 2010 Ingo Kripahle %
% See end of file for terms of use. %
% Die Nutzungsbedingungen befinden sich am Ende der Datei %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Informationen : hive-project.de
Kontakt : drohne235@googlemail.com
System : TriOS
Name : copy
Chip : Regnatix
Typ : Programm
Version : 00
Subversion : 01
Funktion : Externes Kommando "copy". Die Datei wird dabei in den eRAM eingelesen
und wieder mit neuem Namen geschrieben. Einfache Version: keine Speicherverwaltung,
es k<00>nnen nur Dateien kopiert werden, die in den verf<00>gbaren eRAM passen.
Logbuch :
13-03-2009-dr235 - erste version
22-03-2010-dr235 - anpassung trios
Kommandoliste:
copy <quelle> datei ---> eRAM
copy <quelle> <ziel> datei ---> datei
copy <quelle> <ziel> <parameter> datei ---> datei, parameter momentan unbenutzt
}}
OBJ
ios: "ios"
CON
_CLKMODE = XTAL1 + PLL16X
_XINFREQ = 5_000_000
PARALEN = 32
VAR
byte parastr1[PARALEN]
byte parastr2[PARALEN]
byte parastr3[PARALEN]
byte modus
long dlen 'dateil<00>nge
long count 'positionsz<00>hler
PUB main2 | i,n
' modus 0 keine aktion
' 1 von datei nach eram
' 2 von datei nach datei
ios.start
modus := 0 ' kopiermodus
ios.parastart
parastr1[0] := 0
parastr2[0] := 0
parastr3[0] := 0
rdpara1
if modus > 0 ' datei --> eram
rdfile
if modus == 2 ' eram --> datei
wrfile
ios.paradel
ios.stop
PUB rdfile | status,len,i,char,curpos
dlen := 0 'dateil<00>nge auf 0 setzen
len := ios#SYSVAR 'maximale dateigr<00><00>e
status := ios.sdopen("r",@parastr1) 'datei <00>ffnen
if status > 0 'fehler beim <00>ffnen der datei?
ios.print(@err2)
ios.printdec(status)
ios.printnl
if status == 0
ios.print(@msg5)
curpos := ios.curgetx 'cursorposition x merken
repeat i from 0 to len
char := ios.sdgetc
if ios.sdeof == 1 'eof erreicht?
quit
ios.ram_write(char,i)
dlen++
ios.cursetx(curpos) 'position setzen
ios.printdec(dlen)
ios.print(@msg9)
ios.sdclose
ios.print(@msg8)
ios.printnl
PUB wrfile | curpos,status,i,char
status := ios.sdopen("r",@parastr2) 'test ob datei vorhanden
ios.sdclose 'datei gleich wieder schlie<00>en
if status == 0 'datei ist schon vorhanden
ios.print(@msg7)
if ios.keywait <> "j"
modus := 0
ios.print(string("nein"))
ios.printnl
else
modus := 2
ios.print(string("ja"))
ios.printnl
if modus == 2
ios.print(@msg6)
curpos := ios.curgetx 'cursorposition x merken
status := ios.sdopen("w",@parastr2) 'datei <00>ffnen
if status > 0 'fehler beim <00>ffnen der datei?
ios.print(@err3)
ios.printdec(status)
ios.printnl
if status == 0
repeat i from 0 to dlen-1
char := ios.ram_read(i)
ios.sdputc(char)
ios.cursetx(curpos) 'position setzen
ios.printdec(i+1)
ios.print(@msg9)
ios.sdclose
ios.print(@msg8)
ios.printnl
PUB rdpara1
if ios.paranext(@parastr1) 'parameter quelldatei einlesen
ios.print(@msg1)
ios.print(@parastr1)
ios.printnl
rdpara2
rdpara3
else
ios.print(@err1)
ios.printnl
return
PUB rdpara2
if ios.paranext(@parastr2) 'parameter zieldatei einlesen
ios.print(@msg2)
ios.print(@parastr2)
ios.printnl
modus := 2
else
ios.print(@msg4)
ios.printnl
modus := 1
PUB rdpara3
if ios.paranext(@parastr3) 'parameter optionen einlesen
ios.print(@msg3)
ios.print(@parastr3)
ios.printnl
DAT
msg1 byte "Quelldatei : ", 0
msg2 byte "Zieldatei : ", 0
msg3 byte "Parameter : ", 0
msg4 byte "Kopiermodus: SD-Card --> eRAM",0
msg5 byte "Datei einlesen : ", 0
msg6 byte "Datei schreiben: ", 0
msg7 byte "Vorhandene Datei <00>berschreiben? <j/n> : ", 0
msg8 byte " ok ", 0
msg9 byte " Bytes ", 0
err1 byte "Keine Quelldatei angegeben!",13,0
err2 byte "Quelldatei kann nicht ge<00>ffnet werden! : ", 0
err3 byte "Zieldatei kann nicht ge<00>ffnet werden! : ", 0
err4 byte "Datei zu gro<00>!", 0
DAT
{{
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% TERMS OF USE: MIT License %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%$%
%Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation %
%files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, %
%modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software%
%is furnished to do so, subject to the following conditions: %
% %
%The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.%
% %
%THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE %
%WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR %
%COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, %
%ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
}}