≡
Products
▼
Support
▼
Company
▼
Forum
Ambiera Forum
Discussions, Help and Support.
Create a new account
,
Search
, or Login:
Create reply in
Read binary files in CopperCube bin2cc released
Posted by:
(you are not logged in)
Enter the missing letter in: "Int?rnational"
(you are not logged in)
Text:
[quote][b][/b] wrote: [quote][b]Robbo[/b] wrote: When saving I just have an array of data I want to save like this: var dat1 = invStats.toString(); ccbWriteFileContent('data/bin/invStats1.bin', dat1); Then when reloading it - to stop some problems like empty data files and causing issues plus converting numbers back to number format from a string do this: var invStats = []; var data = ccbReadFileContent('data/bin/invStats.bin'); if (data == null) {invStats.length = 0;} else {invStats = data.split(",");} var len = invStats.length; for (var i=0; i<len; i++) { if (!isNaN(invStats[i])) {invStats[i] = invStats[i] * 1;} }[/quote] Thank you for your reply. In fact this way essentially reads and writes a text file, not a binary file. The idea of your code is similar to mine in that it converts binary data to a text file. However, storing text using strings made up of commas and numbers takes up more than a hex string. My method is to convert to hex text. However, I have only written the read function so far, not the write function yet. Recently I've been busy writing functions to load camera animation files.[/quote]
Possible Codes
Feature
Code
Link
[url] www.example.com [/url]
Bold
[b]bold text[/b]
Image
[img]http://www.example.com/image.jpg[/img]
Quote
[quote]quoted text[/quote]
Code
[code]source code[/code]
Emoticons
Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact