[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.javascript

Optional printouts using flag?

JT

9/11/2015 7:37:00 AM

Sometimes when programming one wants traces of operation to be printout, to derive how a value was achieved, but in the general case one just want the result out within form.

Is there a way to steer what rows should be interpretated/run by using a flag.
It would be neat if one could use a none Javscript symbol at start of line and then use a bolean flag to tell the interpretator if that line should be interpretated or not.

That way you could swithch between extensive printouts, or just result.

How is this usually resolved in Javascript, is there any language that support the kind of behaviour i suggest?
9 Answers

Evertjan.

9/11/2015 9:25:00 AM

0

jonas.thornvall@gmail.com wrote on 11 Sep 2015 in comp.lang.javascript:

> Sometimes when programming one wants traces of operation to be printout,
> to derive how a value was achieved, but in the general case one just
> want the result out within form.

I don't think so, why would you want "traces of operation" on paper?

Perhaps you mean you want to see it in the console.log?

console.log('value of a is: ' + a);

> Is there a way to steer what rows should be interpretated/run by using a
> flag.

if (debug=='on') console.log('value of a is: ' + a);

> It would be neat if one could use a none Javscript symbol at start
> of line

What is a "none Javscript symbol"?
A "non-Javascript symbol"?
A "known Javascript symbol"?

Javascript essentially has no start-of-line.
The newline does not mean much.

Change the word "line" to "statement",
where statement" could also be a group of consecutive statements within { }.


> and then use a bolean flag to tell the interpretator if that

script-interpretor I would say.

> line should be interpretated or not.

if (debug=='on') { };

> That way you could swithch between extensive printouts, or just result.

You clould also just disregard the console,
or have your printer throw the paper directly into the trach-bin.

> How is this usually resolved in Javascript,

By debugging, see above.

You can also set and use breakpoints with the Developer Tool [usually F12]

> is there any language that
> support the kind of behaviour i suggest?

The behavour is called "debugging",
if I understand your suggestion correctly.

I sugggest:

https://www.google.com/search?q=javascript+debuggin...

> is there any language that

Only Javascript is on topic in this NH.
Debugging is a general concept much much older than Javascript.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

JT

9/11/2015 9:55:00 AM

0

Den fredag 11 september 2015 kl. 11:25:05 UTC+2 skrev Evertjan.:
> jonas.thornvall@gmail.com wrote on 11 Sep 2015 in comp.lang.javascript:
>
> > Sometimes when programming one wants traces of operation to be printout,
> > to derive how a value was achieved, but in the general case one just
> > want the result out within form.
>
> I don't think so, why would you want "traces of operation" on paper?
>
No i meant online in HTML form, let say you have a calculus system and you like to chose the detail level of presentation of the calculation.

> Perhaps you mean you want to see it in the console.log?

No i want to be able to set a flag in the form that tell the detail level of printouts of variables and calculations.

> console.log('value of a is: ' + a);
>
> > Is there a way to steer what rows should be interpretated/run by using a
> > flag.
>
> if (debug=='on') console.log('value of a is: ' + a);
>
> > It would be neat if one could use a none Javscript symbol at start
> > of line
>
> What is a "none Javscript symbol"?
> A "non-Javascript symbol"?
> A "known Javascript symbol"?

Well i was thinking of a reserved unicode ascii combination at start of row, for example &% could signify 0 and 1 and thus we could have a lot of optional execution paths by set &=1 or &=0 for flagged execution.

Now we would have alot of optional executional choices that can be steered directly from form by reading a checkbox to set the flag for.

&,%,&%,%&,%%,&& and so on.



>
> Javascript essentially has no start-of-line.
> The newline does not mean much.
>
> Change the word "line" to "statement",
> where statement" could also be a group of consecutive statements within { }.
>
>
> > and then use a bolean flag to tell the interpretator if that
>
> script-interpretor I would say.
>
> > line should be interpretated or not.
>
> if (debug=='on') { };
>
> > That way you could swithch between extensive printouts, or just result.
>
> You clould also just disregard the console,
> or have your printer throw the paper directly into the trach-bin.
>
> > How is this usually resolved in Javascript,

This is not just for debug purposes but to steer detail level of a calculation or a salary specificaion.

I do realise that it is probably a database query, but there must be alot of realtime systems nowadays that is overwatched from webinterfaces?

And there you may want to specify detail level of information for the process you want to study?


> By debugging, see above.
>
> You can also set and use breakpoints with the Developer Tool [usually F12]
>
> > is there any language that
> > support the kind of behaviour i suggest?
>
> The behavour is called "debugging",
> if I understand your suggestion correctly.
>
> I sugggest:
>
> https://www.google.com/search?q=javascript+debuggin...
>
> > is there any language that
>
> Only Javascript is on topic in this NH.
> Debugging is a general concept much much older than Javascript.
>
> --
> Evertjan.
> The Netherlands.
> (Please change the x'es to dots in my emailaddress)

JT

9/11/2015 9:59:00 AM

0

Den fredag 11 september 2015 kl. 11:25:05 UTC+2 skrev Evertjan.:
> jonas.thornvall@gmail.com wrote on 11 Sep 2015 in comp.lang.javascript:
>
> > Sometimes when programming one wants traces of operation to be printout,
> > to derive how a value was achieved, but in the general case one just
> > want the result out within form.
>
> I don't think so, why would you want "traces of operation" on paper?
>
> Perhaps you mean you want to see it in the console.log?
>
> console.log('value of a is: ' + a);
>
> > Is there a way to steer what rows should be interpretated/run by using a
> > flag.
>
> if (debug=='on') console.log('value of a is: ' + a);
>
> > It would be neat if one could use a none Javscript symbol at start
> > of line
>
> What is a "none Javscript symbol"?
> A "non-Javascript symbol"?
> A "known Javascript symbol"?
>
> Javascript essentially has no start-of-line.
> The newline does not mean much.
>
> Change the word "line" to "statement",
> where statement" could also be a group of consecutive statements within { }.
>
>
> > and then use a bolean flag to tell the interpretator if that
>
> script-interpretor I would say.
>
> > line should be interpretated or not.
>
> if (debug=='on') { };
>
> > That way you could swithch between extensive printouts, or just result.
>
> You clould also just disregard the console,
> or have your printer throw the paper directly into the trach-bin.
>
> > How is this usually resolved in Javascript,
>
> By debugging, see above.
>
> You can also set and use breakpoints with the Developer Tool [usually F12]
>
> > is there any language that
> > support the kind of behaviour i suggest?
>
> The behavour is called "debugging",
> if I understand your suggestion correctly.
>
> I sugggest:
>
> https://www.google.com/search?q=javascript+debuggin...
>
> > is there any language that
>
> Only Javascript is on topic in this NH.
> Debugging is a general concept much much older than Javascript.
>
> --
> Evertjan.
> The Netherlands.
> (Please change the x'es to dots in my emailaddress)

By the way Evertjan, i did find the bug for the baseconversion it was rather silly.

If you find a base that gives wrong answer tell about it. For giant bases it can stall, but i have not found a base where the sanity check is not true.

http://jt.node365.se/baseconvers...

Evertjan.

9/11/2015 10:28:00 AM

0

jonas.thornvall@gmail.com wrote on 11 Sep 2015 in comp.lang.javascript:

>> if (debug=='on') console.log('value of a is: ' + a);
>>
>> > It would be neat if one could use a none Javscript symbol at start
>> > of line
>>
>> What is a "none Javscript symbol"?
>> A "non-Javascript symbol"?
>> A "known Javascript symbol"?
>
> Well i was thinking of a reserved unicode ascii combination at start of
> row, for example &% could signify 0 and 1 and thus we could have a lot
> of optional execution paths by set &=1 or &=0 for flagged execution.

Why don't you answer my Q above?

There is no start-of-line or start-of-row in Javascript,
Javascript is just aa script of statements.

> Now we would have alot of optional executional choices that can be
> steered directly from form by reading a checkbox to set the flag for.
>
> &,%,&%,%&,%%,&& and so on.

You can muse whatever you like, but Javascript is just Javascript.

>> I don't think so, why would you want "traces of operation" on paper?

> No i meant online in HTML form, let say you have a calculus system and
> you > like to chose the detail level of presentation of the calculation.

"online" has nothing to do with it.
Do you mean html as processed by a modern browser?

No, clientside javascript can only do what it does,



>> if (debug=='on') { };
>>
>> > That way you could swithch between extensive printouts, or just
>> > result.
>>
>> You clould also just disregard the console,
>> or have your printer throw the paper directly into the trach-bin.
>>
>> > How is this usually resolved in Javascript,
>
> This is not just for debug purposes but to steer detail level of a
> calculation or a salary specificaion.

You should use the DOM for that, and steer the DOM with your Javascript.

> I do realise that it is probably a database query,

I don't think so.

> but there must be
> alot of realtime systems nowadays that is overwatched from
> webinterfaces?

This above sentence means nothing to me.

> And there you may want to specify detail level of information for the
> process you want to study?

=======================================

Well, try the following using DOM by clientside Javascript:

<!DOCTYPE html>
<span class='level1'>text 1 text</span><br>
<span class='level3'>text 3 text</span><br>
<span class='level2'>text 2 text</span><br>
<span class='level3'>text 3 text</span>


<script type='text/javascript'>

var Iwantlevel3gone = true;

if (Iwantlevel3gone) {
var temp = document.querySelectorAll('.level3');
for (i in temp) temp[i].style.display = 'none';
};

</script>

==========================

Or use serverside Javascript by reloading the page:

<%
var level1, level2, level3, Iwantlevel3gone = true;

if (Iwantlevel3gone) {
level1 = true;
level2 = true;
level3 = false;
};
%>

<% if (level2) { %>text 1 text<% } %><br>
<% if (level3) { %>text 3 text<% } %><br>
<% if (level2) { %>text 2 text<% } %><br>
<% if (level3) { %>text 3 text<% } %>

[not tested]


--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Evertjan.

9/11/2015 10:44:00 AM

0

jonas.thornvall@gmail.com wrote on 11 Sep 2015 in comp.lang.javascript:

> Den fredag 11 september 2015 kl. 11:25:05 UTC+2 skrev Evertjan.:
>> jonas.thornvall@gmail.com wrote on 11 Sep 2015 in comp.lang.javascript:
>>
>> > Sometimes when programming one wants traces of operation to be
>> > printout, to derive how a value was achieved, but in the general case
>> > one just want the result out within form.
>>
>> I don't think so, why would you want "traces of operation" on paper?
>>
>> Perhaps you mean you want to see it in the console.log?
>>
>> console.log('value of a is: ' + a);
>>
>> > Is there a way to steer what rows should be interpretated/run by
>> > using a flag.
>>
>> if (debug=='on') console.log('value of a is: ' + a);
>>
>> > It would be neat if one could use a none Javscript symbol at start
>> > of line
>>
>> What is a "none Javscript symbol"?
>> A "non-Javascript symbol"?
>> A "known Javascript symbol"?
>>
>> Javascript essentially has no start-of-line.
>> The newline does not mean much.
>>
>> Change the word "line" to "statement",
>> where statement" could also be a group of consecutive statements within
>> { }.
>>
>>
>> > and then use a bolean flag to tell the interpretator if that
>>
>> script-interpretor I would say.
>>
>> > line should be interpretated or not.
>>
>> if (debug=='on') { };
>>
>> > That way you could swithch between extensive printouts, or just
>> > result.
>>
>> You clould also just disregard the console,
>> or have your printer throw the paper directly into the trach-bin.
>>
>> > How is this usually resolved in Javascript,
>>
>> By debugging, see above.
>>
>> You can also set and use breakpoints with the Developer Tool [usually
>> F12]
>>
>> > is there any language that
>> > support the kind of behaviour i suggest?
>>
>> The behavour is called "debugging",
>> if I understand your suggestion correctly.
>>
>> I sugggest:
>>
>> https://www.google.com/search?q=javascript+debuggin...
>>
>> > is there any language that
>>
>> Only Javascript is on topic in this NH.
>> Debugging is a general concept much much older than Javascript.
>>
>> --
>> Evertjan.
>> The Netherlands.
>> (Please change the x'es to dots in my emailaddress)
>
> By the way Evertjan, i did find the bug for the baseconversion it was
> rather silly.

You do not make sense, this is no response to the above or to the subject of
the tread.

This is usenet, not email, so try to follow Netiquette!

> If you find a base that gives wrong answer tell about it. For giant
> bases it can stall, but i have not found a base where the sanity check
> is not true.
>
> http://jt.node365.se/baseconvers...
>



--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

JT

9/11/2015 2:24:00 PM

0

Den fredag 11 september 2015 kl. 12:29:11 UTC+2 skrev Evertjan.:
> jonas.thornvall@gmail.com wrote on 11 Sep 2015 in comp.lang.javascript:
>
> >> if (debug=='on') console.log('value of a is: ' + a);
> >>
> >> > It would be neat if one could use a none Javscript symbol at start
> >> > of line
> >>
> >> What is a "none Javscript symbol"?
> >> A "non-Javascript symbol"?
> >> A "known Javascript symbol"?
> >
> > Well i was thinking of a reserved unicode ascii combination at start of
> > row, for example &% could signify 0 and 1 and thus we could have a lot
> > of optional execution paths by set &=1 or &=0 for flagged execution.
>
> Why don't you answer my Q above?
>
> There is no start-of-line or start-of-row in Javascript,
> Javascript is just aa script of statements.
>
> > Now we would have alot of optional executional choices that can be
> > steered directly from form by reading a checkbox to set the flag for.
> >
> > &,%,&%,%&,%%,&& and so on.
>
> You can muse whatever you like, but Javascript is just Javascript.
>
> >> I don't think so, why would you want "traces of operation" on paper?
>
> > No i meant online in HTML form, let say you have a calculus system and
> > you > like to chose the detail level of presentation of the calculation.
>
> "online" has nothing to do with it.
> Do you mean html as processed by a modern browser?
>
> No, clientside javascript can only do what it does,
>
>
>
> >> if (debug=='on') { };
> >>
> >> > That way you could swithch between extensive printouts, or just
> >> > result.
> >>
> >> You clould also just disregard the console,
> >> or have your printer throw the paper directly into the trach-bin.
> >>
> >> > How is this usually resolved in Javascript,
> >
> > This is not just for debug purposes but to steer detail level of a
> > calculation or a salary specificaion.
>
> You should use the DOM for that, and steer the DOM with your Javascript.
>
> > I do realise that it is probably a database query,
>
> I don't think so.
>
> > but there must be
> > alot of realtime systems nowadays that is overwatched from
> > webinterfaces?
>
> This above sentence means nothing to me.
>
> > And there you may want to specify detail level of information for the
> > process you want to study?
>
> =======================================
>
> Well, try the following using DOM by clientside Javascript:
>
> <!DOCTYPE html>
> <span class='level1'>text 1 text</span><br>
> <span class='level3'>text 3 text</span><br>
> <span class='level2'>text 2 text</span><br>
> <span class='level3'>text 3 text</span>
>
>
> <script type='text/javascript'>
>
> var Iwantlevel3gone = true;
>
> if (Iwantlevel3gone) {
> var temp = document.querySelectorAll('.level3');
> for (i in temp) temp[i].style.display = 'none';
> };
>
> </script>
>
> ==========================
>
> Or use serverside Javascript by reloading the page:
>
> <%
> var level1, level2, level3, Iwantlevel3gone = true;
>
> if (Iwantlevel3gone) {
> level1 = true;
> level2 = true;
> level3 = false;
> };
> %>
>
> <% if (level2) { %>text 1 text<% } %><br>
> <% if (level3) { %>text 3 text<% } %><br>
> <% if (level2) { %>text 2 text<% } %><br>
> <% if (level3) { %>text 3 text<% } %>
>
> [not tested]
>
>
> --
> Evertjan.
> The Netherlands.
> (Please change the x'es to dots in my emailaddress)

You are correct Janevert i misunderstood, your example work perfectly fine with forms as was as console.

So if(debugOne), if(debugTwo) and so on it will be.

JT

9/11/2015 2:27:00 PM

0

Den fredag 11 september 2015 kl. 16:24:02 UTC+2 skrev jonas.t...@gmail.com:
> Den fredag 11 september 2015 kl. 12:29:11 UTC+2 skrev Evertjan.:
> > jonas.thornvall@gmail.com wrote on 11 Sep 2015 in comp.lang.javascript:
> >
> > >> if (debug=='on') console.log('value of a is: ' + a);
> > >>
> > >> > It would be neat if one could use a none Javscript symbol at start
> > >> > of line
> > >>
> > >> What is a "none Javscript symbol"?
> > >> A "non-Javascript symbol"?
> > >> A "known Javascript symbol"?
> > >
> > > Well i was thinking of a reserved unicode ascii combination at start of
> > > row, for example &% could signify 0 and 1 and thus we could have a lot
> > > of optional execution paths by set &=1 or &=0 for flagged execution.
> >
> > Why don't you answer my Q above?
> >
> > There is no start-of-line or start-of-row in Javascript,
> > Javascript is just aa script of statements.
> >
> > > Now we would have alot of optional executional choices that can be
> > > steered directly from form by reading a checkbox to set the flag for.
> > >
> > > &,%,&%,%&,%%,&& and so on.
> >
> > You can muse whatever you like, but Javascript is just Javascript.
> >
> > >> I don't think so, why would you want "traces of operation" on paper?
> >
> > > No i meant online in HTML form, let say you have a calculus system and
> > > you > like to chose the detail level of presentation of the calculation.
> >
> > "online" has nothing to do with it.
> > Do you mean html as processed by a modern browser?
> >
> > No, clientside javascript can only do what it does,
> >
> >
> >
> > >> if (debug=='on') { };
> > >>
> > >> > That way you could swithch between extensive printouts, or just
> > >> > result.
> > >>
> > >> You clould also just disregard the console,
> > >> or have your printer throw the paper directly into the trach-bin.
> > >>
> > >> > How is this usually resolved in Javascript,
> > >
> > > This is not just for debug purposes but to steer detail level of a
> > > calculation or a salary specificaion.
> >
> > You should use the DOM for that, and steer the DOM with your Javascript.
> >
> > > I do realise that it is probably a database query,
> >
> > I don't think so.
> >
> > > but there must be
> > > alot of realtime systems nowadays that is overwatched from
> > > webinterfaces?
> >
> > This above sentence means nothing to me.
> >
> > > And there you may want to specify detail level of information for the
> > > process you want to study?
> >
> > =======================================
> >
> > Well, try the following using DOM by clientside Javascript:
> >
> > <!DOCTYPE html>
> > <span class='level1'>text 1 text</span><br>
> > <span class='level3'>text 3 text</span><br>
> > <span class='level2'>text 2 text</span><br>
> > <span class='level3'>text 3 text</span>
> >
> >
> > <script type='text/javascript'>
> >
> > var Iwantlevel3gone = true;
> >
> > if (Iwantlevel3gone) {
> > var temp = document.querySelectorAll('.level3');
> > for (i in temp) temp[i].style.display = 'none';
> > };
> >
> > </script>
> >
> > ==========================
> >
> > Or use serverside Javascript by reloading the page:
> >
> > <%
> > var level1, level2, level3, Iwantlevel3gone = true;
> >
> > if (Iwantlevel3gone) {
> > level1 = true;
> > level2 = true;
> > level3 = false;
> > };
> > %>
> >
> > <% if (level2) { %>text 1 text<% } %><br>
> > <% if (level3) { %>text 3 text<% } %><br>
> > <% if (level2) { %>text 2 text<% } %><br>
> > <% if (level3) { %>text 3 text<% } %>
> >
> > [not tested]
> >
> >
> > --
> > Evertjan.
> > The Netherlands.
> > (Please change the x'es to dots in my emailaddress)
>
> You are correct Janevert i misunderstood, your example work perfectly fine with forms as was as console.
>
> So if(debugOne), if(debugTwo) and so on it will be.

But the thing i find distorumbing is a printout in a loop will have to check again and again. It would had been better to flag the whole line /statement as not for execution with a boolean.

It seem a waiste of cycles doing it again and again.

Evertjan.

9/11/2015 2:42:00 PM

0

jonas.thornvall@gmail.com wrote on 11 Sep 2015 in comp.lang.javascript:

> But the thing i find distorumbing is a printout in a loop will have to
> check again and again. It would had been better to flag the whole line
> /statement as not for execution with a boolean.

1 it is not print-out, it is screen-display.

2 "better"???, how many cycles you expect, 20.000 ?

3 you can cchange the content of a class-rule, if you like,
in javascript/css/DOM there are many ways to an end.

What about the serverside javascript solution?
if the more detailed display is seldom used,
it is more efficient.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

JT

9/11/2015 2:52:00 PM

0

Den fredag 11 september 2015 kl. 16:42:25 UTC+2 skrev Evertjan.:
> jonas.thornvall@gmail.com wrote on 11 Sep 2015 in comp.lang.javascript:
>
> > But the thing i find distorumbing is a printout in a loop will have to
> > check again and again. It would had been better to flag the whole line
> > /statement as not for execution with a boolean.
>
> 1 it is not print-out, it is screen-display.
>
> 2 "better"???, how many cycles you expect, 20.000 ?
>
> 3 you can cchange the content of a class-rule, if you like,
> in javascript/css/DOM there are many ways to an end.
>
> What about the serverside javascript solution?
> if the more detailed display is seldom used,
> it is more efficient.
>
> --
> Evertjan.
> The Netherlands.
> (Please change the x'es to dots in my emailaddress)

Well the extra screen-display was only about 30 ms so i have to optimise something else.

http://jt.node365.se/baseconvers...