Discussion:
[TECH] : javascript embedded in html embedded in c embedded in a ESP8266 wrapper script
Justin Richards
2018-01-20 21:41:50 UTC
Permalink
To help speed up the development cycle I have separated HTML out of the
source code so I can quickly modify,save and refresh in chrome to test.
Much faster than recompiling, uploading etc.

To again use within C the code needs to be wrapped in quotes and existing
quotes need to be escaped.

The process of wrapping in quotes and stripping off the quotes for me is
cumbersome.

This line for example

textfield.outerHTML = "<input type='range' value='" +
testdatainput[arrindex] + "' id='idrange" + arrfieldsinput[arrindex] + "'
oninput='updatehtmltext(\""+arrfieldsinput[arrindex]+"\");' min='" +
arrfieldsinputmin[arrindex]+ "' max='" + arrfieldsinputmax[arrindex]+ "'
step='0.1' style='width: 250px;height: 25px;'>";

Takes me a long time to modify for use within C.

I guess something similar to the mpfs.exe utility is what is needed.

How do people handle this. Are there wrapper scripts for this. Is there a
better way.

Justin
--
http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist
Christopher Head
2018-01-21 01:06:38 UTC
Permalink
Post by Justin Richards
How do people handle this. Are there wrapper scripts for this. Is there a
better way.
I know of a few options, though none of this information is PIC specific so any particular idea may or may not actually help you.

Some assemblers have a directive named “incbin” or similar. Such a directive includes an arbitrary file as raw bytes right at that point in the generated output memory section. You would typically put a label, then incbin, then perhaps another label. The first label gives you the address of your blob, while the second minus the first gives you its length. From a C point of view, you would declare the first label as an extern char array of unspecified length and the second as an extern char; “firstLabel” alone is the data array while “(&secondLabel-&firstLabel[0])” is the length. Of course, as always in C, you could replace &firstLabel[0] with just firstLabel, but I thought this form would be perhaps a little easier to understand.

Some linkers may allow you to do exactly the same thing with a directive in the linker script and symbol assignments around it to get the addresses.

If you are running Linux, the “xxd” command’s “-i” option turns an arbitrary file into a C source file with its bytes in an array. If you are running Windows, you can probably get xxd from Cygwin, but I don’t really program under Windows so I can’t say for sure.
--
Christopher Head
r***@bredband.net
2018-01-21 11:57:19 UTC
Permalink
Can't you just use a text sequence not used elsewhere, like e.g. {{esq_qt}}, &nbsp;instead of the escaped quotes in the file you are editing and then use two scripts&nbsp;and regex or something&nbsp;to simply change (including removing) it to the purpose you want, html for chrome or c code for downloading?

Put the scripts in a command or batch file and then it is just a matter of saving the file you are editing and running the batch file which converts your edited file to html and c code in two separate files which is then used instead of the file you are editing. Sort of a very simple mpfs utility or preprocessor.

Or perhaps I have missed something?

/Ruben


Den Sun, 21 Jan 2018 05:41:50 +0800, Justin Richards skrev:

To help speed up the development cycle I have separated HTML out of the
source code so I can quickly modify,save and refresh in chrome to test.
Much faster than recompiling, uploading etc.

To again use within C the code needs to be wrapped in quotes and existing
quotes need to be escaped.

The process of wrapping in quotes and stripping off the quotes for me is
cumbersome.

This line for example

textfield.outerHTML = " oninput='updatehtmltext(\""+arrfieldsinput[arrindex]+"\");' min='" +
arrfieldsinputmin[arrindex]+ "' max='" + arrfieldsinputmax[arrindex]+ "'
step='0.1' style='width: 250px;height: 25px;'&gt;";

Takes me a long time to modify for use within C.

I guess something similar to the mpfs.exe utility is what is needed.

How do people handle this. Are there wrapper scripts for this. Is there a
better way.

Justin
--
http://www.piclist.com/techref/piclist PIC/SX FAQ &amp; list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist
&nbsp;
--
http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist
Jason White
2018-01-21 13:20:59 UTC
Permalink
Justin, perhaps C's preprocessor could do some of the work for you?

However, if it were up to me I would script the build process; most
tool chains support this. I would have it automatically invoke a
program that generates the C file from the HTML as the first step of
the build before the compiler is run on it.
Post by r***@bredband.net
Can't you just use a text sequence not used elsewhere, like e.g. {{esq_qt}}, &nbsp;instead of the escaped quotes in the file you are editing and then use two scripts&nbsp;and regex or something&nbsp;to simply change (including removing) it to the purpose you want, html for chrome or c code for downloading?
Put the scripts in a command or batch file and then it is just a matter of saving the file you are editing and running the batch file which converts your edited file to html and c code in two separate files which is then used instead of the file you are editing. Sort of a very simple mpfs utility or preprocessor.
Or perhaps I have missed something?
/Ruben
To help speed up the development cycle I have separated HTML out of the
source code so I can quickly modify,save and refresh in chrome to test.
Much faster than recompiling, uploading etc.
To again use within C the code needs to be wrapped in quotes and existing
quotes need to be escaped.
The process of wrapping in quotes and stripping off the quotes for me is
cumbersome.
This line for example
textfield.outerHTML = " oninput='updatehtmltext(\""+arrfieldsinput[arrindex]+"\");' min='" +
arrfieldsinputmin[arrindex]+ "' max='" + arrfieldsinputmax[arrindex]+ "'
Takes me a long time to modify for use within C.
I guess something similar to the mpfs.exe utility is what is needed.
How do people handle this. Are there wrapper scripts for this. Is there a
better way.
Justin
--
http://www.piclist.com/techref/piclist PIC/SX FAQ &amp; list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist
&nbsp;
--
http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist
--
Jason White
--
http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist
Justin Richards
2018-01-22 01:02:44 UTC
Permalink
I will explore this option as it is a tedious choir as it stands.
Post by Jason White
Justin, perhaps C's preprocessor could do some of the work for you?
However, if it were up to me I would script the build process; most
tool chains support this. I would have it automatically invoke a
program that generates the C file from the HTML as the first step of
the build before the compiler is run on it.
Post by r***@bredband.net
Can't you just use a text sequence not used elsewhere, like e.g.
{{esq_qt}}, &nbsp;instead of the escaped quotes in the file you are editing
and then use two scripts&nbsp;and regex or something&nbsp;to simply change
(including removing) it to the purpose you want, html for chrome or c code
for downloading?
Post by r***@bredband.net
Put the scripts in a command or batch file and then it is just a matter
of saving the file you are editing and running the batch file which
converts your edited file to html and c code in two separate files which is
then used instead of the file you are editing. Sort of a very simple mpfs
utility or preprocessor.
Post by r***@bredband.net
Or perhaps I have missed something?
/Ruben
To help speed up the development cycle I have separated HTML out of the
source code so I can quickly modify,save and refresh in chrome to test.
Much faster than recompiling, uploading etc.
To again use within C the code needs to be wrapped in quotes and existing
quotes need to be escaped.
The process of wrapping in quotes and stripping off the quotes for me is
cumbersome.
This line for example
textfield.outerHTML = " oninput='updatehtmltext(\""+
arrfieldsinput[arrindex]+"\");' min='" +
Post by r***@bredband.net
arrfieldsinputmin[arrindex]+ "' max='" + arrfieldsinputmax[arrindex]+ "'
Takes me a long time to modify for use within C.
I guess something similar to the mpfs.exe utility is what is needed.
How do people handle this. Are there wrapper scripts for this. Is there a
better way.
Justin
--
http://www.piclist.com/techref/piclist PIC/SX FAQ &amp; list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist
&nbsp;
--
http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist
--
Jason White
--
http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist
--
http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist
Justin Richards
2018-01-21 22:38:17 UTC
Permalink
Looks like thats what I will be doing. Notepad++ has macros that should
help.

I am assumming that many programmers would have faced this issue and hoped
someone had come up with a handy tool which just needed the right search
terms to find.
Post by r***@bredband.net
Can't you just use a text sequence not used elsewhere, like e.g.
{{esq_qt}}, &nbsp;instead of the escaped quotes in the file you are editing
and then use two scripts&nbsp;and regex or something&nbsp;to simply change
(including removing) it to the purpose you want, html for chrome or c code
for downloading?
Put the scripts in a command or batch file and then it is just a matter of
saving the file you are editing and running the batch file which converts
your edited file to html and c code in two separate files which is then
used instead of the file you are editing. Sort of a very simple mpfs
utility or preprocessor.
Or perhaps I have missed something?
/Ruben
To help speed up the development cycle I have separated HTML out of the
source code so I can quickly modify,save and refresh in chrome to test.
Much faster than recompiling, uploading etc.
To again use within C the code needs to be wrapped in quotes and existing
quotes need to be escaped.
The process of wrapping in quotes and stripping off the quotes for me is
cumbersome.
This line for example
textfield.outerHTML = " oninput='updatehtmltext(\""+
arrfieldsinput[arrindex]+"\");' min='" +
arrfieldsinputmin[arrindex]+ "' max='" + arrfieldsinputmax[arrindex]+ "'
Takes me a long time to modify for use within C.
I guess something similar to the mpfs.exe utility is what is needed.
How do people handle this. Are there wrapper scripts for this. Is there a
better way.
Justin
--
http://www.piclist.com/techref/piclist PIC/SX FAQ &amp; list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist
&nbsp;
--
http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist
--
http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist
Isaac M. Bavaresco
2018-01-22 11:52:08 UTC
Permalink
Write a program to convert your text file into a series of quoted
characters:

char HTML[] = {
't','e','x','t','f','i','e','l','d','.','o','u','t','e','r','H','T','M',',
'L',' ','=',' ','"','<','i','n','p','u','t','
','t','y','p','e','=','\'','r','a',',
'n','g','e','\'',' ','v','a','l','u','e','=','\'','"',' ','+',',...
};

If you use assembly, create a series of 'db' directives:

    db
't','e','x','t','f','i','e','l','d','.','o','u','t','e','r','H','T','M','L','
','=',' ','"','...

Then just include this file in you project.

Each time you change your HTML code, just convert it again with your
custom program.

You could create a rule in the makefile to invoke this program
automatically.

Cheers,

Isaac
Post by Justin Richards
To help speed up the development cycle I have separated HTML out of the
source code so I can quickly modify,save and refresh in chrome to test.
Much faster than recompiling, uploading etc.
To again use within C the code needs to be wrapped in quotes and existing
quotes need to be escaped.
The process of wrapping in quotes and stripping off the quotes for me is
cumbersome.
This line for example
textfield.outerHTML = "<input type='range' value='" +
testdatainput[arrindex] + "' id='idrange" + arrfieldsinput[arrindex] + "'
oninput='updatehtmltext(\""+arrfieldsinput[arrindex]+"\");' min='" +
arrfieldsinputmin[arrindex]+ "' max='" + arrfieldsinputmax[arrindex]+ "'
step='0.1' style='width: 250px;height: 25px;'>";
Takes me a long time to modify for use within C.
I guess something similar to the mpfs.exe utility is what is needed.
How do people handle this. Are there wrapper scripts for this. Is there a
better way.
Justin
---
Este email foi escaneado pelo Avast antivírus.
https://www.avast.com/antivirus
--
http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
View/change your membership options
Loading...