#3 is an old school way of making sure the JavaScript didn’t get executed until after the html was loaded. This was usually required to set/get some value on some html element and if the JavaScript was run at the top of the page the html element would not yet exist and you’d have a bug (good times!). Nowadays we use events and execute our code when the event fires. So you’re correct in using .show() or some other event.
Made a Main() function that holds the JS that was at the end of the original HTML (for startup).
Put the three .js and two .css files in the project folder and in the Project Explorer.
Used a Container control and put the HTML in the Content property.
At this point, the project on the design side looks OK, but the project GoodBarcode.appstudio.zip (66.5 KB)
won’t run, either locally or on Volt. When asked to run, it just doesn’t do anything visible. Any thoughts?
I had a look at your project. Once of the third party css files you were adding had a bad character in it. We have just uploaded a new build (7.3.1.3) which handles this gracefully.
Thanks. I couldn’t get it to run in appStudio (got it to run in a plain browser with HTML). I’m just not familiar enough with how to make something in HTML transfer into an appStudio app. Thanks anyways George.
I downloaded your last attempt. Not much shows up in AppStudio’s Design Screen, so I pressed Run to see what was going on. Sure enough - there’s an error in the HTML preventing the form from displaying. (“Unxpected token < line 2 column 5”)
Opening the Chrome Console, I see errors, like “Uncaught ReferenceError: dynamsoft is not defined”. First job is to fix that error. I see dynamsoft is called from foundation.min.js.
It looks like you’re missing a .js file to define dynamsoft.
The next step for you will be to figure out what file you need for dynamsoft and add that to your project.
As for the < error, I had seen this earlier but couldn’t see the problem in the code - this is what the ‘offending code’ looks like in appStudio (second line, )
Took care of the HTML problem by removing the lines - thanks!
The second problem was that the program is not finding the dynamsoft object. This object appears to be defined in the dbr_6_5_0_2_min_js file on line 16 (at the end).
The documentation on lines 6-9 in the script_js file says to indicate where I put it (when I moved it). I put the dbr_6_5_0_2_min_js file in two places (not knowing which would word): in a Dist folder (the folder it was in for their original example - I added one to my project), and in the same folder as the .project file (and dragged it onto the Project Explorer). The comment that said that the *wasm" file should be in the same place as the dbr_6_5_0_2_min_js file so I put it in each of the two places also. Then I added the line of code (line 10) in script_js:
dynamsoft.dbrEnv.resourcesPath = Dist/
Thoughts? Here is a link to the original and current version of the app.
isn’t valid JavaScript, so it gets rejected. I think it wants you to identify the directory the files are found in - they are top level. You’ll need to replace Dist/ with something like “” or “./”. It needs to be a string.
Once you make that change, you’ll find dynamsoft is still not defined. What library supported to define it?
A second issue that this is the first time someone has used an .wasm file with AppStudio. Is there a non-wasm way to do this?
The dynamsoft object appears to be defined in the dbr_6_5_0_2_min_js file on the end of line 16 (var dynamsoft). If you look in the original zipped file from the dynamsoft folks, this is all of the code to make it work. I used their code and made it work in a browser with simple HTML demo webpage they included.
Do you think appStudio won’t work with a wasm file?
George-
I tried moving the two dbr_ files up - get a new error now (see attached). This is using the url location for the files:
dynamsoft.dbrEnv.resourcesPath = ‘https://www.cindycorritore.com/barcode/dbrwasm/js’
Professor, Business Intelligence and Analytics
Business Intelligence & Analytics Department
Heider College of Business
Creighton University
Omaha, NE USA
402-612-1260
You’re really close. The comment for line 10 reads:
// By default, js will load `dbr-<version>.min.js` & `dbr-<version>.wasm` in the same folder as the context.
// `dbr-<version>.min.js` & `dbr-<version>.wasm` should always put in same folder.
// Modify this setting when you put `dbr-<version>.min.js` & `dbr-<version>.wasm` somewhere else.
// Original: dynamsoft.dbrEnv.resourcesPath = 'https://demo.dynamsoft.com/dbr_wasm/js';
Since the .wasm file is now in the same folder as the corresponding .js file, you don’t need to change the path to it. Just comment line 10 out.
Good - that makes it run without errors. Now to make it work - it doesn’t turn on the camera at this point, although this code ran outside of appStudio. Thanks George