Found an issue in SpiderBasic ? Please report it here !
❤x1
 
Posts: 6
Joined: Sat Feb 09, 2019 5:42 am

Optimize javascript output and database

by ❤x1 Wed Feb 20, 2019 3:02 pm

Hello,
In my project, compiling with "optimize javascript output" ticked always fails with this error message.

---------------------------
SpiderBasic -
---------------------------
spiderbasic.js:32: WARNING - Keywords and reserved words are not allowed as unquoted property names in older versions of JavaScript. If you are targeting newer versions of JavaScript, set the appropriate language_in option.

function spider_FinishDatabaseQuery(a){var c;(c=spider.database.objects.Get(a))&&c.statement.free()}function spider_IsDatabase(a){return spider.database.objects.Is(a)}function spider_CloseDatabase(a){var c;(c=spider.database.objects.Get(a))&&c.db.close()}function spider_ExportDatabase(a,c){var b;return(b=spider.database.objects.Get(a))?(b=new Blob([b.db.export()],{type:"application/octet-stream"}),saveAs(b,c),1):0}

^



spiderbasic.js:33: WARNING - Keywords and reserved words are not allowed as unquoted property names in older versions of JavaScript. If you are targeting newer versions of JavaScript, set the appropriate language_in option.

function spider_ExportDatabaseMemory(a){var c;return(a=spider.database.objects.Get(a))?(a=a.db.export(),c=spider_AllocateMemory(a.length),c.view8.set(a,0,c.byteLength),c):0}function spider_DatabaseError(){return spider.database.error}function spider_DatabaseID(a){var c;return(c=spider.database.objects.Get(a))?c.db:0};

^

...

Picked up _JAVA_OPTIONS: -Xmx512M


I realized it's also true with this way shorter example ( from viewtopic.php?p=5384#p5384 ) :

Code: Select all
#LocalDatabase = 0

Procedure Handler_Database_Loading(Status, Filename.s, File, SizeRead)
   Protected *buffer
   
   If Status = #PB_Status_Loaded ;The sqlite database file is ready, we now need to load it as a database
      *Buffer = ExportFileMemory(File)
      CloseFile(0)
     
      If Not OpenDatabase(#LocalDatabase, *Buffer)
         FreeMemory(*Buffer)
         Debug DatabaseError()
      Else
         FreeMemory(*Buffer)
         Debug "Database Loaded!"
         Debug "Here is every time this database was accessed : "
         
         DatabaseQuery(#LocalDatabase,"Select * FROM Example") ; List all the items in the database.
         While NextDatabaseRow(#LocalDatabase)
            Debug FormatDate("%mm/%dd/%yyyy - %hh:%ii:%ss", GetDatabaseLong(#LocalDatabase,0) ) ; display each entry
         Wend
         FinishDatabaseQuery(#LocalDatabase)
         
         ; now, let's add a new entry :
         DatabaseUpdate(#LocalDatabase,"INSERT Into Example (Date) Values ("+Date()+");")
         
         ; and don't forget to save it!
         *Buffer = ExportDatabaseMemory(#LocalDatabase)
         CreateFile(0,"mydbfile",0,#PB_LocalStorage)
         WriteData(0,*Buffer,0,MemorySize(*Buffer))
         CloseFile(0)
         FreeMemory(*Buffer)
         
      EndIf
         
   ElseIf Status = #PB_Status_Error ; The sqlite database file wasn't found, it's probably the first time your user load the app!
      ; In this case, there is two option : load a default database, or create it from scratch. Here I'll use the second :
      OpenDatabase(#LocalDatabase)
      DatabaseUpdate(#LocalDatabase,"CREATE TABLE `Example` ( `Date`   INTEGER );")
      Debug "Database Created!"
     
      ; Now, I'll add a single entry to the db :
      DatabaseUpdate(#LocalDatabase,"INSERT Into Example (Date) Values ("+Date()+");")
     
      ; The important thing to understand about SQLite database is : it always stays in memory. In order to make any change permanant, you need to write it to the local storage.
      ; Depending on the type of application you are writing, you can use different strategy for this : you could write any change down, you could have a timer and saver every X minutes, wait for your user to save manually...
     
      ; now, let's save it!
      *Buffer = ExportDatabaseMemory(#LocalDatabase)
      CreateFile(0,"mydbfile",0,#PB_LocalStorage)
      WriteData(0,*Buffer,0,MemorySize(*Buffer))
      CloseFile(0)
      FreeMemory(*Buffer)
     
   EndIf
EndProcedure

ReadFile(0,"mydbfile",@Handler_Database_Loading(),#PB_LocalStorage) ; read the sqlite database file from the local storage
Return to Bugs Reports

Who is online

Users browsing this forum: No registered users and 2 guests