Jump to content

CWBudde

Members
  • Content Count

    330
  • Joined

  • Last visited

2 Followers

About CWBudde

  • Rank

  • Birthday 01/17/1980

Contact Methods

  • Website URL
    http://www.pcjv.de

Profile Information

  • Gender
    Male
  • Location
    Germany

Business

  • Sector
    Government

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. This has already been implemented, but maybe not included in the last release.
  2. Not for PhoneGap. However, I can send you a file for Cordova though (I have no permissions to attach it to this post). Also you might want to read more here.
  3. That's what I meant. The Cordova.js file is nothing you have to take care for (hence the need to remove the {$R ..} line). You only need to have a link in your HTML file or script that link in with the snippet I posted earlier. In my case I have added this somewhere in the .spr file.
  4. Sorry, I didn't want to confuse you with my suggestions. Typically it's either to us PhoneGap (which is based on Cordova, but made simple) or Cordova directly. The latter is a bit more down to the metal as opposed to PhoneGap. One advantage of Cordova over the PhoneGap build service is the fact that you can run it locally on your machine (PhoneGap itself will run locally as well, but still might access to the cloud). This makes working with Cordova potentially faster and more independent. This said, both are more or less controlled by the same config.xml, which should reside in the s
  5. It is possible to target the browser as platform. However it can not go beyond the security limits of a browser. So it might be of limited use. In order to use Cordova you have to indeed link to the Cordova API. However, the cordova libraries are typically copied by Cordova itself. The code below should be satisfying to link the Cordova library (if present): uses W3C.HTML5; // load Cordova library asynchronous var CordovaScript := JHTMLScriptElement(Document.createElement('script')); CordovaScript.&type := 'text/javascript'; CordovaScript.async := true; CordovaScript.src := 'cor
  6. CWBudde

    FileWriter

    If you only open the file (e.g. by drag & drop the file 'index.html' onto the browser) the file protocol will be used (i.E. 'file:///'). If you serve a file the browser uses the http / https protocol. Regarding PhoneGap / Cordova: It is possible to target the browser as platform. However it can not go beyond the security limits of a browser. So it might be of limited use. In order to use Cordova you have to indeed link to the Cordova API. However, the cordova libraries are typically copied by Cordova itself. The code below should be satisfying to link the Cordova library (if presen
  7. CWBudde

    FileWriter

    It's fine for me.
  8. CWBudde

    FileWriter

    Here are some reasons why it might work with some browsers and not with others: The internal browser has the least security restrictions. So if things work there it doesn't mean much. At the same time the internal browser is a bit outdated as the Chromium binaries equals to Chrome 39. This means some deprecated APIs might still be supported there while others (newer) might not be on board yet. When you use open in browser it runs your web-app in your default browser, but still serves the website from within Smart Mobile Studio. This makes a difference as the file access is still handle
  9. CWBudde

    FileWriter

    Eventually, you must cast the class to the right type to make it work. Something like: var DataBlob := new JBlob(['some text'], JBlobPropertyBag(class &type = 'text/plain' end)); But I have to admit that it looks a bit ugly. The cast means something like: I take care that the code is formaly correct. However a type-safe alternative would be better. Something like: var BlobProperties: JBlobPropertyBag; BlobProperties.&type := 'text/plain'; var DataBlob := new JBlob(['some text'], BlobProperties); But it bloats the code and does not represent the nullable character of JavaScript (w
  10. CWBudde

    FileWriter

    The reported error comes from the fact that 'type' is a keyword in Pascal. It has to be escaped. So the correct code would be: var DataBlob := new JBlob(['some text'], class &type = 'text/plain' end); You can create a JBlob directly from a JArrayBuffer, which is defined in W3C.TypedArray. Assuming that TByteArray = array of Byte this would probably translate to uses W3C.TypedArray, W3C.File; var UInt8Array := JUint8Array.Create(YourByteArray); var DataBlob := JBlob.Create([UInt8Array]); where the latter can be used directly by the write procedure. Btw. I would use the f
  11. CWBudde

    FileWriter

    First thing I noticed: You can get rid of the asm code section by writing something like the following: aOptions := class create = false; exclusive = false; end; But that's not a big deal, just might improve the legibility. If the file doesn't exist already you might need to set create to true, though. Next you may consider to remove the surrounding exception handler to defer the exception handling to the underlying browser / cordova. It might have a different (better) hint about the type mismatch. Typically this comes with the position of the error (of the JavaScript code). Whil
  12. CWBudde

    FileWriter

    I just read it in detail right now. It's not correct how you call it. With: BrowserAPI.window.requestFileSystem(0,0,FileSystem.MyCreateFile(NIL),FileSystem.FileError(NIL)); you execute the function FileSystem.MyCreateFile(NIL) before doing anything else. It is passed with the parameter 'nil', so it's clear why the filesystem is not assigned. If you leave the parameter out it should work. Eventually you might need to add an '@' before the name. So something like: BrowserAPI.window.requestFileSystem(0, 0, @FileSystem.MyCreateFile, @FileSystem.FileError); might already do the trick.
  13. CWBudde

    FileWriter

    The unit W3C.File is a header for the File API (see https://www.w3.org/TR/FileAPI/) which only specifies a writer. In addition to this there is the deprecated unit W3C.FileSystem for the File-System API (https://www.w3.org/TR/file-system-api/). The latter is discontinued and thus deprecated. However you can find previous versions such as this: https://www.w3.org/TR/2012/WD-file-system-api-20120417/. As you can see it doesn't contain a writer either, but this does: https://www.w3.org/TR/2012/WD-file-writer-api-20120417/ This said, you can only use this in theory as the API has not been wide
  14. CWBudde

    FileWriter

    Have you tried setting the size parameter to any other value than zero? Something like: [...]window.requestFileSystem(0,1024*1024, ... It might also be worth to compare the PhoneGap header unit (which is already quite old) to the (also quite old and deprecated) unit W3C.FileSystem. The latter is a little bit more verbose and the base for the PhoneGap/Cordova code.
  15. CWBudde

    FileWriter

    I not an expert for PhoneGap, but I'm pretty experienced with Cordova (the underlying open source project) and there you need to add the file plugin first. Eventually this could be needed for PhoneGap as well.
×
×
  • Create New...