Posts by DecSoft

Show threads by DecSoft
3346 posts found, page 218 of 224

DecSoft (In thread: Problem with setting variables from JavaScript Callback)

Hello Jürgen,

Certainly the problem is that "scanresult" function is executed asynchronously. If I am not wrong "ScanBarcode" is an app function which is called in order to retrieve a barcode. however, such function launch the Barcode "picker" (correct?), and, until the user really scan the barcode the, the "scanresult" nor "scanerror" are executed.

Then we can't use the variable "Barcode" just after call the "ScanBarcode" app function, because such variable is not available at all until the user scan the barcode. What is solution? The solution is to react when the "scanresult" function are executed. My suggestion is to prepare an app function, say "BarcodeReaded", and write something like this in the "scanresult" function:

We can also add a "Text" argument to the "BarcodeReaded" function, then we can simply write something like this:

This is the way in which this kind of things works, not only for the barcode plugin. For example, the we can't write something like that using an Http client control:

The above "AlertBox" can't show the Http client response, because they are not available until the Http client Success event is executed. If in the future I implement the Barcode plugin in App Builder, they must have an "Success" and "Error" events too, in order to be ready when the user scan a barcode.

Hope you can understand this Jürgen, when not, don't hesitate to continue posting.

** Please carefully read the next post **


DecSoft (In thread: Problem with setting variables from JavaScript Callback)

Hello Jürgen,

The problem here is that "scanresult" function is executed asynchronously, then what we assign to "window.App.RootScope.Barcode" is the first defined "barcode" variable value, that is, "HELLO".

Once "scanresult" is executed, what you do is to assign the "result.text" to the "barcode" variable, not to "window.App.RootScope.Barcode". Then the solution is to assign the "result.text" to this variable:


DecSoft (In thread: KeyDown event? Checking user's inputs on keyboard (and mouse click))

Hello Walter,

The above code look well except for the "document.getElementById('action')", which maybe cause an error if the element "action" doesn't exists. On the other hand, try to leave the "index.html" without changes, since this file is generated automatically by the program in every debug/build operation. Then you can use a separated Javascript to do something like that.

Update your App Builder copy because I update it in order to add the KeyUp and KeyDown events for all Input controls, Textarea and Typeahead controls. You can use such events like others in App Builder, and remember the variable "Event" of the control contains the information about the event, then in the case of the KeyUp and KeyDown events, for example:


DecSoft (In thread: No more messages in Console)

Hello Walter,

Oh yes... I am very worry Walter. The Console action support now a second argument (with the kind of console message) and therefore the action are not recognized with only one argument... you need to add such second argument to the Console action calls:

Please sorry for the inconveniences.


DecSoft (In thread: Modify the Report Sample App to include functions (Add, Edit, Delete)?)

Hello CIS,

I think your PHP do not look what we can expect. For example, your PHP scripts produce HTML code, which is something that your app do not expect. Your app provide all the required HTML, you no need to worry about it in the PHP scripts. These scripts must "act" when are requested and must responde with the appropiate data. No more.

You no need an HTML form to send information to your PHP scripts: you must use the Input controls what you need and then use the Http client control to perform the appropiate HTTP POST request. On the same way, you no need to list your database data by output it from PHP scripts. Your scripts must return JSON data that the Report control can parse and show automatically for you.

I am very sorry because this app sample are not trivial at all, probably take me several hours, and currently I am very busy with other project areas. Again, try to understand what you need and ask here for help when you needed. I am very sorry but I can't say other thing at this time. Just remember:

1º add.php - Need to receive POST data and their response can be, for example, just an "OK" or "Fail", in order to understand from our app the data has been added.

2º edit.php - Need to receive POST data and their response can be, again, just an "OK" or "Fail", in order to understand from our app the data has been updated or not.

3º list.php - Only need to return the appropiate data as a JSON object. This script must be very similar to the "data.php" you can found in the current app samples. That JSON object is parsed and show by the Report control.

4º delete.php - Need to receive POST data and their response can be the same than "add.php" and "edit.php".

On the other hand, remember we need to enable "CORS" requests in our PHP scripts. You can view how by read the "data.php" refered above and included into the Report app sample. This may are not needed for the local web served files (probably not) but "CORS" must be enabled for our PHP scripts when use a remote server.


DecSoft (In thread: Modify the Report Sample App to include functions (Add, Edit, Delete)?)

Hello CIS,

First of all, note than the "InputBox" action callback must be an app function, not an action like "StrReplace" as you write. Take a look at the InputBox app sample for more information. On the other hand, probably you need to decide what action execute next: "HttpExecute", "SimplePost" and "SimpleGet" probably cannot be called like you write above.

If you choose to use the HttpClient control to made an HTTP POST it's ok, but you no need to call "SimplePost" at all. On the other hand, "SimplePost" do not offer any feedback, then maybe it's not the right action in your case. Finally you call the "SimpleGet" action, but, again, probably you no need to do something like that CIS.

You can play with the app using a local webserver (*), just remember that if you want to use PHP and MySQL these stuff must be available and running in the local webserver too. We need to think our app is a act like a web page in these scenarios, and therefore we must made the appropiate HTTP GET and POST requests. We can need more or less calls, the Report control or others, depending of the app we made.

If you start with the app I can help you in some particular points when you need! In other case I can't promise when I a possible app sample like you wanted can be ready since I am very busy right now with other App Builder stuff.

(*) Remember that App Builder debugger starts an HTTP local server, then, if you need to work with other local server you must use different ports. By default App Builder uses the 9999 port and this can be changed in the program options dialog from the Menu -> Edit -> Program options.


DecSoft (In thread: Modify the Report Sample App to include functions (Add, Edit, Delete)?)

Hello,

As an addition to my previous message I want to say than the Report control is very powerful and right now App Builder include four different samples: Report, Report2, Report3 and Report4.

A Report control can be feed using their URL variable. Then the control automagically perform the HTTP request, retrieve the response and prepare the data to be show into the Report table.

Maybe we are a bit confusing with the samples "data.json" and "data.php" files. In fact we can include files like "data.json" in our apps in order to feed a Report control with the file app local URL.

"data.php", instead, is a sample of how the JSON data can provide from a webserver and therefore can be dinamically changed or updated in order to allow our apps to show the latest information.

On the other hand, the Report control can also be feed by using their "Data" variable instead their "URL" variable. And this can be made at least in two ways: load JSON data using an action like "SimpleGet" or prepare our own JSON object using the object related actions.

This last way is particularly interesting because we prepare the JSON object in runtime and therefore such object can contains different information in different scenarios. The App Builder's Report3 and Report4 show to us how to do something like this.

That's all! Hope this information can be useful!

Don't forget to play with the App Builder's app samples!


DecSoft (In thread: Modify the Report Sample App to include functions (Add, Edit, Delete)?)

Hello CIS,

Certainly we can prepare the required stuff to not only retrieve and show information from a webserver, allowing to add and edit information too, but probably this is out of the scope of the Report app sample. Maybe we can prepare an specific app sample to doing something like you wanted, however, in the meanwhile, note what are the required stuff in order to do something like that:

1º We firstly need a webserver capable to receive HTTP GET and POST requests and also to store the information in some kind of database like MySQL, for example.

2º We need to prepare some kind of API accesible by HTTP calls in URL like the below ones:

3º We can use a Report control to process and show the JSON data provided by the "get.php" HTTP requests. Note we can add some arguments to the URL in order to retrieve specific information, for example, this URL:

... can produce different results than this other URL:

4º The "edit.php" script can be ready to accept some record specific ID, for example:

The above URL can respond with a ready to parse variables list text like these:

We can use the "ParseVariables" action to get the variables from the response and show their content in a couple of Text input controls.

5º The same app view which show that Text input controls can have a Push button to made an HTTP POST request to the same "edit.php" script, providing the updated information of the edited record.

6º In order to add new records to the database we only need the appropiate Input controls and to made an HTTP POST request to the "add.php" script, providing the appropiate record information.

Probably this is not a complete answer since I do not add what you wanted to the Report control, but I tell you how something like that can be made using App Builder. Maybe in the near future we prepare an app sample around this.


DecSoft (In thread: NeoPlugins - Parsing an HTML table)

Hello Nelson,

I think we can use npXmls but they require too much work than use npRexp. npXmls is a very complex plugin which allow us to parse arbitrary XML, but requires some work in order to get ready for what we wanted. npRexp is more close up to this kind of problems, since we can provide a regular expression of our search query and simply get the available matches.


DecSoft (In thread: NeoPlugins - Parsing an HTML table)

Hello Nelson,

Probably npXmls can do the job too, but I think npRexp can be better here. I modified one of the npRexp samples in order to search for "pcom" data in your HTML table. Take a look if you wanted here:

Sample download

I just modified a little the application sample, then probably we can get better results: it's a question of time, some npRexp study and adapt the plugin to our own publication.


DecSoft (In thread: load array with LoadVariables action ?)

Hello Walter,

Various things to consider here.

4. If I change something in these files IE accepts it immediatly, Chrome and Firefox donn´t . although I pressed F5 different times and I empty the cache manually ...

I test right now in Internet Explorer, Firefox and Chrome and works like expected. If I load a file with two variables "a" and "b" I can use "LoadVariables" or "ParseVariables" and then access such variables. If then I change the file and add a new "c" variable, when I use again the refered actions, there is no problem to get the value of the new added variable.

If we are talking of files included by the app, remember that you can edit the original file, but the app have their own copy of the file! If the argument for the "LoadVariable" action is an remote URL (a remote file) then this must work like expected if you edit the remote file, however, remember "LoadVariables" is not the best way load remote files, because we have no feedback.

"LoadVariables" is mainly intended to load variables for an HTML template, that is, the content of an HTML control. We can use in other scenarios too (for my above test I did so) but it's not recomended, since "LoadVariables" do not offer any feedback about their success or error. This action is also intented to work with local (app files) because these files always exists and we can expect a more or less response from the app server.

5. I checked the ParseVars sample different times made some test in my app, also using HTTPexecute. BUT the thing is with HttpExecute action I stop the script, all script actions behind HttpExecute will not be executed.

Something wrong in your script? Because, in fact, for remote files (not app files) the "ParseVariables" is the way instead of "LoadVariables", and, in order to use this action we need the help of an HTTP Client control, like the sample you mention does. I try right now with the "ParseVars" samples and try to modify the remote variables file and all works like expected Walter.

Yes, the "ParseVariables" action can be used to get variables not only to be shown in an HTML content control, but also to use in other possible places, however, we need to take care about the flow of our app. As you know, all the actions are executed asynchronously, that is, be can't expect the variables are ready just after execute the "HttpExecute" action, we need to wait for the "Success" or "Error" events of the HTTP Client control, and use the HTTP Client response as the argument for the "ParseVariables" action.

Then we need to think in that before count with the variables: we can't use the variables until the HTTP Client control "Success" event and the "ParseVariables" call, and we also need to prepare some scenario for a posible "Error" event. Both scenarios depend on what kind of thing we try to do, I just can say at this time that both "LoadVariables" and "ParseVariables" actions works here in all the browser I test, then maybe you have some problem with your script. Maybe you can send me or prepare a sample to try to reproduce the problem?

6. So my question is, if there is a possibilty to start i.e a function "loadthis" in the show event of an view and WAIT for the end of the function before continuing the show event script. For example with a while which is waiting for a response var of the function

No. I think there is not a way to do such thing Walter. Every action are asynchronously executed. However this not meant we can't do the things, just that we need to think about how to do what we need in an asynchronous way. Then, if you want to execute "something" when the "ParseVariables" end their work, why don't prepare an app function with the "something" stuff and call to that function just after "ParseVariables" in the HTTP Client control "Success" event?

Supose we have two app functions named "GetVariables" and "ProcessVariables". Then our app view "Show" event can look something like this:

1º We call "GetVariables" and that function basically call the "HttpExecute" action to retrieve the remote variables. There is not more stuff in the app view "Show" event.

2º Once the "HttpExecute" is called we wait for the "Success" event of the HTTP Client control. In that event, we use the "ParseVariables" action (using the "[HttpClient1.Response]" variable as argument) and inmediatelly after call to "ProcessVariables".

That's all. We no need to wait for some action execution in the "Show" event, instead of that we "start" the process for retrieving the remote variables file and process the variables when they are retrieved.

7. As far as I understand now the show event script of a view is first read totally and then executed?

I am not sure if understand well, but this and all events and pieces of code are executed following the action's sequence.

8 And last but not least: Do different browsers handle the SetOption and GetOption different? Do they use different webspace? I wrote a own temporary log function which uses SetOption for the log entries. And get different resuklt using IE and/or Chrome/Firefox. confusing!

"SetOption" relies in the "LocalStorage" of every browser. In principle they must work in a similar way. It's just an space to save pairs of keys and values for our apps, then this keys and values must be the same in every browser if we save the same for the keys and values couples. There is no differences in how App Builder deal with this in different browsers Walter.

Hope this all can help you in some manner, but, remember to post here (or in a new thread) whatever you wanted.


DecSoft (In thread: Code minimizer > Sorry an error occur ....)

Hello to all,

The App Builder Code Minimizer tool (GUI) has been enhanced in order to offer information if an error occur. This information has before available when use the App Builder CLI (command line compiler) but not in the GUI version of the Code Minimizer tool. Now both offer us the same information if an error occur while minimize our apps code. Commonly this kind of errors appear by some syntax mistakes and the information provided by the error can be very useful to locale and fix the problem.


DecSoft (In thread: How to add new Cordova plugins please ?)

Hello,

Just to mention another possible approach we can take here: define a Javascript app function. We can define a Javascript app function (instead of an App Builder script function) with two arguments, "phone" and "message". The code of our function can be something like this:

If we name the function as "SendSMS" then the function appear into the Actions palette under the Function's category and we can call it like:

Finally I add this information as a new Apache Cordova custom plugins App Builder help tutorial. Also I add the new "Plugins" app sample which show us how we can custom plugins like this. Take a look if you like Samuel. :)


DecSoft (In thread: How to add new Cordova plugins please ?)

You're welcome!

Always thanks you Samuel. :)


DecSoft (In thread: How to add new Cordova plugins please ?)

Hello Samuel,

I updated App Builder right now by adding a new Cordova custom plugins option into the app options dialog. We can put in the Custom plugins editbox one or more custom plugins by specifying the plugin ID, for example, "com.jsmobile.plugins.sms" for the SMS plugin we are talking about in this post.

App Builder automatically add custom plugins into their generated Cordova batch files and also into their generated Cordova "config.xml" file. This avoid the need to edit the batch files to add the plugins by ourself everytime we build the app, since the Cordova batch files are regenerated in every app build.

Everybody can read the DecSoft support forum for learning purposes, however only DecSoft customers can post new threads. Purchase one or more licenses of some DecSoft products in order to give this and other benefits.

This website uses cookies only to store your preferences.

Ok! Hide this note More information