
Quote from rrey on October 14, 2019, 6:54 pmHola,
Estoy estudiando la demo fabric-canvas, y quería cargar y recuperar un archivo json.
Grabar un archivo me ha funcionado con:
fabUnselect "Container1" fabSaveAsJSON "Container1" [myjson] VarToLocalFile [myjson] "mi_json"Pero cargar desde local no me funciona. Uso este código.
fabUnselect "Container1" LocalFileToVar "FileInput1" [texto] fabLoadFromJSON "Container1" [texto]Se supone que este último se tenía que abrir una cuadro de diálogo para elegir el archivo a cargar. Pero no me sale.
¿Algo estoy haciendo maal?
Saludos,
Roger
Hola,
Estoy estudiando la demo fabric-canvas, y quería cargar y recuperar un archivo json.
Grabar un archivo me ha funcionado con:
fabUnselect "Container1" fabSaveAsJSON "Container1" [myjson] VarToLocalFile [myjson] "mi_json"
Pero cargar desde local no me funciona. Uso este código.
fabUnselect "Container1" LocalFileToVar "FileInput1" [texto] fabLoadFromJSON "Container1" [texto]
Se supone que este último se tenía que abrir una cuadro de diálogo para elegir el archivo a cargar. Pero no me sale.
¿Algo estoy haciendo maal?
Saludos,
Roger
Quote from Gaev on October 14, 2019, 8:00 pm@rrey
But loading from local doesn't work for me. I use this code.
This code ...
LocalFileToVar "LoadLocalFile" [varLocalFileContent]... works for me ...
1) This code must be in the code section (tab) of the FileInput object ( FileInput1 in your case) ... not part of a Push Button object ... this might be the reason you are not prompted for the file name.
2) The Help file section for this command states ...
Note that loading is asynchronous.
... if you (temporarily) set up a text object (eg a Container ) whose html property is set to [text] , you will see the content of the file after it is loaded ... however, there is a small time delay ... and what could be happening in your case, is that the subsequent command ( fabLoadFromJSON ) could be serviced BEFORE the file content is loaded into [text]
But loading from local doesn't work for me. I use this code.
This code ...
LocalFileToVar "LoadLocalFile" [varLocalFileContent]
... works for me ...
1) This code must be in the code section (tab) of the FileInput object ( FileInput1 in your case) ... not part of a Push Button object ... this might be the reason you are not prompted for the file name.
2) The Help file section for this command states ...
Note that loading is asynchronous.
... if you (temporarily) set up a text object (eg a Container ) whose html property is set to [text] , you will see the content of the file after it is loaded ... however, there is a small time delay ... and what could be happening in your case, is that the subsequent command ( fabLoadFromJSON ) could be serviced BEFORE the file content is loaded into [text]
Quote from Gaev on October 14, 2019, 8:08 pm@rrey
There are commands to hold off on dependent commands until the file content is loaded ... but none of them triggered the subroutine for me.
This Forum was giving me an error (Forbidden Content) when I tried to submit the entire post ... so I am doing it in parts
Added later ... the commands are Watch, onLoadSuccess, onLoadEnd
There are commands to hold off on dependent commands until the file content is loaded ... but none of them triggered the subroutine for me.
This Forum was giving me an error (Forbidden Content) when I tried to submit the entire post ... so I am doing it in parts
Added later ... the commands are Watch, onLoadSuccess, onLoadEnd
Quote from Gaev on October 14, 2019, 8:20 pm@luishp
The Forum will not let me add the other command ... keeps telling me that I have Forbidden Content.
Also noticed that the code section is not rendering ... shows the underlying html instead ... used to be an old issue that has returned.
The Forum will not let me add the other command ... keeps telling me that I have Forbidden Content.
Also noticed that the code section is not rendering ... shows the underlying html instead ... used to be an old issue that has returned.

Quote from rrey on October 14, 2019, 8:46 pm@gaev
¿Donde pones ese código en valor inicial? De momento no me ha funcionado.
Pero he probado este que sí funciona retrasando el tiempo para que se cargue.
LocalFileToVar "FileInput1" [texto] fabUnselect "Container1" Wait 2000 fabLoadFromJSON "Container1" [texto] EndWaitPero reflexionando un poco me pregunto que si se ejecutara desde internet y el archivo tarda más de dos segundos en cargarse podría dar error. Por eso sería importante que hubiera algún tipo de comando como comentas.
Gracias por tu ayuda.
Roger Rey
¿Donde pones ese código en valor inicial? De momento no me ha funcionado.
Pero he probado este que sí funciona retrasando el tiempo para que se cargue.
LocalFileToVar "FileInput1" [texto] fabUnselect "Container1" Wait 2000 fabLoadFromJSON "Container1" [texto] EndWait
Pero reflexionando un poco me pregunto que si se ejecutara desde internet y el archivo tarda más de dos segundos en cargarse podría dar error. Por eso sería importante que hubiera algún tipo de comando como comentas.
Gracias por tu ayuda.
Roger Rey

Quote from luishp on October 14, 2019, 8:53 pm@gaev,
Also noticed that the code section is not rendering ... shows the underlying html instead ... used to be an old issue that has returned.
I have edited your post and it works again. Not sure why it happened again.
The Forum will not let me add the other command ... keeps telling me that I have Forbidden Content.
I thought moderators like you would have the possibility to publish it anyway :(
Please, upload a sample project instead in a .neoapp or .zip file.
Also noticed that the code section is not rendering ... shows the underlying html instead ... used to be an old issue that has returned.
I have edited your post and it works again. Not sure why it happened again.
The Forum will not let me add the other command ... keeps telling me that I have Forbidden Content.
I thought moderators like you would have the possibility to publish it anyway :(
Please, upload a sample project instead in a .neoapp or .zip file.
Quote from Gaev on October 14, 2019, 9:23 pm@rrey
If you run your App from the web, LocalFileToVar would still load the contents of a local (to where the user's device was) file ... so timing differences would only be dependent on the speed of the device.
The only bullet proof method is to use one of the event driven commands (listed before) that would trigger subroutines when the file content was loaded.
@luishp
Please, upload a sample project instead in a .neoapp or .zip file.
To be clear, it was objecting to my typing some simple text ... it kept objecting when I tried to enter the last of the on Load commands ... the one referring to erroneous situations.
If you run your App from the web, LocalFileToVar would still load the contents of a local (to where the user's device was) file ... so timing differences would only be dependent on the speed of the device.
The only bullet proof method is to use one of the event driven commands (listed before) that would trigger subroutines when the file content was loaded.
Please, upload a sample project instead in a .neoapp or .zip file.
To be clear, it was objecting to my typing some simple text ... it kept objecting when I tried to enter the last of the on Load commands ... the one referring to erroneous situations.

Quote from luishp on October 14, 2019, 10:01 pm@rrey también es posible utilizar onLoadSuccess para saber cuando se ha cargado cualquier archivo y ejecutar el código correspondiente.
@gaev, that's quite strange. The website has a protection system against code injection. If it fails the only thing I can do is deactivate it (not a good idea). Fortunately, it only happens very rarely. Sorry.
@rrey también es posible utilizar onLoadSuccess para saber cuando se ha cargado cualquier archivo y ejecutar el código correspondiente.
@gaev, that's quite strange. The website has a protection system against code injection. If it fails the only thing I can do is deactivate it (not a good idea). Fortunately, it only happens very rarely. Sorry.


Quote from luishp on October 18, 2019, 4:47 pmHola @rrey, si onLoadSuccess es una de las acciones de VisualNEO Web que puedes encontrar dentro de la sección "Events".
No estoy seguro de que vaya a funcionar con archivos cargados localmente (sin un servidor de por medio). Alternativamente puedes utilizar Watch para saber si el archivo ha sido cargado en una variable.
Hola @rrey, si onLoadSuccess es una de las acciones de VisualNEO Web que puedes encontrar dentro de la sección "Events".
No estoy seguro de que vaya a funcionar con archivos cargados localmente (sin un servidor de por medio). Alternativamente puedes utilizar Watch para saber si el archivo ha sido cargado en una variable.

Quote from rrey on October 18, 2019, 4:57 pmMuchas gracias @luishp no conocía la segunda solución.
Me está gustando mucho el programa. Te animo a seguir desarrollándose.
Saludos,
Roger
Muchas gracias @luishp no conocía la segunda solución.
Me está gustando mucho el programa. Te animo a seguir desarrollándose.
Saludos,
Roger