function JavaScript not recognized.

Just starting out? Need help? Post your questions and find answers here.
falsam
Posts: 286
Joined: Mon May 05, 2014 9:49 pm
Location: France
Contact:

function JavaScript not recognized.

Post by falsam »

Hello.
What a pleasure to submit a code that doesn't work on Android 😉

■ I'm testing the creation of a text file on Android with the Cordova-plugin-file.

The plugin is initialized correctly.

■ Here's the problem.
This line calls a JavaScript function on success that is not recognized.

Code: Select all

! window.requestFileSystem(window.PERSISTENT, 0, successCallback, errorCallback)
■ I use ADB to debug the apk. ADB returns the following line:
ReferenceError: successCallback is not defined
at f_start (spiderbasic.js?t=1725521373:378:49)
at Channel.onDeviceReady (spiderbasic.js?t=1725521373:390:1)
at Channel.subscribe (cordova.js:802:21)
at document.addEventListener (cordova.js:125:34)
at document.addEventListener (cordova.js:1463:13)
at SpiderLaunch (spiderbasic.js?t=1725521373:386:10)
at SpiderMain (main.js?t=1725521373:31:9)
at Channel.onDeviceReady (index.html:13:91)
at Channel.fire (cordova.js:872:23)
at cordova.js:232:49
SpiderMain @ main.js?t=1725521373:40
debug.js?t=1725521373:59 C:\SpiderBasic Project\Files\Write file.sb:18 successCallback is not defined
■ The code

Code: Select all

EnableExplicit

Declare Start()

;Import Cordova Plugin
Import "cordova plugin add cordova-plugin-file"
EndImport

!document.addEventListener("deviceready", onDeviceReady, false);  

!function onDeviceReady() {    
! alert("Plugin initialisé")
  Start()
!}  

Procedure Start()
  Debug "Start()"
  ! window.requestFileSystem(window.PERSISTENT, 0, successCallback, errorCallback)
EndProcedure

!function successCallback(fs) {
! alert("File : " + fs.name);
!}

!function errorCallback(error) {
! alert("Error : " + error.code);
!}
I hope you can help me. Thank you for your help.

PS: If you have a method for writing files in Android,I accept your solutions 👍

➽ Windows 11 - jdk-11.0.2 - SB 3.00 - Android 15
https://falsam.com

Sorry for my poor english