<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.flowcode.co.uk/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Admin</id>
	<title>Flowcode Help - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://www.flowcode.co.uk/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Admin"/>
	<link rel="alternate" type="text/html" href="https://www.flowcode.co.uk/wiki/index.php?title=Special:Contributions/Admin"/>
	<updated>2026-05-06T03:15:05Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.34.1</generator>
	<entry>
		<id>https://www.flowcode.co.uk/wiki/index.php?title=File:ExternalCAN.jpg&amp;diff=14516</id>
		<title>File:ExternalCAN.jpg</title>
		<link rel="alternate" type="text/html" href="https://www.flowcode.co.uk/wiki/index.php?title=File:ExternalCAN.jpg&amp;diff=14516"/>
		<updated>2014-02-11T10:09:13Z</updated>

		<summary type="html">&lt;p&gt;Admin: Admin uploaded a new version of &amp;amp;quot;File:ExternalCAN.jpg&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://www.flowcode.co.uk/wiki/index.php?title=File:InternalCAN.jpg&amp;diff=14514</id>
		<title>File:InternalCAN.jpg</title>
		<link rel="alternate" type="text/html" href="https://www.flowcode.co.uk/wiki/index.php?title=File:InternalCAN.jpg&amp;diff=14514"/>
		<updated>2014-02-11T10:07:03Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://www.flowcode.co.uk/wiki/index.php?title=File:ExternalCAN.jpg&amp;diff=14515</id>
		<title>File:ExternalCAN.jpg</title>
		<link rel="alternate" type="text/html" href="https://www.flowcode.co.uk/wiki/index.php?title=File:ExternalCAN.jpg&amp;diff=14515"/>
		<updated>2014-02-11T10:07:03Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://www.flowcode.co.uk/wiki/index.php?title=File:CAN_High.jpg&amp;diff=14509</id>
		<title>File:CAN High.jpg</title>
		<link rel="alternate" type="text/html" href="https://www.flowcode.co.uk/wiki/index.php?title=File:CAN_High.jpg&amp;diff=14509"/>
		<updated>2014-02-11T10:01:32Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://www.flowcode.co.uk/wiki/index.php?title=File:CAN_Low.jpg&amp;diff=14510</id>
		<title>File:CAN Low.jpg</title>
		<link rel="alternate" type="text/html" href="https://www.flowcode.co.uk/wiki/index.php?title=File:CAN_Low.jpg&amp;diff=14510"/>
		<updated>2014-02-11T10:01:32Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://www.flowcode.co.uk/wiki/index.php?title=File:CAN_Demo.fcfx&amp;diff=14511</id>
		<title>File:CAN Demo.fcfx</title>
		<link rel="alternate" type="text/html" href="https://www.flowcode.co.uk/wiki/index.php?title=File:CAN_Demo.fcfx&amp;diff=14511"/>
		<updated>2014-02-11T10:01:32Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://www.flowcode.co.uk/wiki/index.php?title=File:CAN_DataFile.jpg&amp;diff=14507</id>
		<title>File:CAN DataFile.jpg</title>
		<link rel="alternate" type="text/html" href="https://www.flowcode.co.uk/wiki/index.php?title=File:CAN_DataFile.jpg&amp;diff=14507"/>
		<updated>2014-02-11T10:01:31Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://www.flowcode.co.uk/wiki/index.php?title=File:CAN_File.jpg&amp;diff=14508</id>
		<title>File:CAN File.jpg</title>
		<link rel="alternate" type="text/html" href="https://www.flowcode.co.uk/wiki/index.php?title=File:CAN_File.jpg&amp;diff=14508"/>
		<updated>2014-02-11T10:01:31Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://www.flowcode.co.uk/wiki/index.php?title=File:LCDConns.jpg&amp;diff=14481</id>
		<title>File:LCDConns.jpg</title>
		<link rel="alternate" type="text/html" href="https://www.flowcode.co.uk/wiki/index.php?title=File:LCDConns.jpg&amp;diff=14481"/>
		<updated>2014-01-30T17:31:12Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://www.flowcode.co.uk/wiki/index.php?title=File:FAT_Data_Logger_Fast.fcfx&amp;diff=14479</id>
		<title>File:FAT Data Logger Fast.fcfx</title>
		<link rel="alternate" type="text/html" href="https://www.flowcode.co.uk/wiki/index.php?title=File:FAT_Data_Logger_Fast.fcfx&amp;diff=14479"/>
		<updated>2014-01-30T17:18:19Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://www.flowcode.co.uk/wiki/index.php?title=Component:_File_(SD,_SDHC)_(Storage)&amp;diff=14478</id>
		<title>Component: File (SD, SDHC) (Storage)</title>
		<link rel="alternate" type="text/html" href="https://www.flowcode.co.uk/wiki/index.php?title=Component:_File_(SD,_SDHC)_(Storage)&amp;diff=14478"/>
		<updated>2014-01-30T17:17:33Z</updated>

		<summary type="html">&lt;p&gt;Admin: /* Examples */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{| width=&amp;quot;50%&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| width=&amp;quot;20%&amp;quot; style=&amp;quot;color: gray;&amp;quot; | Author&lt;br /&gt;
| Matrix Ltd.&lt;br /&gt;
|-&lt;br /&gt;
| width=&amp;quot;20%&amp;quot; style=&amp;quot;color: gray;&amp;quot; | Version&lt;br /&gt;
| 1.10&lt;br /&gt;
|-&lt;br /&gt;
| width=&amp;quot;20%&amp;quot; style=&amp;quot;color: gray;&amp;quot; | Category&lt;br /&gt;
| Storage&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==[[File:Component Icon 0b61bd39_05a3_46ee_a2a5_da7bffb583c5.png|Image]] FAT (SD, SDHC) component==&lt;br /&gt;
FAT component allowing access to read and write files on a SD, SDHC or MMC card.&lt;br /&gt;
&lt;br /&gt;
The component automatically detects the filesystem on the card on initialise so FAT16 and &lt;br /&gt;
FAT32 are fully supported.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
&lt;br /&gt;
===Reading data from a text file===&lt;br /&gt;
&lt;br /&gt;
Example to read a text file from a SD card or from a text file in simulation and display on a 16 x 2 character LCD. The text file needs to be in the same directory as the Flowcode .fcfx project file for the simulation to run correctly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Fcfile|FAT Read_File.fcfx|FAT Read File}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:test.txt]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Console showing current 512 byte sector data&lt;br /&gt;
&lt;br /&gt;
[[File:FatBuffer.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Console showing high level FAT status&lt;br /&gt;
&lt;br /&gt;
[[File:FatStatus.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Parsing a standard .BMP image file===&lt;br /&gt;
&lt;br /&gt;
Example to read a bitmap image file from a SD card or from a bitmap file in simulation and display on a graphical LCD. The bitmapfile needs to be in the same directory as the Flowcode .fcfx project file for the simulation to run correctly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Fcfile|GLCD_FAT_BMP.fcfx|FAT display Bitmap}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Demo bitmap files referenced in the example.&lt;br /&gt;
&lt;br /&gt;
[[File:FATDemoBitmaps.zip]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Picture showing a bitmap being displayed on a GLCD component.&lt;br /&gt;
&lt;br /&gt;
[[File:FatSimulatedBitmap.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Data logger Simple===&lt;br /&gt;
&lt;br /&gt;
Example showing how to take a collection of analogue readings and save them into a text based file, the simple way.&lt;br /&gt;
&lt;br /&gt;
{{Fcfile|FAT Data_Logger_Simple_Slow.fcfx|FAT data logger simple but slow}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Data logger Advanced===&lt;br /&gt;
&lt;br /&gt;
Example showing how to take a collection of analogue readings and save them into a text based file, the fast way.&lt;br /&gt;
&lt;br /&gt;
{{Fcfile|FAT Data_Logger_Fast.fcfx|FAT data logger fast}}&lt;br /&gt;
&lt;br /&gt;
==Downloadable macro reference==&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;ReadStringFromFile&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Reads a string from the currently open file. Auto increments the position in the file.&lt;br /&gt;
&lt;br /&gt;
An empty string signifies the end of the file has been reached.&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]] ''NumBytes''&lt;br /&gt;
::Maximum number of bytes to attempt to read&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]] ''EndChar''&lt;br /&gt;
::Ends the string if the value specified is found, default is 0&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|STRING]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;WriteByteToBuffer&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Writes a single byte to the current 512 byte local sector buffer.&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|UINT]] ''Address''&lt;br /&gt;
::Address Range 0 - 511&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]] ''Data''&lt;br /&gt;
::Data Byte to write to the buffer&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:''This call does not return a value''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;MoveToNextFileSector&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Attempts to move to the next sector in the file.&lt;br /&gt;
&lt;br /&gt;
When reading a file you would leave force next sector set to 0.&lt;br /&gt;
&lt;br /&gt;
When writing a file you would  leave force next sector set to 1 to allow new sectors to be created as the file grows.&lt;br /&gt;
&lt;br /&gt;
Returns 0 for success&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]] ''Force_Next_Sector''&lt;br /&gt;
::0 = Don't add new sector, 1 = Add new sector if we are at the end of the file&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;ReadFileSector&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Overwrites local buffer with the current file sector from the disk.&lt;br /&gt;
&lt;br /&gt;
Used to restore the local sector buffer with the actual sector stored on the card.&lt;br /&gt;
&lt;br /&gt;
Return = 0 : Local buffer refreshed with current card sector &lt;br /&gt;
&lt;br /&gt;
Return &amp;gt; 0 : Error&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:''This macro has no parameters''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;ReadByteFromFile&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Reads a byte from the currently open file. Auto increments the position in the file.&lt;br /&gt;
&lt;br /&gt;
A return value of 0 may signify the end of the file has been reached (depending on the contents of the file).&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:''This macro has no parameters''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;DeleteFile&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Searches for and deletes a file in the current folder location on the card. Default = Root&lt;br /&gt;
&lt;br /&gt;
Returns 0 for success.&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|&amp;lt;- STRING]] ''Filename''&lt;br /&gt;
::8.3 format filename e.g.&amp;quot;file.txt&amp;quot;&lt;br /&gt;
::''This parameter may be returned back to the caller''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;CreateFile&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Creates a file in the current folder location on the card. Default = Root&lt;br /&gt;
&lt;br /&gt;
Returns 0 for success&lt;br /&gt;
&lt;br /&gt;
File must be opened using &amp;quot;Open_File&amp;quot; after creation before writing any data.&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|&amp;lt;- STRING]] ''Filename''&lt;br /&gt;
::8.3 format filename e.g.&amp;quot;file.txt&amp;quot;&lt;br /&gt;
::''This parameter may be returned back to the caller''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;ScanCurrentFolder&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Method for retreiving file or folder names for the card to allow for dynamic file opening or playback. Does not currently simulate.&lt;br /&gt;
&lt;br /&gt;
0 - Filetype found and stored into string array, 1 - End of folder reached, 2 - Filetype mismatch 3 - Empty&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|UINT]] ''Current_Idx''&lt;br /&gt;
::Contains the current pointer in the directory table. Values from 0 to 511 to completley search the current folder for a files or folders&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]] ''Scan_Type''&lt;br /&gt;
::Sets the scan to search for Files or Folders. 0 = Scan for files, 1 = Scan for folders&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;ReadByteFromScan&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Returns a byte of the name of the file or folder retreived from the Scan_Current_folder function.&lt;br /&gt;
&lt;br /&gt;
Return = ASCII byte at position Idx from the folder name or file name at position Current_Idx in the directory&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]] ''idx''&lt;br /&gt;
::0 - 11 for a file, 0 - 7 for a folder&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;OpenFolder&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
&amp;quot;..&amp;quot; - Jumps up a directory, if at root then remains in root&lt;br /&gt;
&lt;br /&gt;
&amp;quot;root&amp;quot; - Jumps directly back to the root directory&lt;br /&gt;
&lt;br /&gt;
&amp;quot;foldername&amp;quot; - Opens folder named foldername&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|&amp;lt;- STRING]] ''Folder_Name''&lt;br /&gt;
::''This parameter may be returned back to the caller''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;ReadByteFromBuffer&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Reads a byte of data from the local sector buffer.&lt;br /&gt;
&lt;br /&gt;
Return = Data byte read from the local sector buffer.&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|UINT]] ''Address''&lt;br /&gt;
::0 - 511 - Contains the position of the byte to be read&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;ReadFileLength&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Returns the number of bytes in the current sector that are used by the current open file.&lt;br /&gt;
&lt;br /&gt;
Return = 512 - Sector is filled with file data&lt;br /&gt;
&lt;br /&gt;
Return &amp;lt; 512 - Last sector of the file, Retval specifies how many bytes of data are remaining in the sector&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:''This macro has no parameters''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|INT]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;OpenFile&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Searches for and opens a file for reading or writing from within the current directory on the disk.&lt;br /&gt;
&lt;br /&gt;
Returns 0 for success.&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|&amp;lt;- STRING]] ''Filename''&lt;br /&gt;
::8.3 filename of the file we are trying to open e.g. &amp;quot;file.txt&amp;quot;&lt;br /&gt;
::''This parameter may be returned back to the caller''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;WriteFileSector&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Overwrites the current sector on the memory card with the contents of the local sector buffer. See write_byte_to_buffer function.&lt;br /&gt;
&lt;br /&gt;
Return = 0 - File sector written successfully.&lt;br /&gt;
&lt;br /&gt;
Return &amp;gt; 0 - File sector write error&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:''This macro has no parameters''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;SetFileIndex&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Sets the current file index and used to switch between several open file streams. &lt;br /&gt;
&lt;br /&gt;
Default = 0.&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]] ''File_Index''&lt;br /&gt;
::File index ranges from 0 to (Max Concurrent Files - 1)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:''This call does not return a value''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;AppendStringToFile&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Adds the contents of the data string parameter to the end of the currently open file.&lt;br /&gt;
&lt;br /&gt;
Returns 0 for success.&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|&amp;lt;- STRING]] ''Data_String''&lt;br /&gt;
::Data to append to the end of the file&lt;br /&gt;
::''This parameter may be returned back to the caller''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;Initialise&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Attempts to communicate with the SD card and if successful sets up the file system.&lt;br /&gt;
&lt;br /&gt;
Returns 0 for success.&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:''This macro has no parameters''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Simulation macro reference==&lt;br /&gt;
&lt;br /&gt;
''This component does not contain any simulation macros''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Property reference==&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;Max Concurrent Files&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This property is of type ''Signed integer'' and can be referenced with the variable name ''max_concurrent_files''.&lt;br /&gt;
&lt;br /&gt;
Specifies how many concurrent files can be opened at any one time.&lt;br /&gt;
&lt;br /&gt;
Use the SetFileIndex macro to switch between concurrent files.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;Channel&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''Channel''.&lt;br /&gt;
&lt;br /&gt;
SPI communications channel&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;Prescaler&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''PR_SCALE''.&lt;br /&gt;
&lt;br /&gt;
SPI initial clock divider - Frequency should be under 400khz to allow startup to work&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;Chip Select - CS&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This property is of type ''Single digital pin'' and can be referenced with the variable name ''cs_pin''.&lt;br /&gt;
&lt;br /&gt;
Chip Select Pin for SPI&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;Data In - MISO / SDI&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This property is of type ''Single digital pin'' and can be referenced with the variable name ''miso_pin''.&lt;br /&gt;
&lt;br /&gt;
Data In SPI Pin&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;Data Out - MOSI / SDO&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This property is of type ''Single digital pin'' and can be referenced with the variable name ''mosi_pin''.&lt;br /&gt;
&lt;br /&gt;
Data Out SPI Pin&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;Serial Clock - SCK&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This property is of type ''Single digital pin'' and can be referenced with the variable name ''sck_pin''.&lt;br /&gt;
&lt;br /&gt;
Master Clock SPI pin&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;Root Directory&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This property is of type ''Directory'' and can be referenced with the variable name ''root_dir''.&lt;br /&gt;
&lt;br /&gt;
Directory flagged as root for simulation.&lt;br /&gt;
&lt;br /&gt;
Modern windows systems do not like you writing files to a hard drive root directory so a directory off the root is advised.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;Auto Insert Card&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This property is of type ''True or false'' and can be referenced with the variable name ''AutoInsertCard''.&lt;br /&gt;
&lt;br /&gt;
When set to yes the SD card will be automatically inserted at the start of simulation, &lt;br /&gt;
&lt;br /&gt;
Otherwise you must manually click the card on the panel to insert.&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://www.flowcode.co.uk/wiki/index.php?title=Component:_File_(SD,_SDHC)_(Storage)&amp;diff=14477</id>
		<title>Component: File (SD, SDHC) (Storage)</title>
		<link rel="alternate" type="text/html" href="https://www.flowcode.co.uk/wiki/index.php?title=Component:_File_(SD,_SDHC)_(Storage)&amp;diff=14477"/>
		<updated>2014-01-30T17:13:32Z</updated>

		<summary type="html">&lt;p&gt;Admin: /* Data logger Simple */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{| width=&amp;quot;50%&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| width=&amp;quot;20%&amp;quot; style=&amp;quot;color: gray;&amp;quot; | Author&lt;br /&gt;
| Matrix Ltd.&lt;br /&gt;
|-&lt;br /&gt;
| width=&amp;quot;20%&amp;quot; style=&amp;quot;color: gray;&amp;quot; | Version&lt;br /&gt;
| 1.10&lt;br /&gt;
|-&lt;br /&gt;
| width=&amp;quot;20%&amp;quot; style=&amp;quot;color: gray;&amp;quot; | Category&lt;br /&gt;
| Storage&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==[[File:Component Icon 0b61bd39_05a3_46ee_a2a5_da7bffb583c5.png|Image]] FAT (SD, SDHC) component==&lt;br /&gt;
FAT component allowing access to read and write files on a SD, SDHC or MMC card.&lt;br /&gt;
&lt;br /&gt;
The component automatically detects the filesystem on the card on initialise so FAT16 and &lt;br /&gt;
FAT32 are fully supported.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
&lt;br /&gt;
===Reading data from a text file===&lt;br /&gt;
&lt;br /&gt;
Example to read a text file from a SD card or from a text file in simulation and display on a 16 x 2 character LCD. The text file needs to be in the same directory as the Flowcode .fcfx project file for the simulation to run correctly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Fcfile|FAT Read_File.fcfx|FAT Read File}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:test.txt]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Console showing current 512 byte sector data&lt;br /&gt;
&lt;br /&gt;
[[File:FatBuffer.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Console showing high level FAT status&lt;br /&gt;
&lt;br /&gt;
[[File:FatStatus.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Parsing a standard .BMP image file===&lt;br /&gt;
&lt;br /&gt;
Example to read a bitmap image file from a SD card or from a bitmap file in simulation and display on a graphical LCD. The bitmapfile needs to be in the same directory as the Flowcode .fcfx project file for the simulation to run correctly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Fcfile|GLCD_FAT_BMP.fcfx|FAT display Bitmap}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Demo bitmap files referenced in the example.&lt;br /&gt;
&lt;br /&gt;
[[File:FATDemoBitmaps.zip]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Picture showing a bitmap being displayed on a GLCD component.&lt;br /&gt;
&lt;br /&gt;
[[File:FatSimulatedBitmap.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Data logger Simple===&lt;br /&gt;
&lt;br /&gt;
Example showing how to take a collection of analogue readings and save them into a text based file.&lt;br /&gt;
&lt;br /&gt;
[[File:FAT Sata_Logger_Simple_Slow]]&lt;br /&gt;
&lt;br /&gt;
===Data logger Advanced===&lt;br /&gt;
&lt;br /&gt;
==Downloadable macro reference==&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;ReadStringFromFile&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Reads a string from the currently open file. Auto increments the position in the file.&lt;br /&gt;
&lt;br /&gt;
An empty string signifies the end of the file has been reached.&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]] ''NumBytes''&lt;br /&gt;
::Maximum number of bytes to attempt to read&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]] ''EndChar''&lt;br /&gt;
::Ends the string if the value specified is found, default is 0&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|STRING]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;WriteByteToBuffer&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Writes a single byte to the current 512 byte local sector buffer.&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|UINT]] ''Address''&lt;br /&gt;
::Address Range 0 - 511&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]] ''Data''&lt;br /&gt;
::Data Byte to write to the buffer&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:''This call does not return a value''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;MoveToNextFileSector&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Attempts to move to the next sector in the file.&lt;br /&gt;
&lt;br /&gt;
When reading a file you would leave force next sector set to 0.&lt;br /&gt;
&lt;br /&gt;
When writing a file you would  leave force next sector set to 1 to allow new sectors to be created as the file grows.&lt;br /&gt;
&lt;br /&gt;
Returns 0 for success&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]] ''Force_Next_Sector''&lt;br /&gt;
::0 = Don't add new sector, 1 = Add new sector if we are at the end of the file&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;ReadFileSector&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Overwrites local buffer with the current file sector from the disk.&lt;br /&gt;
&lt;br /&gt;
Used to restore the local sector buffer with the actual sector stored on the card.&lt;br /&gt;
&lt;br /&gt;
Return = 0 : Local buffer refreshed with current card sector &lt;br /&gt;
&lt;br /&gt;
Return &amp;gt; 0 : Error&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:''This macro has no parameters''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;ReadByteFromFile&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Reads a byte from the currently open file. Auto increments the position in the file.&lt;br /&gt;
&lt;br /&gt;
A return value of 0 may signify the end of the file has been reached (depending on the contents of the file).&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:''This macro has no parameters''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;DeleteFile&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Searches for and deletes a file in the current folder location on the card. Default = Root&lt;br /&gt;
&lt;br /&gt;
Returns 0 for success.&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|&amp;lt;- STRING]] ''Filename''&lt;br /&gt;
::8.3 format filename e.g.&amp;quot;file.txt&amp;quot;&lt;br /&gt;
::''This parameter may be returned back to the caller''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;CreateFile&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Creates a file in the current folder location on the card. Default = Root&lt;br /&gt;
&lt;br /&gt;
Returns 0 for success&lt;br /&gt;
&lt;br /&gt;
File must be opened using &amp;quot;Open_File&amp;quot; after creation before writing any data.&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|&amp;lt;- STRING]] ''Filename''&lt;br /&gt;
::8.3 format filename e.g.&amp;quot;file.txt&amp;quot;&lt;br /&gt;
::''This parameter may be returned back to the caller''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;ScanCurrentFolder&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Method for retreiving file or folder names for the card to allow for dynamic file opening or playback. Does not currently simulate.&lt;br /&gt;
&lt;br /&gt;
0 - Filetype found and stored into string array, 1 - End of folder reached, 2 - Filetype mismatch 3 - Empty&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|UINT]] ''Current_Idx''&lt;br /&gt;
::Contains the current pointer in the directory table. Values from 0 to 511 to completley search the current folder for a files or folders&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]] ''Scan_Type''&lt;br /&gt;
::Sets the scan to search for Files or Folders. 0 = Scan for files, 1 = Scan for folders&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;ReadByteFromScan&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Returns a byte of the name of the file or folder retreived from the Scan_Current_folder function.&lt;br /&gt;
&lt;br /&gt;
Return = ASCII byte at position Idx from the folder name or file name at position Current_Idx in the directory&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]] ''idx''&lt;br /&gt;
::0 - 11 for a file, 0 - 7 for a folder&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;OpenFolder&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
&amp;quot;..&amp;quot; - Jumps up a directory, if at root then remains in root&lt;br /&gt;
&lt;br /&gt;
&amp;quot;root&amp;quot; - Jumps directly back to the root directory&lt;br /&gt;
&lt;br /&gt;
&amp;quot;foldername&amp;quot; - Opens folder named foldername&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|&amp;lt;- STRING]] ''Folder_Name''&lt;br /&gt;
::''This parameter may be returned back to the caller''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;ReadByteFromBuffer&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Reads a byte of data from the local sector buffer.&lt;br /&gt;
&lt;br /&gt;
Return = Data byte read from the local sector buffer.&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|UINT]] ''Address''&lt;br /&gt;
::0 - 511 - Contains the position of the byte to be read&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;ReadFileLength&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Returns the number of bytes in the current sector that are used by the current open file.&lt;br /&gt;
&lt;br /&gt;
Return = 512 - Sector is filled with file data&lt;br /&gt;
&lt;br /&gt;
Return &amp;lt; 512 - Last sector of the file, Retval specifies how many bytes of data are remaining in the sector&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:''This macro has no parameters''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|INT]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;OpenFile&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Searches for and opens a file for reading or writing from within the current directory on the disk.&lt;br /&gt;
&lt;br /&gt;
Returns 0 for success.&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|&amp;lt;- STRING]] ''Filename''&lt;br /&gt;
::8.3 filename of the file we are trying to open e.g. &amp;quot;file.txt&amp;quot;&lt;br /&gt;
::''This parameter may be returned back to the caller''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;WriteFileSector&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Overwrites the current sector on the memory card with the contents of the local sector buffer. See write_byte_to_buffer function.&lt;br /&gt;
&lt;br /&gt;
Return = 0 - File sector written successfully.&lt;br /&gt;
&lt;br /&gt;
Return &amp;gt; 0 - File sector write error&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:''This macro has no parameters''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;SetFileIndex&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Sets the current file index and used to switch between several open file streams. &lt;br /&gt;
&lt;br /&gt;
Default = 0.&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]] ''File_Index''&lt;br /&gt;
::File index ranges from 0 to (Max Concurrent Files - 1)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:''This call does not return a value''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;AppendStringToFile&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Adds the contents of the data string parameter to the end of the currently open file.&lt;br /&gt;
&lt;br /&gt;
Returns 0 for success.&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|&amp;lt;- STRING]] ''Data_String''&lt;br /&gt;
::Data to append to the end of the file&lt;br /&gt;
::''This parameter may be returned back to the caller''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;Initialise&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Attempts to communicate with the SD card and if successful sets up the file system.&lt;br /&gt;
&lt;br /&gt;
Returns 0 for success.&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:''This macro has no parameters''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Simulation macro reference==&lt;br /&gt;
&lt;br /&gt;
''This component does not contain any simulation macros''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Property reference==&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;Max Concurrent Files&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This property is of type ''Signed integer'' and can be referenced with the variable name ''max_concurrent_files''.&lt;br /&gt;
&lt;br /&gt;
Specifies how many concurrent files can be opened at any one time.&lt;br /&gt;
&lt;br /&gt;
Use the SetFileIndex macro to switch between concurrent files.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;Channel&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''Channel''.&lt;br /&gt;
&lt;br /&gt;
SPI communications channel&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;Prescaler&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''PR_SCALE''.&lt;br /&gt;
&lt;br /&gt;
SPI initial clock divider - Frequency should be under 400khz to allow startup to work&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;Chip Select - CS&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This property is of type ''Single digital pin'' and can be referenced with the variable name ''cs_pin''.&lt;br /&gt;
&lt;br /&gt;
Chip Select Pin for SPI&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;Data In - MISO / SDI&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This property is of type ''Single digital pin'' and can be referenced with the variable name ''miso_pin''.&lt;br /&gt;
&lt;br /&gt;
Data In SPI Pin&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;Data Out - MOSI / SDO&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This property is of type ''Single digital pin'' and can be referenced with the variable name ''mosi_pin''.&lt;br /&gt;
&lt;br /&gt;
Data Out SPI Pin&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;Serial Clock - SCK&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This property is of type ''Single digital pin'' and can be referenced with the variable name ''sck_pin''.&lt;br /&gt;
&lt;br /&gt;
Master Clock SPI pin&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;Root Directory&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This property is of type ''Directory'' and can be referenced with the variable name ''root_dir''.&lt;br /&gt;
&lt;br /&gt;
Directory flagged as root for simulation.&lt;br /&gt;
&lt;br /&gt;
Modern windows systems do not like you writing files to a hard drive root directory so a directory off the root is advised.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;Auto Insert Card&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This property is of type ''True or false'' and can be referenced with the variable name ''AutoInsertCard''.&lt;br /&gt;
&lt;br /&gt;
When set to yes the SD card will be automatically inserted at the start of simulation, &lt;br /&gt;
&lt;br /&gt;
Otherwise you must manually click the card on the panel to insert.&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://www.flowcode.co.uk/wiki/index.php?title=File:FAT_Read_File.fcfx&amp;diff=14476</id>
		<title>File:FAT Read File.fcfx</title>
		<link rel="alternate" type="text/html" href="https://www.flowcode.co.uk/wiki/index.php?title=File:FAT_Read_File.fcfx&amp;diff=14476"/>
		<updated>2014-01-30T17:10:14Z</updated>

		<summary type="html">&lt;p&gt;Admin: Admin uploaded a new version of &amp;amp;quot;File:FAT Read File.fcfx&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://www.flowcode.co.uk/wiki/index.php?title=Component:_File_(SD,_SDHC)_(Storage)&amp;diff=14475</id>
		<title>Component: File (SD, SDHC) (Storage)</title>
		<link rel="alternate" type="text/html" href="https://www.flowcode.co.uk/wiki/index.php?title=Component:_File_(SD,_SDHC)_(Storage)&amp;diff=14475"/>
		<updated>2014-01-30T17:05:48Z</updated>

		<summary type="html">&lt;p&gt;Admin: /* Examples */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{| width=&amp;quot;50%&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| width=&amp;quot;20%&amp;quot; style=&amp;quot;color: gray;&amp;quot; | Author&lt;br /&gt;
| Matrix Ltd.&lt;br /&gt;
|-&lt;br /&gt;
| width=&amp;quot;20%&amp;quot; style=&amp;quot;color: gray;&amp;quot; | Version&lt;br /&gt;
| 1.10&lt;br /&gt;
|-&lt;br /&gt;
| width=&amp;quot;20%&amp;quot; style=&amp;quot;color: gray;&amp;quot; | Category&lt;br /&gt;
| Storage&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==[[File:Component Icon 0b61bd39_05a3_46ee_a2a5_da7bffb583c5.png|Image]] FAT (SD, SDHC) component==&lt;br /&gt;
FAT component allowing access to read and write files on a SD, SDHC or MMC card.&lt;br /&gt;
&lt;br /&gt;
The component automatically detects the filesystem on the card on initialise so FAT16 and &lt;br /&gt;
FAT32 are fully supported.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
&lt;br /&gt;
===Reading data from a text file===&lt;br /&gt;
&lt;br /&gt;
Example to read a text file from a SD card or from a text file in simulation and display on a 16 x 2 character LCD. The text file needs to be in the same directory as the Flowcode .fcfx project file for the simulation to run correctly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Fcfile|FAT Read_File.fcfx|FAT Read File}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:test.txt]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Console showing current 512 byte sector data&lt;br /&gt;
&lt;br /&gt;
[[File:FatBuffer.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Console showing high level FAT status&lt;br /&gt;
&lt;br /&gt;
[[File:FatStatus.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Parsing a standard .BMP image file===&lt;br /&gt;
&lt;br /&gt;
Example to read a bitmap image file from a SD card or from a bitmap file in simulation and display on a graphical LCD. The bitmapfile needs to be in the same directory as the Flowcode .fcfx project file for the simulation to run correctly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Fcfile|GLCD_FAT_BMP.fcfx|FAT display Bitmap}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Demo bitmap files referenced in the example.&lt;br /&gt;
&lt;br /&gt;
[[File:FATDemoBitmaps.zip]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Picture showing a bitmap being displayed on a GLCD component.&lt;br /&gt;
&lt;br /&gt;
[[File:FatSimulatedBitmap.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Data logger Simple===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Data logger Advanced===&lt;br /&gt;
&lt;br /&gt;
==Downloadable macro reference==&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;ReadStringFromFile&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Reads a string from the currently open file. Auto increments the position in the file.&lt;br /&gt;
&lt;br /&gt;
An empty string signifies the end of the file has been reached.&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]] ''NumBytes''&lt;br /&gt;
::Maximum number of bytes to attempt to read&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]] ''EndChar''&lt;br /&gt;
::Ends the string if the value specified is found, default is 0&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|STRING]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;WriteByteToBuffer&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Writes a single byte to the current 512 byte local sector buffer.&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|UINT]] ''Address''&lt;br /&gt;
::Address Range 0 - 511&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]] ''Data''&lt;br /&gt;
::Data Byte to write to the buffer&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:''This call does not return a value''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;MoveToNextFileSector&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Attempts to move to the next sector in the file.&lt;br /&gt;
&lt;br /&gt;
When reading a file you would leave force next sector set to 0.&lt;br /&gt;
&lt;br /&gt;
When writing a file you would  leave force next sector set to 1 to allow new sectors to be created as the file grows.&lt;br /&gt;
&lt;br /&gt;
Returns 0 for success&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]] ''Force_Next_Sector''&lt;br /&gt;
::0 = Don't add new sector, 1 = Add new sector if we are at the end of the file&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;ReadFileSector&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Overwrites local buffer with the current file sector from the disk.&lt;br /&gt;
&lt;br /&gt;
Used to restore the local sector buffer with the actual sector stored on the card.&lt;br /&gt;
&lt;br /&gt;
Return = 0 : Local buffer refreshed with current card sector &lt;br /&gt;
&lt;br /&gt;
Return &amp;gt; 0 : Error&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:''This macro has no parameters''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;ReadByteFromFile&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Reads a byte from the currently open file. Auto increments the position in the file.&lt;br /&gt;
&lt;br /&gt;
A return value of 0 may signify the end of the file has been reached (depending on the contents of the file).&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:''This macro has no parameters''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;DeleteFile&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Searches for and deletes a file in the current folder location on the card. Default = Root&lt;br /&gt;
&lt;br /&gt;
Returns 0 for success.&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|&amp;lt;- STRING]] ''Filename''&lt;br /&gt;
::8.3 format filename e.g.&amp;quot;file.txt&amp;quot;&lt;br /&gt;
::''This parameter may be returned back to the caller''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;CreateFile&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Creates a file in the current folder location on the card. Default = Root&lt;br /&gt;
&lt;br /&gt;
Returns 0 for success&lt;br /&gt;
&lt;br /&gt;
File must be opened using &amp;quot;Open_File&amp;quot; after creation before writing any data.&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|&amp;lt;- STRING]] ''Filename''&lt;br /&gt;
::8.3 format filename e.g.&amp;quot;file.txt&amp;quot;&lt;br /&gt;
::''This parameter may be returned back to the caller''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;ScanCurrentFolder&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Method for retreiving file or folder names for the card to allow for dynamic file opening or playback. Does not currently simulate.&lt;br /&gt;
&lt;br /&gt;
0 - Filetype found and stored into string array, 1 - End of folder reached, 2 - Filetype mismatch 3 - Empty&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|UINT]] ''Current_Idx''&lt;br /&gt;
::Contains the current pointer in the directory table. Values from 0 to 511 to completley search the current folder for a files or folders&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]] ''Scan_Type''&lt;br /&gt;
::Sets the scan to search for Files or Folders. 0 = Scan for files, 1 = Scan for folders&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;ReadByteFromScan&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Returns a byte of the name of the file or folder retreived from the Scan_Current_folder function.&lt;br /&gt;
&lt;br /&gt;
Return = ASCII byte at position Idx from the folder name or file name at position Current_Idx in the directory&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]] ''idx''&lt;br /&gt;
::0 - 11 for a file, 0 - 7 for a folder&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;OpenFolder&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
&amp;quot;..&amp;quot; - Jumps up a directory, if at root then remains in root&lt;br /&gt;
&lt;br /&gt;
&amp;quot;root&amp;quot; - Jumps directly back to the root directory&lt;br /&gt;
&lt;br /&gt;
&amp;quot;foldername&amp;quot; - Opens folder named foldername&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|&amp;lt;- STRING]] ''Folder_Name''&lt;br /&gt;
::''This parameter may be returned back to the caller''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;ReadByteFromBuffer&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Reads a byte of data from the local sector buffer.&lt;br /&gt;
&lt;br /&gt;
Return = Data byte read from the local sector buffer.&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|UINT]] ''Address''&lt;br /&gt;
::0 - 511 - Contains the position of the byte to be read&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;ReadFileLength&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Returns the number of bytes in the current sector that are used by the current open file.&lt;br /&gt;
&lt;br /&gt;
Return = 512 - Sector is filled with file data&lt;br /&gt;
&lt;br /&gt;
Return &amp;lt; 512 - Last sector of the file, Retval specifies how many bytes of data are remaining in the sector&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:''This macro has no parameters''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|INT]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;OpenFile&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Searches for and opens a file for reading or writing from within the current directory on the disk.&lt;br /&gt;
&lt;br /&gt;
Returns 0 for success.&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|&amp;lt;- STRING]] ''Filename''&lt;br /&gt;
::8.3 filename of the file we are trying to open e.g. &amp;quot;file.txt&amp;quot;&lt;br /&gt;
::''This parameter may be returned back to the caller''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;WriteFileSector&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Overwrites the current sector on the memory card with the contents of the local sector buffer. See write_byte_to_buffer function.&lt;br /&gt;
&lt;br /&gt;
Return = 0 - File sector written successfully.&lt;br /&gt;
&lt;br /&gt;
Return &amp;gt; 0 - File sector write error&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:''This macro has no parameters''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;SetFileIndex&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Sets the current file index and used to switch between several open file streams. &lt;br /&gt;
&lt;br /&gt;
Default = 0.&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]] ''File_Index''&lt;br /&gt;
::File index ranges from 0 to (Max Concurrent Files - 1)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:''This call does not return a value''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;AppendStringToFile&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Adds the contents of the data string parameter to the end of the currently open file.&lt;br /&gt;
&lt;br /&gt;
Returns 0 for success.&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|&amp;lt;- STRING]] ''Data_String''&lt;br /&gt;
::Data to append to the end of the file&lt;br /&gt;
::''This parameter may be returned back to the caller''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;Initialise&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Attempts to communicate with the SD card and if successful sets up the file system.&lt;br /&gt;
&lt;br /&gt;
Returns 0 for success.&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:''This macro has no parameters''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Simulation macro reference==&lt;br /&gt;
&lt;br /&gt;
''This component does not contain any simulation macros''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Property reference==&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;Max Concurrent Files&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This property is of type ''Signed integer'' and can be referenced with the variable name ''max_concurrent_files''.&lt;br /&gt;
&lt;br /&gt;
Specifies how many concurrent files can be opened at any one time.&lt;br /&gt;
&lt;br /&gt;
Use the SetFileIndex macro to switch between concurrent files.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;Channel&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''Channel''.&lt;br /&gt;
&lt;br /&gt;
SPI communications channel&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;Prescaler&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''PR_SCALE''.&lt;br /&gt;
&lt;br /&gt;
SPI initial clock divider - Frequency should be under 400khz to allow startup to work&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;Chip Select - CS&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This property is of type ''Single digital pin'' and can be referenced with the variable name ''cs_pin''.&lt;br /&gt;
&lt;br /&gt;
Chip Select Pin for SPI&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;Data In - MISO / SDI&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This property is of type ''Single digital pin'' and can be referenced with the variable name ''miso_pin''.&lt;br /&gt;
&lt;br /&gt;
Data In SPI Pin&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;Data Out - MOSI / SDO&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This property is of type ''Single digital pin'' and can be referenced with the variable name ''mosi_pin''.&lt;br /&gt;
&lt;br /&gt;
Data Out SPI Pin&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;Serial Clock - SCK&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This property is of type ''Single digital pin'' and can be referenced with the variable name ''sck_pin''.&lt;br /&gt;
&lt;br /&gt;
Master Clock SPI pin&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;Root Directory&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This property is of type ''Directory'' and can be referenced with the variable name ''root_dir''.&lt;br /&gt;
&lt;br /&gt;
Directory flagged as root for simulation.&lt;br /&gt;
&lt;br /&gt;
Modern windows systems do not like you writing files to a hard drive root directory so a directory off the root is advised.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;Auto Insert Card&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This property is of type ''True or false'' and can be referenced with the variable name ''AutoInsertCard''.&lt;br /&gt;
&lt;br /&gt;
When set to yes the SD card will be automatically inserted at the start of simulation, &lt;br /&gt;
&lt;br /&gt;
Otherwise you must manually click the card on the panel to insert.&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://www.flowcode.co.uk/wiki/index.php?title=Component:_File_(SD,_SDHC)_(Storage)&amp;diff=14474</id>
		<title>Component: File (SD, SDHC) (Storage)</title>
		<link rel="alternate" type="text/html" href="https://www.flowcode.co.uk/wiki/index.php?title=Component:_File_(SD,_SDHC)_(Storage)&amp;diff=14474"/>
		<updated>2014-01-30T17:00:58Z</updated>

		<summary type="html">&lt;p&gt;Admin: /* Examples */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{| width=&amp;quot;50%&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| width=&amp;quot;20%&amp;quot; style=&amp;quot;color: gray;&amp;quot; | Author&lt;br /&gt;
| Matrix Ltd.&lt;br /&gt;
|-&lt;br /&gt;
| width=&amp;quot;20%&amp;quot; style=&amp;quot;color: gray;&amp;quot; | Version&lt;br /&gt;
| 1.10&lt;br /&gt;
|-&lt;br /&gt;
| width=&amp;quot;20%&amp;quot; style=&amp;quot;color: gray;&amp;quot; | Category&lt;br /&gt;
| Storage&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==[[File:Component Icon 0b61bd39_05a3_46ee_a2a5_da7bffb583c5.png|Image]] FAT (SD, SDHC) component==&lt;br /&gt;
FAT component allowing access to read and write files on a SD, SDHC or MMC card.&lt;br /&gt;
&lt;br /&gt;
The component automatically detects the filesystem on the card on initialise so FAT16 and &lt;br /&gt;
FAT32 are fully supported.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
&lt;br /&gt;
Example to read a text file from a SD card or from a text file in simulation and display on a 16 x 2 character LCD. The text file needs to be in the same directory as the Flowcode .fcfx project file for the simulation to run correctly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Fcfile|FAT Read_File.fcfx|FAT Read File}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:test.txt]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Console showing current 512 byte sector data&lt;br /&gt;
&lt;br /&gt;
[[File:FatBuffer.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Console showing high level FAT status&lt;br /&gt;
&lt;br /&gt;
[[File:FatStatus.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Example to read a bitmap image file from a SD card or from a bitmap file in simulation and display on a graphical LCD. The bitmapfile needs to be in the same directory as the Flowcode .fcfx project file for the simulation to run correctly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Fcfile|GLCD_FAT_BMP.fcfx|FAT display Bitmap}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Demo bitmap files referenced in the example.&lt;br /&gt;
&lt;br /&gt;
[[File:FATDemoBitmaps.zip]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Picture showing a bitmap being displayed on a GLCD component.&lt;br /&gt;
&lt;br /&gt;
[[File:FatSimulatedBitmap.jpg]]&lt;br /&gt;
&lt;br /&gt;
==Downloadable macro reference==&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;ReadStringFromFile&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Reads a string from the currently open file. Auto increments the position in the file.&lt;br /&gt;
&lt;br /&gt;
An empty string signifies the end of the file has been reached.&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]] ''NumBytes''&lt;br /&gt;
::Maximum number of bytes to attempt to read&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]] ''EndChar''&lt;br /&gt;
::Ends the string if the value specified is found, default is 0&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|STRING]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;WriteByteToBuffer&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Writes a single byte to the current 512 byte local sector buffer.&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|UINT]] ''Address''&lt;br /&gt;
::Address Range 0 - 511&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]] ''Data''&lt;br /&gt;
::Data Byte to write to the buffer&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:''This call does not return a value''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;MoveToNextFileSector&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Attempts to move to the next sector in the file.&lt;br /&gt;
&lt;br /&gt;
When reading a file you would leave force next sector set to 0.&lt;br /&gt;
&lt;br /&gt;
When writing a file you would  leave force next sector set to 1 to allow new sectors to be created as the file grows.&lt;br /&gt;
&lt;br /&gt;
Returns 0 for success&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]] ''Force_Next_Sector''&lt;br /&gt;
::0 = Don't add new sector, 1 = Add new sector if we are at the end of the file&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;ReadFileSector&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Overwrites local buffer with the current file sector from the disk.&lt;br /&gt;
&lt;br /&gt;
Used to restore the local sector buffer with the actual sector stored on the card.&lt;br /&gt;
&lt;br /&gt;
Return = 0 : Local buffer refreshed with current card sector &lt;br /&gt;
&lt;br /&gt;
Return &amp;gt; 0 : Error&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:''This macro has no parameters''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;ReadByteFromFile&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Reads a byte from the currently open file. Auto increments the position in the file.&lt;br /&gt;
&lt;br /&gt;
A return value of 0 may signify the end of the file has been reached (depending on the contents of the file).&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:''This macro has no parameters''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;DeleteFile&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Searches for and deletes a file in the current folder location on the card. Default = Root&lt;br /&gt;
&lt;br /&gt;
Returns 0 for success.&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|&amp;lt;- STRING]] ''Filename''&lt;br /&gt;
::8.3 format filename e.g.&amp;quot;file.txt&amp;quot;&lt;br /&gt;
::''This parameter may be returned back to the caller''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;CreateFile&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Creates a file in the current folder location on the card. Default = Root&lt;br /&gt;
&lt;br /&gt;
Returns 0 for success&lt;br /&gt;
&lt;br /&gt;
File must be opened using &amp;quot;Open_File&amp;quot; after creation before writing any data.&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|&amp;lt;- STRING]] ''Filename''&lt;br /&gt;
::8.3 format filename e.g.&amp;quot;file.txt&amp;quot;&lt;br /&gt;
::''This parameter may be returned back to the caller''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;ScanCurrentFolder&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Method for retreiving file or folder names for the card to allow for dynamic file opening or playback. Does not currently simulate.&lt;br /&gt;
&lt;br /&gt;
0 - Filetype found and stored into string array, 1 - End of folder reached, 2 - Filetype mismatch 3 - Empty&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|UINT]] ''Current_Idx''&lt;br /&gt;
::Contains the current pointer in the directory table. Values from 0 to 511 to completley search the current folder for a files or folders&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]] ''Scan_Type''&lt;br /&gt;
::Sets the scan to search for Files or Folders. 0 = Scan for files, 1 = Scan for folders&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;ReadByteFromScan&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Returns a byte of the name of the file or folder retreived from the Scan_Current_folder function.&lt;br /&gt;
&lt;br /&gt;
Return = ASCII byte at position Idx from the folder name or file name at position Current_Idx in the directory&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]] ''idx''&lt;br /&gt;
::0 - 11 for a file, 0 - 7 for a folder&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;OpenFolder&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
&amp;quot;..&amp;quot; - Jumps up a directory, if at root then remains in root&lt;br /&gt;
&lt;br /&gt;
&amp;quot;root&amp;quot; - Jumps directly back to the root directory&lt;br /&gt;
&lt;br /&gt;
&amp;quot;foldername&amp;quot; - Opens folder named foldername&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|&amp;lt;- STRING]] ''Folder_Name''&lt;br /&gt;
::''This parameter may be returned back to the caller''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;ReadByteFromBuffer&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Reads a byte of data from the local sector buffer.&lt;br /&gt;
&lt;br /&gt;
Return = Data byte read from the local sector buffer.&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|UINT]] ''Address''&lt;br /&gt;
::0 - 511 - Contains the position of the byte to be read&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;ReadFileLength&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Returns the number of bytes in the current sector that are used by the current open file.&lt;br /&gt;
&lt;br /&gt;
Return = 512 - Sector is filled with file data&lt;br /&gt;
&lt;br /&gt;
Return &amp;lt; 512 - Last sector of the file, Retval specifies how many bytes of data are remaining in the sector&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:''This macro has no parameters''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|INT]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;OpenFile&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Searches for and opens a file for reading or writing from within the current directory on the disk.&lt;br /&gt;
&lt;br /&gt;
Returns 0 for success.&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|&amp;lt;- STRING]] ''Filename''&lt;br /&gt;
::8.3 filename of the file we are trying to open e.g. &amp;quot;file.txt&amp;quot;&lt;br /&gt;
::''This parameter may be returned back to the caller''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;WriteFileSector&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Overwrites the current sector on the memory card with the contents of the local sector buffer. See write_byte_to_buffer function.&lt;br /&gt;
&lt;br /&gt;
Return = 0 - File sector written successfully.&lt;br /&gt;
&lt;br /&gt;
Return &amp;gt; 0 - File sector write error&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:''This macro has no parameters''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;SetFileIndex&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Sets the current file index and used to switch between several open file streams. &lt;br /&gt;
&lt;br /&gt;
Default = 0.&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]] ''File_Index''&lt;br /&gt;
::File index ranges from 0 to (Max Concurrent Files - 1)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:''This call does not return a value''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;AppendStringToFile&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Adds the contents of the data string parameter to the end of the currently open file.&lt;br /&gt;
&lt;br /&gt;
Returns 0 for success.&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|&amp;lt;- STRING]] ''Data_String''&lt;br /&gt;
::Data to append to the end of the file&lt;br /&gt;
::''This parameter may be returned back to the caller''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;Initialise&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Attempts to communicate with the SD card and if successful sets up the file system.&lt;br /&gt;
&lt;br /&gt;
Returns 0 for success.&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:''This macro has no parameters''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Simulation macro reference==&lt;br /&gt;
&lt;br /&gt;
''This component does not contain any simulation macros''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Property reference==&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;Max Concurrent Files&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This property is of type ''Signed integer'' and can be referenced with the variable name ''max_concurrent_files''.&lt;br /&gt;
&lt;br /&gt;
Specifies how many concurrent files can be opened at any one time.&lt;br /&gt;
&lt;br /&gt;
Use the SetFileIndex macro to switch between concurrent files.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;Channel&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''Channel''.&lt;br /&gt;
&lt;br /&gt;
SPI communications channel&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;Prescaler&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''PR_SCALE''.&lt;br /&gt;
&lt;br /&gt;
SPI initial clock divider - Frequency should be under 400khz to allow startup to work&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;Chip Select - CS&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This property is of type ''Single digital pin'' and can be referenced with the variable name ''cs_pin''.&lt;br /&gt;
&lt;br /&gt;
Chip Select Pin for SPI&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;Data In - MISO / SDI&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This property is of type ''Single digital pin'' and can be referenced with the variable name ''miso_pin''.&lt;br /&gt;
&lt;br /&gt;
Data In SPI Pin&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;Data Out - MOSI / SDO&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This property is of type ''Single digital pin'' and can be referenced with the variable name ''mosi_pin''.&lt;br /&gt;
&lt;br /&gt;
Data Out SPI Pin&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;Serial Clock - SCK&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This property is of type ''Single digital pin'' and can be referenced with the variable name ''sck_pin''.&lt;br /&gt;
&lt;br /&gt;
Master Clock SPI pin&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;Root Directory&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This property is of type ''Directory'' and can be referenced with the variable name ''root_dir''.&lt;br /&gt;
&lt;br /&gt;
Directory flagged as root for simulation.&lt;br /&gt;
&lt;br /&gt;
Modern windows systems do not like you writing files to a hard drive root directory so a directory off the root is advised.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;Auto Insert Card&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This property is of type ''True or false'' and can be referenced with the variable name ''AutoInsertCard''.&lt;br /&gt;
&lt;br /&gt;
When set to yes the SD card will be automatically inserted at the start of simulation, &lt;br /&gt;
&lt;br /&gt;
Otherwise you must manually click the card on the panel to insert.&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://www.flowcode.co.uk/wiki/index.php?title=File:FatBuffer.jpg&amp;diff=14472</id>
		<title>File:FatBuffer.jpg</title>
		<link rel="alternate" type="text/html" href="https://www.flowcode.co.uk/wiki/index.php?title=File:FatBuffer.jpg&amp;diff=14472"/>
		<updated>2014-01-30T17:00:17Z</updated>

		<summary type="html">&lt;p&gt;Admin: Admin uploaded a new version of &amp;amp;quot;File:FatBuffer.jpg&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://www.flowcode.co.uk/wiki/index.php?title=File:FatStatus.jpg&amp;diff=14473</id>
		<title>File:FatStatus.jpg</title>
		<link rel="alternate" type="text/html" href="https://www.flowcode.co.uk/wiki/index.php?title=File:FatStatus.jpg&amp;diff=14473"/>
		<updated>2014-01-30T17:00:17Z</updated>

		<summary type="html">&lt;p&gt;Admin: Admin uploaded a new version of &amp;amp;quot;File:FatStatus.jpg&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://www.flowcode.co.uk/wiki/index.php?title=File:FATDemoBitmaps.zip&amp;diff=14471</id>
		<title>File:FATDemoBitmaps.zip</title>
		<link rel="alternate" type="text/html" href="https://www.flowcode.co.uk/wiki/index.php?title=File:FATDemoBitmaps.zip&amp;diff=14471"/>
		<updated>2014-01-30T17:00:16Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://www.flowcode.co.uk/wiki/index.php?title=Component:_File_(SD,_SDHC)_(Storage)&amp;diff=14470</id>
		<title>Component: File (SD, SDHC) (Storage)</title>
		<link rel="alternate" type="text/html" href="https://www.flowcode.co.uk/wiki/index.php?title=Component:_File_(SD,_SDHC)_(Storage)&amp;diff=14470"/>
		<updated>2014-01-30T16:59:51Z</updated>

		<summary type="html">&lt;p&gt;Admin: /* Examples */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{| width=&amp;quot;50%&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| width=&amp;quot;20%&amp;quot; style=&amp;quot;color: gray;&amp;quot; | Author&lt;br /&gt;
| Matrix Ltd.&lt;br /&gt;
|-&lt;br /&gt;
| width=&amp;quot;20%&amp;quot; style=&amp;quot;color: gray;&amp;quot; | Version&lt;br /&gt;
| 1.10&lt;br /&gt;
|-&lt;br /&gt;
| width=&amp;quot;20%&amp;quot; style=&amp;quot;color: gray;&amp;quot; | Category&lt;br /&gt;
| Storage&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==[[File:Component Icon 0b61bd39_05a3_46ee_a2a5_da7bffb583c5.png|Image]] FAT (SD, SDHC) component==&lt;br /&gt;
FAT component allowing access to read and write files on a SD, SDHC or MMC card.&lt;br /&gt;
&lt;br /&gt;
The component automatically detects the filesystem on the card on initialise so FAT16 and &lt;br /&gt;
FAT32 are fully supported.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
&lt;br /&gt;
Example to read a text file from a SD card or from a text file in simulation and display on a 16 x 2 character LCD. The text file needs to be in the same directory as the Flowcode .fcfx project file for the simulation to run correctly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Fcfile|FAT Read_File.fcfx|FAT Read File}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:test.txt]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Console showing current 512 byte sector data&lt;br /&gt;
&lt;br /&gt;
[[File:FATBuffer.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Console showing high level FAT status&lt;br /&gt;
&lt;br /&gt;
[[File:FATStatus.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Example to read a bitmap image file from a SD card or from a bitmap file in simulation and display on a graphical LCD. The bitmapfile needs to be in the same directory as the Flowcode .fcfx project file for the simulation to run correctly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Fcfile|GLCD_FAT_BMP.fcfx|FAT display Bitmap}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Demo bitmap files referenced in the example.&lt;br /&gt;
&lt;br /&gt;
[[File:FATDemoBitmaps.zip]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Picture showing a bitmap being displayed on a GLCD component.&lt;br /&gt;
&lt;br /&gt;
[[File:FatSimulatedBitmap.jpg]]&lt;br /&gt;
&lt;br /&gt;
==Downloadable macro reference==&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;ReadStringFromFile&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Reads a string from the currently open file. Auto increments the position in the file.&lt;br /&gt;
&lt;br /&gt;
An empty string signifies the end of the file has been reached.&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]] ''NumBytes''&lt;br /&gt;
::Maximum number of bytes to attempt to read&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]] ''EndChar''&lt;br /&gt;
::Ends the string if the value specified is found, default is 0&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|STRING]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;WriteByteToBuffer&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Writes a single byte to the current 512 byte local sector buffer.&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|UINT]] ''Address''&lt;br /&gt;
::Address Range 0 - 511&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]] ''Data''&lt;br /&gt;
::Data Byte to write to the buffer&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:''This call does not return a value''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;MoveToNextFileSector&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Attempts to move to the next sector in the file.&lt;br /&gt;
&lt;br /&gt;
When reading a file you would leave force next sector set to 0.&lt;br /&gt;
&lt;br /&gt;
When writing a file you would  leave force next sector set to 1 to allow new sectors to be created as the file grows.&lt;br /&gt;
&lt;br /&gt;
Returns 0 for success&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]] ''Force_Next_Sector''&lt;br /&gt;
::0 = Don't add new sector, 1 = Add new sector if we are at the end of the file&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;ReadFileSector&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Overwrites local buffer with the current file sector from the disk.&lt;br /&gt;
&lt;br /&gt;
Used to restore the local sector buffer with the actual sector stored on the card.&lt;br /&gt;
&lt;br /&gt;
Return = 0 : Local buffer refreshed with current card sector &lt;br /&gt;
&lt;br /&gt;
Return &amp;gt; 0 : Error&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:''This macro has no parameters''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;ReadByteFromFile&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Reads a byte from the currently open file. Auto increments the position in the file.&lt;br /&gt;
&lt;br /&gt;
A return value of 0 may signify the end of the file has been reached (depending on the contents of the file).&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:''This macro has no parameters''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;DeleteFile&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Searches for and deletes a file in the current folder location on the card. Default = Root&lt;br /&gt;
&lt;br /&gt;
Returns 0 for success.&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|&amp;lt;- STRING]] ''Filename''&lt;br /&gt;
::8.3 format filename e.g.&amp;quot;file.txt&amp;quot;&lt;br /&gt;
::''This parameter may be returned back to the caller''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;CreateFile&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Creates a file in the current folder location on the card. Default = Root&lt;br /&gt;
&lt;br /&gt;
Returns 0 for success&lt;br /&gt;
&lt;br /&gt;
File must be opened using &amp;quot;Open_File&amp;quot; after creation before writing any data.&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|&amp;lt;- STRING]] ''Filename''&lt;br /&gt;
::8.3 format filename e.g.&amp;quot;file.txt&amp;quot;&lt;br /&gt;
::''This parameter may be returned back to the caller''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;ScanCurrentFolder&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Method for retreiving file or folder names for the card to allow for dynamic file opening or playback. Does not currently simulate.&lt;br /&gt;
&lt;br /&gt;
0 - Filetype found and stored into string array, 1 - End of folder reached, 2 - Filetype mismatch 3 - Empty&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|UINT]] ''Current_Idx''&lt;br /&gt;
::Contains the current pointer in the directory table. Values from 0 to 511 to completley search the current folder for a files or folders&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]] ''Scan_Type''&lt;br /&gt;
::Sets the scan to search for Files or Folders. 0 = Scan for files, 1 = Scan for folders&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;ReadByteFromScan&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Returns a byte of the name of the file or folder retreived from the Scan_Current_folder function.&lt;br /&gt;
&lt;br /&gt;
Return = ASCII byte at position Idx from the folder name or file name at position Current_Idx in the directory&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]] ''idx''&lt;br /&gt;
::0 - 11 for a file, 0 - 7 for a folder&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;OpenFolder&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
&amp;quot;..&amp;quot; - Jumps up a directory, if at root then remains in root&lt;br /&gt;
&lt;br /&gt;
&amp;quot;root&amp;quot; - Jumps directly back to the root directory&lt;br /&gt;
&lt;br /&gt;
&amp;quot;foldername&amp;quot; - Opens folder named foldername&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|&amp;lt;- STRING]] ''Folder_Name''&lt;br /&gt;
::''This parameter may be returned back to the caller''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;ReadByteFromBuffer&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Reads a byte of data from the local sector buffer.&lt;br /&gt;
&lt;br /&gt;
Return = Data byte read from the local sector buffer.&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|UINT]] ''Address''&lt;br /&gt;
::0 - 511 - Contains the position of the byte to be read&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;ReadFileLength&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Returns the number of bytes in the current sector that are used by the current open file.&lt;br /&gt;
&lt;br /&gt;
Return = 512 - Sector is filled with file data&lt;br /&gt;
&lt;br /&gt;
Return &amp;lt; 512 - Last sector of the file, Retval specifies how many bytes of data are remaining in the sector&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:''This macro has no parameters''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|INT]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;OpenFile&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Searches for and opens a file for reading or writing from within the current directory on the disk.&lt;br /&gt;
&lt;br /&gt;
Returns 0 for success.&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|&amp;lt;- STRING]] ''Filename''&lt;br /&gt;
::8.3 filename of the file we are trying to open e.g. &amp;quot;file.txt&amp;quot;&lt;br /&gt;
::''This parameter may be returned back to the caller''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;WriteFileSector&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Overwrites the current sector on the memory card with the contents of the local sector buffer. See write_byte_to_buffer function.&lt;br /&gt;
&lt;br /&gt;
Return = 0 - File sector written successfully.&lt;br /&gt;
&lt;br /&gt;
Return &amp;gt; 0 - File sector write error&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:''This macro has no parameters''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;SetFileIndex&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Sets the current file index and used to switch between several open file streams. &lt;br /&gt;
&lt;br /&gt;
Default = 0.&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]] ''File_Index''&lt;br /&gt;
::File index ranges from 0 to (Max Concurrent Files - 1)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:''This call does not return a value''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;AppendStringToFile&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Adds the contents of the data string parameter to the end of the currently open file.&lt;br /&gt;
&lt;br /&gt;
Returns 0 for success.&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|&amp;lt;- STRING]] ''Data_String''&lt;br /&gt;
::Data to append to the end of the file&lt;br /&gt;
::''This parameter may be returned back to the caller''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;Initialise&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Attempts to communicate with the SD card and if successful sets up the file system.&lt;br /&gt;
&lt;br /&gt;
Returns 0 for success.&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:''This macro has no parameters''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Simulation macro reference==&lt;br /&gt;
&lt;br /&gt;
''This component does not contain any simulation macros''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Property reference==&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;Max Concurrent Files&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This property is of type ''Signed integer'' and can be referenced with the variable name ''max_concurrent_files''.&lt;br /&gt;
&lt;br /&gt;
Specifies how many concurrent files can be opened at any one time.&lt;br /&gt;
&lt;br /&gt;
Use the SetFileIndex macro to switch between concurrent files.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;Channel&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''Channel''.&lt;br /&gt;
&lt;br /&gt;
SPI communications channel&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;Prescaler&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''PR_SCALE''.&lt;br /&gt;
&lt;br /&gt;
SPI initial clock divider - Frequency should be under 400khz to allow startup to work&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;Chip Select - CS&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This property is of type ''Single digital pin'' and can be referenced with the variable name ''cs_pin''.&lt;br /&gt;
&lt;br /&gt;
Chip Select Pin for SPI&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;Data In - MISO / SDI&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This property is of type ''Single digital pin'' and can be referenced with the variable name ''miso_pin''.&lt;br /&gt;
&lt;br /&gt;
Data In SPI Pin&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;Data Out - MOSI / SDO&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This property is of type ''Single digital pin'' and can be referenced with the variable name ''mosi_pin''.&lt;br /&gt;
&lt;br /&gt;
Data Out SPI Pin&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;Serial Clock - SCK&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This property is of type ''Single digital pin'' and can be referenced with the variable name ''sck_pin''.&lt;br /&gt;
&lt;br /&gt;
Master Clock SPI pin&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;Root Directory&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This property is of type ''Directory'' and can be referenced with the variable name ''root_dir''.&lt;br /&gt;
&lt;br /&gt;
Directory flagged as root for simulation.&lt;br /&gt;
&lt;br /&gt;
Modern windows systems do not like you writing files to a hard drive root directory so a directory off the root is advised.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;Auto Insert Card&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This property is of type ''True or false'' and can be referenced with the variable name ''AutoInsertCard''.&lt;br /&gt;
&lt;br /&gt;
When set to yes the SD card will be automatically inserted at the start of simulation, &lt;br /&gt;
&lt;br /&gt;
Otherwise you must manually click the card on the panel to insert.&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://www.flowcode.co.uk/wiki/index.php?title=File:Laser.bmp&amp;diff=14468</id>
		<title>File:Laser.bmp</title>
		<link rel="alternate" type="text/html" href="https://www.flowcode.co.uk/wiki/index.php?title=File:Laser.bmp&amp;diff=14468"/>
		<updated>2014-01-30T16:58:33Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://www.flowcode.co.uk/wiki/index.php?title=File:Dragon.bmp&amp;diff=14469</id>
		<title>File:Dragon.bmp</title>
		<link rel="alternate" type="text/html" href="https://www.flowcode.co.uk/wiki/index.php?title=File:Dragon.bmp&amp;diff=14469"/>
		<updated>2014-01-30T16:58:33Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://www.flowcode.co.uk/wiki/index.php?title=File:FatBuffer.jpg&amp;diff=14464</id>
		<title>File:FatBuffer.jpg</title>
		<link rel="alternate" type="text/html" href="https://www.flowcode.co.uk/wiki/index.php?title=File:FatBuffer.jpg&amp;diff=14464"/>
		<updated>2014-01-30T16:58:32Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://www.flowcode.co.uk/wiki/index.php?title=File:FatSimulatedBitmap.jpg&amp;diff=14465</id>
		<title>File:FatSimulatedBitmap.jpg</title>
		<link rel="alternate" type="text/html" href="https://www.flowcode.co.uk/wiki/index.php?title=File:FatSimulatedBitmap.jpg&amp;diff=14465"/>
		<updated>2014-01-30T16:58:32Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://www.flowcode.co.uk/wiki/index.php?title=File:FatStatus.jpg&amp;diff=14466</id>
		<title>File:FatStatus.jpg</title>
		<link rel="alternate" type="text/html" href="https://www.flowcode.co.uk/wiki/index.php?title=File:FatStatus.jpg&amp;diff=14466"/>
		<updated>2014-01-30T16:58:32Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://www.flowcode.co.uk/wiki/index.php?title=File:GLCD_FAT_BMP.fcfx&amp;diff=14467</id>
		<title>File:GLCD FAT BMP.fcfx</title>
		<link rel="alternate" type="text/html" href="https://www.flowcode.co.uk/wiki/index.php?title=File:GLCD_FAT_BMP.fcfx&amp;diff=14467"/>
		<updated>2014-01-30T16:58:32Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://www.flowcode.co.uk/wiki/index.php?title=Component:_File_(SD,_SDHC)_(Storage)&amp;diff=14463</id>
		<title>Component: File (SD, SDHC) (Storage)</title>
		<link rel="alternate" type="text/html" href="https://www.flowcode.co.uk/wiki/index.php?title=Component:_File_(SD,_SDHC)_(Storage)&amp;diff=14463"/>
		<updated>2014-01-30T16:57:00Z</updated>

		<summary type="html">&lt;p&gt;Admin: /* Examples */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{| width=&amp;quot;50%&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| width=&amp;quot;20%&amp;quot; style=&amp;quot;color: gray;&amp;quot; | Author&lt;br /&gt;
| Matrix Ltd.&lt;br /&gt;
|-&lt;br /&gt;
| width=&amp;quot;20%&amp;quot; style=&amp;quot;color: gray;&amp;quot; | Version&lt;br /&gt;
| 1.10&lt;br /&gt;
|-&lt;br /&gt;
| width=&amp;quot;20%&amp;quot; style=&amp;quot;color: gray;&amp;quot; | Category&lt;br /&gt;
| Storage&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==[[File:Component Icon 0b61bd39_05a3_46ee_a2a5_da7bffb583c5.png|Image]] FAT (SD, SDHC) component==&lt;br /&gt;
FAT component allowing access to read and write files on a SD, SDHC or MMC card.&lt;br /&gt;
&lt;br /&gt;
The component automatically detects the filesystem on the card on initialise so FAT16 and &lt;br /&gt;
FAT32 are fully supported.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
&lt;br /&gt;
Example to read a text file from a SD card or from a text file in simulation and display on a 16 x 2 character LCD. The text file needs to be in the same directory as the Flowcode .fcfx project file for the simulation to run correctly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Fcfile|FAT Read_File.fcfx|FAT Read File}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:test.txt]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Console showing current 512 byte sector data&lt;br /&gt;
&lt;br /&gt;
[[File:FATBuffer.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Console showing high level FAT status&lt;br /&gt;
&lt;br /&gt;
[[File:FATStatus.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Example to read a bitmap image file from a SD card or from a bitmap file in simulation and display on a graphical LCD. The bitmapfile needs to be in the same directory as the Flowcode .fcfx project file for the simulation to run correctly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Fcfile|GLCD_FAT_BMP.fcfx|FAT display Bitmap}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:dragon.bmp]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:laser.bmp]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Picture showing a bitmap being displayed on a GLCD component.&lt;br /&gt;
&lt;br /&gt;
[[File:FatSimulatedBitmap.jpg]]&lt;br /&gt;
&lt;br /&gt;
==Downloadable macro reference==&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;ReadStringFromFile&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Reads a string from the currently open file. Auto increments the position in the file.&lt;br /&gt;
&lt;br /&gt;
An empty string signifies the end of the file has been reached.&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]] ''NumBytes''&lt;br /&gt;
::Maximum number of bytes to attempt to read&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]] ''EndChar''&lt;br /&gt;
::Ends the string if the value specified is found, default is 0&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|STRING]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;WriteByteToBuffer&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Writes a single byte to the current 512 byte local sector buffer.&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|UINT]] ''Address''&lt;br /&gt;
::Address Range 0 - 511&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]] ''Data''&lt;br /&gt;
::Data Byte to write to the buffer&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:''This call does not return a value''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;MoveToNextFileSector&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Attempts to move to the next sector in the file.&lt;br /&gt;
&lt;br /&gt;
When reading a file you would leave force next sector set to 0.&lt;br /&gt;
&lt;br /&gt;
When writing a file you would  leave force next sector set to 1 to allow new sectors to be created as the file grows.&lt;br /&gt;
&lt;br /&gt;
Returns 0 for success&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]] ''Force_Next_Sector''&lt;br /&gt;
::0 = Don't add new sector, 1 = Add new sector if we are at the end of the file&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;ReadFileSector&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Overwrites local buffer with the current file sector from the disk.&lt;br /&gt;
&lt;br /&gt;
Used to restore the local sector buffer with the actual sector stored on the card.&lt;br /&gt;
&lt;br /&gt;
Return = 0 : Local buffer refreshed with current card sector &lt;br /&gt;
&lt;br /&gt;
Return &amp;gt; 0 : Error&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:''This macro has no parameters''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;ReadByteFromFile&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Reads a byte from the currently open file. Auto increments the position in the file.&lt;br /&gt;
&lt;br /&gt;
A return value of 0 may signify the end of the file has been reached (depending on the contents of the file).&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:''This macro has no parameters''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;DeleteFile&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Searches for and deletes a file in the current folder location on the card. Default = Root&lt;br /&gt;
&lt;br /&gt;
Returns 0 for success.&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|&amp;lt;- STRING]] ''Filename''&lt;br /&gt;
::8.3 format filename e.g.&amp;quot;file.txt&amp;quot;&lt;br /&gt;
::''This parameter may be returned back to the caller''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;CreateFile&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Creates a file in the current folder location on the card. Default = Root&lt;br /&gt;
&lt;br /&gt;
Returns 0 for success&lt;br /&gt;
&lt;br /&gt;
File must be opened using &amp;quot;Open_File&amp;quot; after creation before writing any data.&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|&amp;lt;- STRING]] ''Filename''&lt;br /&gt;
::8.3 format filename e.g.&amp;quot;file.txt&amp;quot;&lt;br /&gt;
::''This parameter may be returned back to the caller''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;ScanCurrentFolder&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Method for retreiving file or folder names for the card to allow for dynamic file opening or playback. Does not currently simulate.&lt;br /&gt;
&lt;br /&gt;
0 - Filetype found and stored into string array, 1 - End of folder reached, 2 - Filetype mismatch 3 - Empty&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|UINT]] ''Current_Idx''&lt;br /&gt;
::Contains the current pointer in the directory table. Values from 0 to 511 to completley search the current folder for a files or folders&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]] ''Scan_Type''&lt;br /&gt;
::Sets the scan to search for Files or Folders. 0 = Scan for files, 1 = Scan for folders&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;ReadByteFromScan&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Returns a byte of the name of the file or folder retreived from the Scan_Current_folder function.&lt;br /&gt;
&lt;br /&gt;
Return = ASCII byte at position Idx from the folder name or file name at position Current_Idx in the directory&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]] ''idx''&lt;br /&gt;
::0 - 11 for a file, 0 - 7 for a folder&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;OpenFolder&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
&amp;quot;..&amp;quot; - Jumps up a directory, if at root then remains in root&lt;br /&gt;
&lt;br /&gt;
&amp;quot;root&amp;quot; - Jumps directly back to the root directory&lt;br /&gt;
&lt;br /&gt;
&amp;quot;foldername&amp;quot; - Opens folder named foldername&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|&amp;lt;- STRING]] ''Folder_Name''&lt;br /&gt;
::''This parameter may be returned back to the caller''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;ReadByteFromBuffer&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Reads a byte of data from the local sector buffer.&lt;br /&gt;
&lt;br /&gt;
Return = Data byte read from the local sector buffer.&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|UINT]] ''Address''&lt;br /&gt;
::0 - 511 - Contains the position of the byte to be read&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;ReadFileLength&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Returns the number of bytes in the current sector that are used by the current open file.&lt;br /&gt;
&lt;br /&gt;
Return = 512 - Sector is filled with file data&lt;br /&gt;
&lt;br /&gt;
Return &amp;lt; 512 - Last sector of the file, Retval specifies how many bytes of data are remaining in the sector&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:''This macro has no parameters''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|INT]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;OpenFile&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Searches for and opens a file for reading or writing from within the current directory on the disk.&lt;br /&gt;
&lt;br /&gt;
Returns 0 for success.&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|&amp;lt;- STRING]] ''Filename''&lt;br /&gt;
::8.3 filename of the file we are trying to open e.g. &amp;quot;file.txt&amp;quot;&lt;br /&gt;
::''This parameter may be returned back to the caller''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;WriteFileSector&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Overwrites the current sector on the memory card with the contents of the local sector buffer. See write_byte_to_buffer function.&lt;br /&gt;
&lt;br /&gt;
Return = 0 - File sector written successfully.&lt;br /&gt;
&lt;br /&gt;
Return &amp;gt; 0 - File sector write error&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:''This macro has no parameters''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;SetFileIndex&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Sets the current file index and used to switch between several open file streams. &lt;br /&gt;
&lt;br /&gt;
Default = 0.&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]] ''File_Index''&lt;br /&gt;
::File index ranges from 0 to (Max Concurrent Files - 1)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:''This call does not return a value''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;AppendStringToFile&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Adds the contents of the data string parameter to the end of the currently open file.&lt;br /&gt;
&lt;br /&gt;
Returns 0 for success.&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|&amp;lt;- STRING]] ''Data_String''&lt;br /&gt;
::Data to append to the end of the file&lt;br /&gt;
::''This parameter may be returned back to the caller''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;&amp;lt;tt&amp;gt;Initialise&amp;lt;/tt&amp;gt;&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;===&lt;br /&gt;
Attempts to communicate with the SD card and if successful sets up the file system.&lt;br /&gt;
&lt;br /&gt;
Returns 0 for success.&lt;br /&gt;
&lt;br /&gt;
'''Parameters'''&lt;br /&gt;
&lt;br /&gt;
:''This macro has no parameters''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Return value'''&lt;br /&gt;
&lt;br /&gt;
:[[Variable Types|BYTE]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Simulation macro reference==&lt;br /&gt;
&lt;br /&gt;
''This component does not contain any simulation macros''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Property reference==&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;Max Concurrent Files&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This property is of type ''Signed integer'' and can be referenced with the variable name ''max_concurrent_files''.&lt;br /&gt;
&lt;br /&gt;
Specifies how many concurrent files can be opened at any one time.&lt;br /&gt;
&lt;br /&gt;
Use the SetFileIndex macro to switch between concurrent files.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;Channel&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''Channel''.&lt;br /&gt;
&lt;br /&gt;
SPI communications channel&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;Prescaler&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''PR_SCALE''.&lt;br /&gt;
&lt;br /&gt;
SPI initial clock divider - Frequency should be under 400khz to allow startup to work&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;Chip Select - CS&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This property is of type ''Single digital pin'' and can be referenced with the variable name ''cs_pin''.&lt;br /&gt;
&lt;br /&gt;
Chip Select Pin for SPI&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;Data In - MISO / SDI&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This property is of type ''Single digital pin'' and can be referenced with the variable name ''miso_pin''.&lt;br /&gt;
&lt;br /&gt;
Data In SPI Pin&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;Data Out - MOSI / SDO&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This property is of type ''Single digital pin'' and can be referenced with the variable name ''mosi_pin''.&lt;br /&gt;
&lt;br /&gt;
Data Out SPI Pin&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;Serial Clock - SCK&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This property is of type ''Single digital pin'' and can be referenced with the variable name ''sck_pin''.&lt;br /&gt;
&lt;br /&gt;
Master Clock SPI pin&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;Root Directory&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This property is of type ''Directory'' and can be referenced with the variable name ''root_dir''.&lt;br /&gt;
&lt;br /&gt;
Directory flagged as root for simulation.&lt;br /&gt;
&lt;br /&gt;
Modern windows systems do not like you writing files to a hard drive root directory so a directory off the root is advised.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-weight: normal;&amp;quot;&amp;gt;&amp;lt;u&amp;gt;Auto Insert Card&amp;lt;/u&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This property is of type ''True or false'' and can be referenced with the variable name ''AutoInsertCard''.&lt;br /&gt;
&lt;br /&gt;
When set to yes the SD card will be automatically inserted at the start of simulation, &lt;br /&gt;
&lt;br /&gt;
Otherwise you must manually click the card on the panel to insert.&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://www.flowcode.co.uk/wiki/index.php?title=File:SlaveComms.jpg&amp;diff=14462</id>
		<title>File:SlaveComms.jpg</title>
		<link rel="alternate" type="text/html" href="https://www.flowcode.co.uk/wiki/index.php?title=File:SlaveComms.jpg&amp;diff=14462"/>
		<updated>2014-01-30T15:12:43Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://www.flowcode.co.uk/wiki/index.php?title=File:USB_Slave_Driver.zip&amp;diff=14460</id>
		<title>File:USB Slave Driver.zip</title>
		<link rel="alternate" type="text/html" href="https://www.flowcode.co.uk/wiki/index.php?title=File:USB_Slave_Driver.zip&amp;diff=14460"/>
		<updated>2014-01-30T15:09:47Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://www.flowcode.co.uk/wiki/index.php?title=File:USBSlaveInstance.jpg&amp;diff=14455</id>
		<title>File:USBSlaveInstance.jpg</title>
		<link rel="alternate" type="text/html" href="https://www.flowcode.co.uk/wiki/index.php?title=File:USBSlaveInstance.jpg&amp;diff=14455"/>
		<updated>2014-01-30T15:08:32Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://www.flowcode.co.uk/wiki/index.php?title=File:USB_Slave_Sim.fcfx&amp;diff=14456</id>
		<title>File:USB Slave Sim.fcfx</title>
		<link rel="alternate" type="text/html" href="https://www.flowcode.co.uk/wiki/index.php?title=File:USB_Slave_Sim.fcfx&amp;diff=14456"/>
		<updated>2014-01-30T15:08:32Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://www.flowcode.co.uk/wiki/index.php?title=File:SlaveProps.jpg&amp;diff=14457</id>
		<title>File:SlaveProps.jpg</title>
		<link rel="alternate" type="text/html" href="https://www.flowcode.co.uk/wiki/index.php?title=File:SlaveProps.jpg&amp;diff=14457"/>
		<updated>2014-01-30T15:08:32Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://www.flowcode.co.uk/wiki/index.php?title=File:SlaveMacroSetup.jpg&amp;diff=14458</id>
		<title>File:SlaveMacroSetup.jpg</title>
		<link rel="alternate" type="text/html" href="https://www.flowcode.co.uk/wiki/index.php?title=File:SlaveMacroSetup.jpg&amp;diff=14458"/>
		<updated>2014-01-30T15:08:32Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://www.flowcode.co.uk/wiki/index.php?title=File:SlaveDevManager.jpg&amp;diff=14459</id>
		<title>File:SlaveDevManager.jpg</title>
		<link rel="alternate" type="text/html" href="https://www.flowcode.co.uk/wiki/index.php?title=File:SlaveDevManager.jpg&amp;diff=14459"/>
		<updated>2014-01-30T15:08:32Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://www.flowcode.co.uk/wiki/index.php?title=File:USB_Slave.fcfx&amp;diff=14454</id>
		<title>File:USB Slave.fcfx</title>
		<link rel="alternate" type="text/html" href="https://www.flowcode.co.uk/wiki/index.php?title=File:USB_Slave.fcfx&amp;diff=14454"/>
		<updated>2014-01-30T15:08:31Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://www.flowcode.co.uk/wiki/index.php?title=File:USB_Serial_Sim.fcfx&amp;diff=14450</id>
		<title>File:USB Serial Sim.fcfx</title>
		<link rel="alternate" type="text/html" href="https://www.flowcode.co.uk/wiki/index.php?title=File:USB_Serial_Sim.fcfx&amp;diff=14450"/>
		<updated>2014-01-30T12:30:26Z</updated>

		<summary type="html">&lt;p&gt;Admin: Admin uploaded a new version of &amp;amp;quot;File:USB Serial Sim.fcfx&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://www.flowcode.co.uk/wiki/index.php?title=File:USB_Serial.fcfx&amp;diff=14451</id>
		<title>File:USB Serial.fcfx</title>
		<link rel="alternate" type="text/html" href="https://www.flowcode.co.uk/wiki/index.php?title=File:USB_Serial.fcfx&amp;diff=14451"/>
		<updated>2014-01-30T12:30:26Z</updated>

		<summary type="html">&lt;p&gt;Admin: Admin uploaded a new version of &amp;amp;quot;File:USB Serial.fcfx&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://www.flowcode.co.uk/wiki/index.php?title=File:SerialComms.jpg&amp;diff=14448</id>
		<title>File:SerialComms.jpg</title>
		<link rel="alternate" type="text/html" href="https://www.flowcode.co.uk/wiki/index.php?title=File:SerialComms.jpg&amp;diff=14448"/>
		<updated>2014-01-30T12:28:54Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://www.flowcode.co.uk/wiki/index.php?title=File:SerialProps.jpg&amp;diff=14449</id>
		<title>File:SerialProps.jpg</title>
		<link rel="alternate" type="text/html" href="https://www.flowcode.co.uk/wiki/index.php?title=File:SerialProps.jpg&amp;diff=14449"/>
		<updated>2014-01-30T12:28:54Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://www.flowcode.co.uk/wiki/index.php?title=File:DeviceManager.jpg&amp;diff=14447</id>
		<title>File:DeviceManager.jpg</title>
		<link rel="alternate" type="text/html" href="https://www.flowcode.co.uk/wiki/index.php?title=File:DeviceManager.jpg&amp;diff=14447"/>
		<updated>2014-01-30T12:28:53Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://www.flowcode.co.uk/wiki/index.php?title=File:USB_Serial.fcfx&amp;diff=14444</id>
		<title>File:USB Serial.fcfx</title>
		<link rel="alternate" type="text/html" href="https://www.flowcode.co.uk/wiki/index.php?title=File:USB_Serial.fcfx&amp;diff=14444"/>
		<updated>2014-01-30T12:19:34Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://www.flowcode.co.uk/wiki/index.php?title=File:USB_Serial_Sim.fcfx&amp;diff=14445</id>
		<title>File:USB Serial Sim.fcfx</title>
		<link rel="alternate" type="text/html" href="https://www.flowcode.co.uk/wiki/index.php?title=File:USB_Serial_Sim.fcfx&amp;diff=14445"/>
		<updated>2014-01-30T12:19:34Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://www.flowcode.co.uk/wiki/index.php?title=Simulation_Events&amp;diff=14399</id>
		<title>Simulation Events</title>
		<link rel="alternate" type="text/html" href="https://www.flowcode.co.uk/wiki/index.php?title=Simulation_Events&amp;diff=14399"/>
		<updated>2014-01-24T09:15:31Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;sidebar&amp;gt;Sidebar: What Is a Macro?&amp;lt;/sidebar&amp;gt;&lt;br /&gt;
[[File:ProjectExplorerEventsTab.jpg|right]]&lt;br /&gt;
A Flowcode simulation event is similar to an [[Interrupt Icon Properties|Interrupt]] but aimed at performing a specific job. The events will not be referenced at all for downloaded microcontroller code but may be used in the generation of such code.&lt;br /&gt;
&lt;br /&gt;
Another key difference between events and interrupts is that events can occur at any time whereas interrupts can only occur whilst the simulation is running.&lt;br /&gt;
&lt;br /&gt;
===Event Management===&lt;br /&gt;
The [[Project Explorer]] events tab is used to list all the available events and provides a quick way of seeing which events are active in your Flowcode project.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When an event is active a small macro icon will appear next to the event. &lt;br /&gt;
&lt;br /&gt;
By hovering over the events you can see a short description of when the event will be called and what parameters will be passed to it.&lt;br /&gt;
&lt;br /&gt;
By double clicking the event you can edit the macro assigned to it. Double clicking the macro item will automatically add an event macro for you with a name specific to the event name. Selecting disabled will deactivate the event and prevent it from firing.&lt;br /&gt;
&lt;br /&gt;
Each event macro will have a return variable which may or may not be used internally by Flowcode, refer to the event description for specific details.&lt;br /&gt;
&lt;br /&gt;
The [[Component Debugger]] window has a option to log events as they are fired which is useful for debugging purposes.&lt;br /&gt;
&lt;br /&gt;
Full details surrounding each of the events in Flowcode can be found here [[Event_Reference]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Video instructions===&lt;br /&gt;
The [http://www.youtube.com/watch?v=DflA2gULQuw&amp;amp;list=PLQDWBb7bxuCgg6aJgPJcfXBMzZdLILceQ&amp;amp;index=26 Simulation Events] video consists of an overview of the simulation events and a demonstration of the [[Event Mouse.Click|Mouse.Click]] event by creating the macro Ev_Click event macro and using a [[Simulation Macro Icon Properties|Simulation Macro]] to change the colour of an object.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
{{#ev:youtube|DflA2gULQuw|640}}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://www.flowcode.co.uk/wiki/index.php?title=File:GetVarSizeEvent.jpg&amp;diff=14385</id>
		<title>File:GetVarSizeEvent.jpg</title>
		<link rel="alternate" type="text/html" href="https://www.flowcode.co.uk/wiki/index.php?title=File:GetVarSizeEvent.jpg&amp;diff=14385"/>
		<updated>2014-01-23T16:36:48Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://www.flowcode.co.uk/wiki/index.php?title=File:GetVarSizeMacro.jpg&amp;diff=14386</id>
		<title>File:GetVarSizeMacro.jpg</title>
		<link rel="alternate" type="text/html" href="https://www.flowcode.co.uk/wiki/index.php?title=File:GetVarSizeMacro.jpg&amp;diff=14386"/>
		<updated>2014-01-23T16:36:48Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://www.flowcode.co.uk/wiki/index.php?title=File:GetVarSize.fcfx&amp;diff=14384</id>
		<title>File:GetVarSize.fcfx</title>
		<link rel="alternate" type="text/html" href="https://www.flowcode.co.uk/wiki/index.php?title=File:GetVarSize.fcfx&amp;diff=14384"/>
		<updated>2014-01-23T16:36:47Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://www.flowcode.co.uk/wiki/index.php?title=Event_Compile.GetVarSize&amp;diff=14383</id>
		<title>Event Compile.GetVarSize</title>
		<link rel="alternate" type="text/html" href="https://www.flowcode.co.uk/wiki/index.php?title=Event_Compile.GetVarSize&amp;diff=14383"/>
		<updated>2014-01-23T16:36:09Z</updated>

		<summary type="html">&lt;p&gt;Admin: /* Examples */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;sidebar&amp;gt;Event Contents&amp;lt;/sidebar&amp;gt;&lt;br /&gt;
Sent to a component to amend the size of the expected array&lt;br /&gt;
&lt;br /&gt;
This event is part of the [[Event class Compile|Compile]] class&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
[[Variable Types|STRING]] ''VarName''&lt;br /&gt;
:The original Flowcode variable&lt;br /&gt;
&lt;br /&gt;
[[Variable Types|ULONG]] ''Elements''&lt;br /&gt;
:The number of elements in the array&lt;br /&gt;
:''This parameter is returned back to Flowcode''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Return value==&lt;br /&gt;
[[Variable Types|ULONG]]&lt;br /&gt;
The return of this event is currently unused&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Detailed description==&lt;br /&gt;
''&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;No additional information&amp;lt;/span&amp;gt;''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
&lt;br /&gt;
On some microcontroller devices there are sometimes limitation on the size of a single data array or other reasons to adjust the size of a variable based on a set of parameters etc.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For example if we try and create an array of size bigger then 256 bytes then this will cause a compilation error.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''#define FCVsz_DATAARRAY 500'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''GetVarSize.c(53): error: total number of array elements can not exceed 0x100'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
By enabling the GetVarSizeevent we can override the number of elements in the array.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:GetVarSizeEvent.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Inside the event macro we check for the name of the variable with the size we want to override and overwrite the .Elements local variable to edit the array size.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:GetVarSizeMacro.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After saving the project and refreshing the C code window the variable now looks like this.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''#define FCVsz_DATAARRAY 255'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
And during compilation we now get this.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''success'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here is the file as a demonstration. &lt;br /&gt;
&lt;br /&gt;
{{Fcfile|GetVarSize.fcfx|Get Var Size Event Example}}&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://www.flowcode.co.uk/wiki/index.php?title=File:FarMem.jpg&amp;diff=14381</id>
		<title>File:FarMem.jpg</title>
		<link rel="alternate" type="text/html" href="https://www.flowcode.co.uk/wiki/index.php?title=File:FarMem.jpg&amp;diff=14381"/>
		<updated>2014-01-22T16:40:02Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://www.flowcode.co.uk/wiki/index.php?title=Event_Compile.AddVar&amp;diff=14380</id>
		<title>Event Compile.AddVar</title>
		<link rel="alternate" type="text/html" href="https://www.flowcode.co.uk/wiki/index.php?title=Event_Compile.AddVar&amp;diff=14380"/>
		<updated>2014-01-22T16:39:45Z</updated>

		<summary type="html">&lt;p&gt;Admin: /* Examples */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;sidebar&amp;gt;Event Contents&amp;lt;/sidebar&amp;gt;&lt;br /&gt;
Sent to a component to allow dynamic amendment of global constant declarations&lt;br /&gt;
&lt;br /&gt;
This event is part of the [[Event class Compile|Compile]] class&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
[[Variable Types|STRING]] ''VarName''&lt;br /&gt;
:The original Flowcode variable&lt;br /&gt;
&lt;br /&gt;
[[Variable Types|STRING]] ''ExpandName''&lt;br /&gt;
:The expanded variable name&lt;br /&gt;
&lt;br /&gt;
[[Variable Types|STRING]] ''Expansion''&lt;br /&gt;
:The expanded string to inline to the code&lt;br /&gt;
:''This parameter is returned back to Flowcode''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Return value==&lt;br /&gt;
[[Variable Types|ULONG]]&lt;br /&gt;
Non-zero to include definition - initialised on call&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Detailed description==&lt;br /&gt;
''&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;No additional information&amp;lt;/span&amp;gt;''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On some PIC devices there are sometimes two types of RAM memory due to bus limitations, near and far. Near memory is fast to access but is limited by the size of the internal bus. Far memory is much less limited but means additional overhead when fetching or storing values.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:FarMem.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When creating Flowcode variables these will default to being stored in near memory to optimise the time to fetch and store values. If you run out of room in near memory then you may get a message like this during compilation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''C:\Users\BenR\Desktop\FarMem.o: Link Error: Could not allocate section .nbss, size = 4118 bytes, attributes = bss near''' &lt;br /&gt;
&lt;br /&gt;
'''Link Error: Could not allocate data memory'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To tell the compiler to move the variable into FAR memory in C you would do something like this.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''__attribute__((far)) unsigned char data[4096];'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Flowcode variable defaults to something like this.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''MX_GLOBAL MX_UINT8 FCV_DATA[FCVsz_DATA]; // Large Data Array'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The AddVar event is used during the compile to C process to take the variables from the variable manager and generate the necessary C code. By calling a macro to run on this event we can tailor the way the variables are added to the C and add in the cast to FAR memory.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:AdVar.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The first thing we need to do in the macro is compare the name of the variable that is currently being processed with the name of the variable we want to store into FAR memory. The string compare function returns 0 if the two strings match up so in the No branch of the decision we then add the &amp;quot;__attribute__((far)) &amp;quot; string to the expansion string.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:EvAddVar.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After saving the project and refreshing the C code window the variable now looks like this.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''__attribute__((far)) MX_GLOBAL MX_UINT8 FCV_DATA[FCVsz_DATA]; // Large Data Array'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
And during compilation we now get this.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Total data memory used (bytes):         0x1116  (4374) 15%'''&lt;br /&gt;
&lt;br /&gt;
'''...'''&lt;br /&gt;
&lt;br /&gt;
'''HEX file creation successful!'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here is the file as a demonstration.&lt;br /&gt;
&lt;br /&gt;
[[File:FarMem.fcfx]]&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://www.flowcode.co.uk/wiki/index.php?title=Event_Contents&amp;diff=14379</id>
		<title>Event Contents</title>
		<link rel="alternate" type="text/html" href="https://www.flowcode.co.uk/wiki/index.php?title=Event_Contents&amp;diff=14379"/>
		<updated>2014-01-22T16:19:41Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* navigation&lt;br /&gt;
** mainpage|mainpage-description&lt;br /&gt;
** portal-url|portal&lt;br /&gt;
** Migrating_to_V6|Migrating to v6&lt;br /&gt;
** Flowcode_Help_Overview|Flowcode Basics&lt;br /&gt;
** Components|Component Help&lt;br /&gt;
** Event_Reference|Simulation Events&lt;br /&gt;
** API_Overview|Simulation API&lt;br /&gt;
** Exercises|Exercises&lt;br /&gt;
** Feature_List|Features&lt;br /&gt;
** Concepts|Concepts&lt;br /&gt;
** Frequently_Asked_Questions|FAQs&lt;br /&gt;
*SEARCH&lt;br /&gt;
*Event classes&lt;br /&gt;
**Event class Compile|Compile&lt;br /&gt;
**Event class Components|Components&lt;br /&gt;
**Event class Console|Console&lt;br /&gt;
**Event class Connection|Connection&lt;br /&gt;
**Event class Scope|Scope&lt;br /&gt;
**Event class Simulation|Simulation&lt;br /&gt;
**Event class System|System&lt;br /&gt;
**Event class Sound|Sound&lt;br /&gt;
**Event class Tooltip|Tooltip&lt;br /&gt;
**Event class File|File&lt;br /&gt;
**Event class Graphics|Graphics&lt;br /&gt;
**Event class Keyboard|Keyboard&lt;br /&gt;
**Event class Mouse|Mouse&lt;br /&gt;
*TOOLBOX&lt;br /&gt;
*LANGUAGES&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Sidebar]]&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://www.flowcode.co.uk/wiki/index.php?title=API_Contents&amp;diff=14378</id>
		<title>API Contents</title>
		<link rel="alternate" type="text/html" href="https://www.flowcode.co.uk/wiki/index.php?title=API_Contents&amp;diff=14378"/>
		<updated>2014-01-22T16:19:16Z</updated>

		<summary type="html">&lt;p&gt;Admin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* navigation&lt;br /&gt;
** mainpage|mainpage-description&lt;br /&gt;
** portal-url|portal&lt;br /&gt;
** Migrating_to_V6|Migrating to v6&lt;br /&gt;
** Flowcode_Help_Overview|Flowcode Basics&lt;br /&gt;
** Components|Component Help&lt;br /&gt;
** Event_Reference|Simulation Events&lt;br /&gt;
** API_Overview|Simulation API&lt;br /&gt;
** Exercises|Exercises&lt;br /&gt;
** Feature_List|Features&lt;br /&gt;
** Concepts|Concepts&lt;br /&gt;
** Frequently_Asked_Questions|FAQs&lt;br /&gt;
*SEARCH&lt;br /&gt;
*API classes&lt;br /&gt;
**API Component|Component&lt;br /&gt;
**API Component.Property|Property&lt;br /&gt;
**API Panel|Panel&lt;br /&gt;
**API Panel.Position|Position&lt;br /&gt;
**API Panel.Position.Math|Math&lt;br /&gt;
**API Panel.Position.Camera|Camera&lt;br /&gt;
**API Panel.PCloud|PCloud&lt;br /&gt;
**API Panel.LinkBar|LinkBar&lt;br /&gt;
**API Panel.Collision|Collision&lt;br /&gt;
**API Panel.Graphics|Graphics&lt;br /&gt;
**API Panel.Graphics.Shape|Shape&lt;br /&gt;
**API Mouse|Mouse&lt;br /&gt;
**API FCD|FCD&lt;br /&gt;
**API Sound|Sound&lt;br /&gt;
**API Scope|Scope&lt;br /&gt;
**API Console|Console&lt;br /&gt;
**API Connection|Connection&lt;br /&gt;
**API Expand|Expand&lt;br /&gt;
**API Tree|Tree&lt;br /&gt;
**API File|File&lt;br /&gt;
**API File.Buffer|Buffer&lt;br /&gt;
**API File.NVM|NVM&lt;br /&gt;
**API Time|Time&lt;br /&gt;
**API Language|Language&lt;br /&gt;
**API System|System&lt;br /&gt;
**API Debug|Debug&lt;br /&gt;
*TOOLBOX&lt;br /&gt;
*LANGUAGES&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Sidebar]]&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
</feed>