
$Regfile = "M103Def.dat"
$Crystal = 4000000
' Check XRAM enabled/disabled and XRAM Size if changing switch XRAMDrive; 1 needs 64kB XRAM enabled
' If use real card in PIN-Mode, you must disable XRAM !!!!!
Const XRAMDrive = 1                     ' 1 for XRAM Drive


Config Date = dmy , Separator = .
$Lib "DateTime.Lib"
config Clock = soft
Enable Interrupts


' Use Serial 0 for communication with PC-Terminal
$Baud = 9600

#IF XRAMDrive = 0
Config Serialin = buffered , Size = 20  ' do not use it in Simulator-terminal
#ENDIF

Open "Com1:" for Binary as #1


' Here you can include the Drive
#IF XRAMDrive = 0
$Include "CONFIG_FlashCardDrive.bas" ' use real card
'$Include "CONFIG_FlashCardDrive_EL_PIN.bas" ' use real card
#ELSE
$Include "CONFIG_XRAMDrive.bas"       ' simulate with "XRAM-Drive"
#ENDIF

$Include "CONFIG_AVR-DOS.Bas"

goto BehindIncludes

$Include "FS_SubFunc_Decl_lib.bas"
$Include "Interpreter.bas"

BehindIncludes:




' Init Port and Card

Print #1 , "Setup Port and Reset Card ... ";

if DriveCheck() = 0 then
   _Temp1 = DriveInit()
else
    print #1 , "Card not inserted, check Card!"
end if


Print #1 , "OK"
print #1 , "Ready for Commands"

print #1 , "Init File System ...  ";


Dim gbTemp1 as Byte                     ' scratch byte
gbTemp1 = 1                             ' Partition 1
gbTemp1 = InitFileSystem(gbTemp1)
if gbTemp1 > 0 then
   print #1 , "Error " ; gbTemp1
else
   print #1 , " OK"
endif


PrintPrompt
#if XRAMDrive = 1
   gosub INITFILES
#ENDIF

Dim gbInp as Byte                       ' holds user input

' Handling communication with user

gbPCInputPointer = 1

do
  gbInp = inkey(#1)                     ' get user input
  if gbInp <> 0 then                    ' something typed in?
      GetInput gbInp                    ' give input to interpreter
  end if
loop                                    ' do forever

End



InitFiles:
Dim Byte1 as Byte , Byte2 as Byte
date$ = "27.03.03"
time$ = "12:10:14"

Open "X1.txt" for Append as #Byte1
gsTestLine = "Zeile 1 in X1.txt 1"
print #Byte1 , gsTestLine
Close #Byte1

time$ = "12:11:16"
byte1 = Freefile()
Open "X2.txt" For Append as #Byte1
gsTestLine = "Zeile 1 in X2.txt 1 2 "
print #Byte1 , gsTestLine
Close #Byte1

time$ = "12:12:18"
byte1 = Freefile()
Open "X3.txt" for Append as #Byte1
gsTestLine = "Zeile 1 in X3.txt 1 2 3"
Print #Byte1 , gsTestLine
Close #Byte1


return


Print "hallo das ist ein teststring"
dim s1 as single , str1 as string * 20
print fusing(s1 , "#.####")
str1 = fusing(s1 , "#.###")