New Mars Forums

Official discussion forum of The Mars Society and MarsNews.com

You are not logged in.

Announcement

Announcement: As a reader of NewMars forum, we have opportunities for you to assist with technical discussions in several initiatives underway. NewMars needs volunteers with appropriate education, skills, talent, motivation and generosity of spirit as a highly valued member. Write to newmarsmember * gmail.com to tell us about your ability's to help contribute to NewMars and become a registered member.

#1 2022-09-24 10:56:55

tahanson43206
Moderator
Registered: 2018-04-27
Posts: 17,064

Java (r) or Javascript Computer Language

It is proposed that work on Admininstrative tasks carried out by Admins and Moderators might be done (in part) using a language called Javascript.

JavaScript is named after but is independent of a language called java. Apparently, Java is popular in web servers, and JavaScript is popular in browsers that run on web clients.

This topic is available for those who might wish to provide insights about how to use  Javascript, or links to relevant resources.\

In addition this topic is available for posting of (short-not-too-long) examples of Java or Javascript.

Long examples of code may be stored on the NewMars Dropbox account, and links to the files posted in this topic.

Because Java is (relatively) operating system independent, the language may be of interest to NewMars members from a variety of locations. Those locations may well include Mars at some point.

Update 2022/09/25 (th) It appears that Java and Javascript are two different things.

If a member would care to post an explanation of the differences, that would be welcome.

Update 2022/09/28 (th) Many demonstration code snippets depend upon console.log() for output.  These can be run in any browser, and output will be visible, if the experimenter/student activates the Console Log display of the browser.

For Google Chrome, the feature is found within Menu >> Tools >> Javascript Console
For Mozilla Firefox, the feature (may be) found within Menu >> Tools >> Web Developer >> Web Console

For other browsers, the feature may be activated in a similar way. If a member of the forum would care to report in this topic, that would be welcome.

Update 2022/09/28 (th) Here is a generic html wrapper courtesy of kirupa.com

// Copy of Sample from kirupa.com
<!DOCTYPE html>
<html>
<body>
    <h1>Example</h1>
    <script>
        // insert your JavaScript code here
        console.log("inline 1");
    </script>
</body>
</html>

The language specification appears to be available at this web site:
https://262.ecma-international.org/5.1/

Update 2022/09/29 --- from the language specification, here is a list of keywords:

7.6.1.1
Keywords
The following tokens are ECMAScript keywords and may not be used as Identifiers in ECMAScript programs.
Syntax
Keyword :: one of
break
case
catch
continue
debugger
default
delete
do
else
finally
for
function
if
in
instanceof
new
return
switch
this
throw
try
typeof
var
void
while
with
© Ecma International 2011

(th)

Offline

#2 2022-09-24 10:58:07

tahanson43206
Moderator
Registered: 2018-04-27
Posts: 17,064

Re: Java (r) or Javascript Computer Language

To start things out, here is a quote that Google found:

The Java™ Programming Language is a general-purpose, concurrent, strongly typed, class-based object-oriented language. It is normally compiled to the bytecode instruction set and binary format defined in the Java Virtual Machine Specification.

Java Programming Language https://docs.oracle.com › javase › docs › technotes › guides

To follow up, I asked Amazon what it has in it's catalog:

1-16 of 770 results for "best java books"

I noted a title devoted to Javascript.

The attraction of Java (from my point of view) is that it might have a decent chance of running on any browser/operating system.

kbd512 has indicated (in last Sunday's Zoom) that there may be minor differences between implementations on different browsers and operating systems, so that possibility must be borne in mind in planning a development project.

Update 2022/09/29 ... investigating debugging options...

https://www.tutorialspoint.com/javascri … ugging.htm

Use a JavaScript Validator
One way to check your JavaScript code for strange bugs is to run it through a program that checks it to make sure it is valid and that it follows the official syntax rules of the language. These programs are called validating parsers or just validators for short, and often come with commercial HTML and JavaScript editors.

The most convenient validator for JavaScript is Douglas Crockford's JavaScript Lint, which is available for free at Douglas Crockford's JavaScript Lint.

Simply visit that web page, paste your JavaScript (Only JavaScript) code into the text area provided, and click the jslint button. This program will parse through your JavaScript code, ensuring that all the variable and function definitions follow the correct syntax. It will also check JavaScript statements, such as if and while, to ensure they too follow the correct format

Add Debugging Code to Your Programs
You can use the alert() or document.write() methods in your program to debug your code. For example, you might write something as follows −

var debugging = true;
var whichImage = "widget";

if( debugging )
   alert( "Calls swapImage() with argument: " + whichImage );
   var swapStatus = swapImage( whichImage );

if( debugging )
   alert( "Exits swapImage() with swapStatus=" + swapStatus );
By examining the content and order of the alert() as they appear, you can examine the health of your program very easily.

Use a JavaScript Debugger
A debugger is an application that places all aspects of script execution under the control of the programmer. Debuggers provide fine-grained control over the state of the script through an interface that allows you to examine and set values as well as control the flow of execution.

Once a script has been loaded into a debugger, it can be run one line at a time or instructed to halt at certain breakpoints. Once execution is halted, the programmer can examine the state of the script and its variables in order to determine if something is amiss. You can also watch variables for changes in their values.

The latest version of the Mozilla JavaScript Debugger (code-named Venkman) for both Mozilla and Netscape browsers can be downloaded at http://www.hacksrus.com/~ginda/venkman


(th)

Offline

#3 2022-09-24 16:53:17

tahanson43206
Moderator
Registered: 2018-04-27
Posts: 17,064

Re: Java (r) or Javascript Computer Language

Among the 770 books listed by Amazon is this one:

RESULTS

Eloquent JavaScript, 3rd Edition: A Modern Introduction to Programming
by Marijn Haverbeke  | Dec 4, 2018
4.6 out of 5 stars 1,446
Paperback

It happened to be in stock at Border's Books locally, so I picked up a copy.

ISBN-13: 978-1593279509
ISBN-10: 1593279507

and...

Completely revised and updated, this best-selling introduction to programming in JavaScript focuses on writing real applications.

JavaScript lies at the heart of almost every modern web application, from social apps like Twitter to browser-based game frameworks like Phaser and Babylon. Though simple for beginners to pick up and play with, JavaScript is a flexible, complex language that you can use to build full-scale applications.

This much anticipated and thoroughly revised third edition of Eloquent JavaScript dives deep into the JavaScript language to show you how to write beautiful, effective code. It has been updated to reflect the current state of Java¬Script and web browsers and includes brand-new material on features like class notation, arrow functions, iterators, async functions, template strings, and block scope. A host of new exercises have also been added to test your skills and keep you on track.

As with previous editions, Haverbeke continues to teach through extensive examples and immerses you in code from the start, while exercises and full-chapter projects give you hands-on experience with writing your own programs. You start by learning the basic structure of the JavaScript language as well as control structures, functions, and data structures to help you write basic programs. Then you'll learn about error handling and bug fixing, modularity, and asynchronous programming before moving on to web browsers and how JavaScript is used to program them. As you build projects such as an artificial life simulation, a simple programming language, and a paint program, you'll learn how to:

- Understand the essential elements of programming, including syntax, control, and data
- Organize and clarify your code with object-oriented and functional programming techniques
- Script the browser and make basic web applications
- Use the DOM effectively to interact with browsers
- Harness Node.js to build servers and utilities

Isn't it time you became fluent in the language of the Web?

* All source code is available online in an inter¬active sandbox, where you can edit the code, run it, and see its output instantly.

Contents

     Introduction

    (Part 1: Language)

    Values, Types, and Operators

    Program Structure

    Functions

    Data Structures: Objects and Arrays

    Higher-order Functions

    The Secret Life of Objects

    Project: A Robot

    Bugs and Errors

    Regular Expressions

    Modules

    Asynchronous Programming

    Project: A Programming Language

    (Part 2: Browser)

    JavaScript and the Browser

    The Document Object Model

    Handling Events

    Project: A Platform Game

    Drawing on Canvas

    HTTP and Forms

    Project: A Pixel Art Editor

    (Part 3: Node)

    Node.js

    Project: Skill-Sharing Website

I'll try to at least skip through the book before Sunday's Zoom ...

(th)

Offline

#4 2022-09-24 17:58:09

tahanson43206
Moderator
Registered: 2018-04-27
Posts: 17,064

Re: Java (r) or Javascript Computer Language

Update regarding Post #3

I have completed page-by-page inspection of the entire book.. The folks who wrote the snippets of praise in the frontispiece seem (to my eye) to have correctly captured the quality of writing, and the careful design of the book.

There is a chapter devoted to interacting with the web from inside a browser, and that is precisely what the present undertaking is about.

Given the proven script from kbd512, using a commercial web automation product, I am guardedly hopeful that script can be translated into Javascript.  Whether that can happen in a single Zoom session remains to be seen, but I imagine it is possible.

(th)

Offline

#5 2022-09-25 11:46:20

tahanson43206
Moderator
Registered: 2018-04-27
Posts: 17,064

Re: Java (r) or Javascript Computer Language

Update regarding Post #3

On page 7, the author invites readers to visit the web site for the book.

Apparently the code for the book is available there.

The web site is given as: https://eloquentjavascript.net

and the code is reported to be available at: https://eloquentjavascript.net/code

The text below the links advises readers that the segments of code often depend upon each other.

The code may work in a browser, or in something called node.js

On Ubuntu 20.04 I tried "node.js" in the Terminal window and got this:

$ node.js
Command 'node.js' not found, did you mean:
  command 'nodejs' from deb nodejs (12.22.9~dfsg-1ubuntu3)
Try: sudo apt install <deb name>

sudo apt install nodejs
[sudo] password for tahanson:
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
  dbconfig-common libcfitsio8 libdvdread7 libjs-openlayers libridl-java
  python-backports.functools-lru-cache syslinux-common systemd-hwe-hwdb
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  libjs-highlight.js libnode72 nodejs-doc
Suggested packages:
  npm
The following NEW packages will be installed:
  libjs-highlight.js libnode72 nodejs nodejs-doc
0 upgraded, 4 newly installed, 0 to remove and 44 not upgraded.
Need to get 13.7 MB of archives.
After this operation, 53.8 MB of additional disk space will be used.
Do you want to continue? [Y/n]

After installation, I asked for the manual on node.js

DESCRIPTION
     Node.js is a set of libraries for JavaScript which allows it to be used
     outside of the browser.  It is primarily focused on creating simple,
     easy-to-build network clients and servers.

     Execute node without arguments to start a REPL.

Well, the software may have been installed, but (of course) at this point, I have no idea how to use it or even if it works.

(th)

Offline

#6 2022-09-25 12:14:23

tahanson43206
Moderator
Registered: 2018-04-27
Posts: 17,064

Re: Java (r) or Javascript Computer Language

In attempting to prepare for this evening's Zoom, I attempted to execute sample code provided by the author of Eloquent Javascript.

My initial attempts were not successful, because I am just trying things, and the book does not show precisely what to type to achieve success.

I asked Google about a Java Editor, and it offered a great number of suggestions ... one citation was for Jedit, so i asked Ubuntu to install it:

sudo apt install jedit
[sudo] password for tahanson:
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
  dbconfig-common libcfitsio8 libdvdread7 libjs-openlayers libridl-java
  python-backports.functools-lru-cache syslinux-common systemd-hwe-hwdb
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  java-wrappers
The following NEW packages will be installed:
  java-wrappers jedit
0 upgraded, 2 newly installed, 0 to remove and 44 not upgraded.
Need to get 2,357 kB of archives.
After this operation, 11.5 MB of additional disk space will be used.
Do you want to continue? [Y/n]

When I typed Jedit at the Terminal window, there was a pause, and then ** this ** showed up:

Welcome to jEdit 5.5
Useful menu commands:
To customize jEdit: Utilities>Global Options (be sure to check out the Shortcuts pane!)
To install plugins: Plugins>Plugin Manager
To customize plugins: Plugins>Plugin Options
To open this window: Help>jEdit Help
jEdit is free software, and you are welcome to redistribute and modify it under certain conditions. See the license section of the read me file for details.
If you think you have found a bug, please consult the Frequently Asked Questions document first.
To give feedback, subscribe to mailing lists or find out about the latest developments in the world of jEdit, visit www.jedit.org.

OK ... but will it run the sample code from Eloquent Javascript?

The answer to that appears to be no (at this point) ... when I entered jedit -run=intro to the terminal window, after saving the code using the jedit editor save, I got a long list of errors.

(th)

Offline

#7 2022-09-25 12:33:32

tahanson43206
Moderator
Registered: 2018-04-27
Posts: 17,064

Re: Java (r) or Javascript Computer Language

I decided to try Microsoft's Visual Studio Community version:

Thank you for downloading Visual Studio
Your download will start shortly. If your download does not begin, click here to retry

Getting started

Follow us YouTube logoTwitter logoFacebook logo

Sign up for the developer community newsletter

New to Visual Studio? Learning a new development tool can be overwhelming. Take this step-by-step learning journey at your own pace to successfully create a simple app in any language of your choice. Let’s get started!

Install Visual Studio
First please make sure to open your Visual Studio download and install. You can save installation time and disk space by selecting just the components needed. You can always incrementally add more components later at any time as needed.

Getting Started with Visual Studio IDE
video screenshot
To develop any type of app or learn a language, you’ll be working in the Visual Studio Integrated Development Environment (IDE). Beyond code editing, Visual Studio IDE brings together graphical designers, compilers, code completion tools, source control, extensions and many more features in one place. Watch this short video to get familiar with the IDE and to learn how to use it for basic tasks.

Make it your own with themes and more
Prefer dark theme? Want to change the layout of windows to your liking? Have favorite keyboard shortcuts? Check out this short video where we walk you through some cool personalization options like themes, fonts, window layout and custom keyboard shortcuts available in Visual Studio.

Visual Studio Personalization video screenshot
Learn how to customize even more settings from these step-by-step plural
Pick a theme
Change Fonts and Colors
Add/remove Menus and Toolbars
Move Window layout
Set familiar command shortcuts
Start a tutorial
Choose an area of development you are most interested in learning
Follow the step-by-step tutorial to gain a basic understanding of building a simple application
Complete your learning by watching the video series and following the recommended

(th)

Offline

#8 2022-09-25 12:37:52

tahanson43206
Moderator
Registered: 2018-04-27
Posts: 17,064

Re: Java (r) or Javascript Computer Language

https://code.visualstudio.com/docs/?dv=linux64_deb

Above appears to be the command to download Visual Studio for Linux 64 bits ...

There is a windows version that is offered as an exe

Update a bit later ....

Visual Studio is installed, and it opened intro.js from the Eloquent Javascript web site.

The text is displayed in an edit window, with lots of colors showing various types of text.

I click run and I presume the program executes, but there is no indication and I don't see a way to step through the code.

That's enough for now.

Hopefully answers will become available at tonight's Zoom session.

Update 2022/09/28 (th) The free Visual Studio Code tool is NOT a full IDE ... it ** is ** a code editor with features that make it useful for development.

It appears that a package called "Phoenix" may offer a near-IDE experience.  It has instantaneous update of a browser display of code in development.

The instantaneous update occurs when the developer/student clicks on File Save.

(th)

Offline

#9 2022-09-25 17:27:20

tahanson43206
Moderator
Registered: 2018-04-27
Posts: 17,064

Re: Java (r) or Javascript Computer Language

Update 2022/09/28 (th) Caution: The code quoted below MUST be edited on your machine to remove the special handling required by FluxBB

In preparation for tonight's Zoom session, I replaced a Windows 7 instance on the Zoom machine with Ubuntu 22.04.

This machine already had Visual Studio installed, but it did not have Node.js.

Installation of Node.js went smoothly, and Visual Studio was happy with the result.

I downloaded the sample code from Eloquent Javascript, and plugged it into the Visual Studio edit window.

Clicking Run gave the correct result of 55.

here is what a snapshot of the edit window looks like:

// Run code here in the context of Chapter 0
console.log(sum(range(1, 10)));

function range(start, end, step) {
  if (step == null) step = 1;
  var array = [];

  if (step > 0) {
    for (var i = start; i <= end; i += step)
      array.push(i);
  } else {
    for (var i = start; i >= end; i += step)
      array.push(i);
  }
  return array;
}

function sum(array) {
  var total = 0;
  for (var i = 0; i < array.length; i++)
    total += array(had to replace expression [ i ] here, to appease FluxBB)
  return total;
}

function factorial(n) {
  if (n == 0) {
    return 1;
  } else {
    return factorial(n - 1) * n;
  }
}

Caution! The line total += array MUST be edited back to original or an error will occur array(expression)

Output shows up in the DEBUG CONSOLE window below the edit space. Value is 55

Update 2022/09/28 (th) The experiment reported above was performed in the sandbox on the author's web site.

To perform the same experiment in an ordinary browser, activate the Console Log feature of the browser.

For Chrome, use Menu >> Tools >> Javascript Console
For Firefox, use Menu >> Tools >> Web Developer >> Web Console

Note: To run the code above in a browser, it needs to have an html wrapper.

(th)

Offline

#10 2022-09-25 17:31:30

tahanson43206
Moderator
Registered: 2018-04-27
Posts: 17,064

Re: Java (r) or Javascript Computer Language

As a follow up to Post 9 above ... literally ** anyone ** around the world whose computer runs Windows, Apple or Linux should be able to reproduce the result shown above.

I'd be interested in seeing the result if anyone else who is currently a member decides to try it.

If there is someone not already a member who would like to join this dive into JavaScript, see the Recruiting topic for procedure.

Please note that the entire Elequent Javascript manuscript appears to be available to download for free.

As an experiment I downloaded an ePub version, and when I opened it I found what appeared to be HTML rendering, as would be appropriate to run in a browser.

(th)

Offline

#11 2022-09-26 17:36:22

tahanson43206
Moderator
Registered: 2018-04-27
Posts: 17,064

Re: Java (r) or Javascript Computer Language

Here's a little gift program (html and Javascript) that came from kbd512.

    <html>
    <head>
    <script type ="javascript">
    fx_run() {
    var startID = document.getElementById('startingID').select();
    //var endID = document.getElementById('endingID').select();

    window.alert('test test test');
    };
    </script>
    </head>
    <body>
    <input id="startingID" type="text"/>
    <input id="endingID" type="text"/>
    <input id="runScript" type="button" onclick="fx_run();" />
    </body>
    </html>

The console sample quoted in Post #9 should be able to run in the sample program, with addition of an output window.

(th)

Offline

#12 2022-09-26 19:50:14

SpaceNut
Administrator
From: New Hampshire
Registered: 2004-07-22
Posts: 28,838

Re: Java (r) or Javascript Computer Language

I finally found the code from before

kbd512 wrote:

SpaceNut,

The first part of the Katalon Recorder script is something like this:

Command | Target | Value
open | http://newmars.com/forums/admin_bans.php
pause | 3000
store | 10002 | ii
while | ii<10005
type | name=form[username] | testid${ii}
click | name=find_ban
pause | 2000
click | link=Remove
pause | 2000
storeEval | ${ii}+1 | ii
endWhile

Yes, I know it can be improved with appropriate wait commands, but this is to roughly illustrate the first part of the script.

I assume this is what you had in mind.

I'll create the second part of the script tomorrow.  My brain is fried from work and I only slept a few hours last night.

Offline

#13 2022-09-27 10:17:33

tahanson43206
Moderator
Registered: 2018-04-27
Posts: 17,064

Re: Java (r) or Javascript Computer Language

For SpaceNut re #12

Thank you for engaging with us in this initiative.

The goal is to create a piece of software (a text file) that you can run on your computer.

However, this effort is for naught if you are not willing to use it.

The process is going to take a while, because the knowledge/skill possessed by kbd512 needs to (somehow) flow from his brain through mine into yours.

Along the way, the opportunity ** should ** be available for other members (or perhaps future readers) to learn something.

I have the distinct advantage of NOT knowing much about Javascript, or more than the rudiments of html.

Accordingly, the process of translating the script you posted in #12, into something you can (and will) run on your computer can take place is simple steps that anyone ** should ** be able to replicate on their own computers.

The reference book I am using is given in Post #3

This book is (apparently) available to download for free from the author's web site:  https://eloquentjavascript.net/code

That said, the key to any success we may achieve is due to the running start provided by kbd512, as shown in Post #11

This code was left unfinished, so that we (whoever "we" turn(s) out to be) can finish it ...

In the next post, I will report a bit of sample code from a website called quackit.com

This code has the distinct advantage of showing both input and output in a running html file.

However, the code has a distinct dis-advantage, in that it updates instantaneously whenever input is changed.

What is needed for the TestID Upgrade application is a button that runs ONLY when you click on it.

The goal is to provide you with an input screen for the starting TestD number, and the number you want to reach.

The output of the run ** should ** be a display of status as the program updates each TestID.

You should have the ability to stop the run at any time. I'm not sure how to do that, but closing the browser is certainly an option.

(th)

Offline

#14 2022-09-27 10:24:51

tahanson43206
Moderator
Registered: 2018-04-27
Posts: 17,064

Re: Java (r) or Javascript Computer Language

This post is about a sample html program/file offered by a website called quackit.com.

Interest Calculator Amount to invest: $

Interest Rate: 0%

Interest Received: $0
// quackit.com example

Above is what you should see on your browser when you run the program.

Here is the program code, as downloaded from quackit.com

<form onsubmit="return false" oninput="amount.value = (principal.valueAsNumber * rate.valueAsNumber) / 100">
<fieldset> 
<legend style="font-weight:bold;">Interest Calculator</legend>
<label for="principal">Amount to invest: $</label>
<input type="number" min="0" id="principal" name="principal" value="1000">
<p><label for="rate">Interest Rate: </label>
<input type="range" min="0" max="20" id="rate" name="rate" value="0" oninput="thisRate.value = rate.value">
<output name="thisRate" for="range">0</output><span>%</span></p>
<p>Interest Received: <strong>$<output name="amount" for="principal rate">0</output></strong></p>
</fieldset>
</form>
// quackit.com example

Procedure:

Copy the demo code from the quote box and paste it into a file.
Then locate the file with a file browser on your computer.
This code should work on any current operating system or browser.

When you have located the code file, right click to display options, and select Open With.

Chose a browser, and open the file.

The browser should open the file and show the page in the first quote in this post.

The goal for the next phase of this initiative is to adapt the working sample code so it performs according to the guide provided by kbd512.

The operator will enter starting and ending numbers, and nothing will happen until the operator clicks a Run button.

Staying with the model from Quackit.com for the moment, what I am looking for is code that will perform the Interest calculation when the operator clicks a button.

At present, the sample code instantaneously updates when any input window is changed.

That is NOT what we want for this project.

(th)

Offline

#15 2022-09-27 12:18:35

tahanson43206
Moderator
Registered: 2018-04-27
Posts: 17,064

Re: Java (r) or Javascript Computer Language

This sample program comes a little closer to what we are looking for ... it has an online prompt for input, and it produces output.

<html> 
<body> 
<script> 
 
// program to create a simple calculator using the if...else...if in JavaScript. 
// take the operator from the user through prompt box in JavaScript. 
const operator = prompt('Enter operator to perform the calculation ( either +, -, * or / ): '); 
 
// accept the number from the user through prompt box 
const number1 = parseFloat(prompt ('Enter the first number: ')); 
const number2 = parseFloat(prompt ('Enter the second number: ')); 
 
let result; // declaration of the variable. 
 
// use if, elseif and else keyword to define the calculator condition in JavaScript. 
if (operator == '+') { // use + (addition) operator to add two numbers 
    result = number1 + number2; 

else if (operator == '-') { // use -  (subtraction) operator to subtract two numbers 
    result = number1 - number2; 

else if (operator == '*') { // use * (multiplication) operator to multiply two numbers 
    result = number1 * number2; 

else { 
    result = number1 / number2; // use / (division) operator to divide two numbers 

 
// display the result of the Calculator 
window.alert(" Result is" + result); 
</script> 
<body> 
</html> 

// https://www.javatpoint.com/javascript-calculator

The sample program should run in anyone's browser, and on any of the major operating systems.

Paste the text into a text editor, save the file as ".html", and use the file browser to open the file with an Internet browser.

(th)

Offline

#16 2022-09-27 20:04:15

SpaceNut
Administrator
From: New Hampshire
Registered: 2004-07-22
Posts: 28,838

Re: Java (r) or Javascript Computer Language

Back when I was looking at the msql-bin log files in 2015
I was making use of this website to pull posts and web pages out of the garbage file.

http://www.w3schools.com/


Here is what a post looks like in that file after junk is removed.

newmars_forums INSERT INTO phpbb_posts  (forum_id, poster_id, icon_id, poster_ip, post_time, post_approved, enable_bbcode, enable_smilies, enable_magic_url, enable_sig, post_username, post_subject, post_text, post_checksum, post_attachment, bbcode_bitfield, bbcode_uid, post_postcount, post_edit_locked, topic_id) VALUES (57, 2783, 0, '96.242.163.72', 1241932731, 1, 1, 1, 1, 1, '', 'Re: Terraforming Ceres', 'Well, for a thin dome.  You do after all want a pressure in the region of 400 kPa.  On Ceres (about 1/40 g), you would need 1600 tonnes/m^2 to gravitationally account for the pressure.\n\nThat said, it won't be a huge problem, since most polymers could do that in a millimeter or less.', '8b1d2c15b991cb0766da48366ed36420', 0, '', '24496j6f', 1, 0, 7777)
newmars_forums UPDATE phpbb_config
    SET config_value = '123742'
    WHERE config_name = 'num_posts'

newmars_forums INSERT INTO phpbb_posts  (forum_id, poster_id, icon_id, poster_ip, post_time, post_approved, enable_bbcode, enable_smilies, enable_magic_url, enable_sig, post_username, post_subject, post_text, post_checksum, post_attachment, bbcode_bitfield, bbcode_uid, post_postcount, post_edit_locked, topic_id) VALUES (11, 2783, 0, '96.242.163.72', 1241932894, 1, 1, 1, 1, 1, '', 'Re: Magnetic Field Generators', 'That's probably true.  Also, if (Or when  <!-- s:wink: --><img src="{SMILIES_PATH}/icon_wink.gif" alt=":wink:" title="Wink" /><!-- s:wink: --> ) we terraform mars, there will likely be a large northern ocean, so it's probably better to go either equatorial or web.\n\nWhat are the possibilities for running the mag. field through the salty northern ocean?', '009bd794c5a4ffcd3333c25665111a84', 0, '', 'i6p5m5pp', 1, 0, 6780)
newmars_forums UPDATE phpbb_config
    SET config_value = '123743'
    WHERE config_name = 'num_posts'

of course this was all cleaned by hand at the time.

So when i get time to focus yes I will see how I can take what you are posting and put it to use.

Offline

#17 2022-09-27 21:31:50

tahanson43206
Moderator
Registered: 2018-04-27
Posts: 17,064

Re: Java (r) or Javascript Computer Language

For SpaceNut ... re Post #16

Thanks for showing us the MySQL detail for two posts, and for indicating when the time comes you'll be willing to take a look at what we might be able to put together.

In working with html samples today, and experimenting with various Javascript, I was reminded forcefully of why I decided not to pursue this path for the initial work.  I used a familiar language and tools, and despite some hurdles along the way, was able to achieve results.

The behavior of html and Javascript seems completely non-intuitive to me (at this point). 

The sample program from kbd512 was a teaser to inspire study.  It was definitely an "exercise for the reader", because it does not actually do anything.

I have found a variety of working Javascript examples, such as an interest calculator, and a very nice four function calculator which take input and produce output, but at this point I have no idea how the text in the scripts results in working behavior in a browser.

Thank goodness you're not in need of this functionality!

(th)

Offline

#18 2022-09-28 06:34:31

tahanson43206
Moderator
Registered: 2018-04-27
Posts: 17,064

Re: Java (r) or Javascript Computer Language

StackExchange provided a recommendation to this web site:

https://www.kirupa.com/html5/running_yo … t_time.htm

The author tackles the challenge of explaining how a web page loads, and explains the order in which various steps occur.

SearchTerm:html order of execution of loading a web page

(th)

Offline

#19 2022-09-28 06:40:36

tahanson43206
Moderator
Registered: 2018-04-27
Posts: 17,064

Re: Java (r) or Javascript Computer Language

From the text at the kirupa.com site, I have copied this ...

<!DOCTYPE html>
<html>
<body>
    <h1>Example</h1>
    <script>
        console.log("inline 1");
    </script>
    <script src="external1.js"></script>
    <script>
        console.log("inline 2");
    </script>
    <script src="external2.js"></script>
    <script>
        console.log("inline 3");
    </script>
</body>
</html>

At this point, I have no idea what will happen if this text is saved to a file and then called to run in a browser.

My main reason for uncertainty is my lack of confidence of where the console.log output is going.

In addition, since alert did (does) not work in the sample code provided by kbd512 to start the learning process, i am not confident it will work here.

OK ... I "ran" the test and the browser shows "Example" in bold text, but the console.log does not show up, and I have no idea where to look for it.

Answer: Chrome has a Console display ... to activate it, Go to Settings >> Tools >> JavaScript Console

Boy! That made a difference!

inline 1 Test.html:6
inline 2 Test.html:10
Failed to load resource file:///tmp/external1.js
inline 3 Test.html:14
Failed to load resource file:///tmp/external2.js

The two error messages about failing to load a resource occurred because I do not have those two external files on this system.

Thanks to Mr. Kirupa, I have a glimmer of hope of being able to puzzle out why the button is not working in the starter code from kbd512.

Remember, that starter code was intended to stimulate the learning process, and NOT to solve the problem.  It provides a glimpse of what a working program might look like, but it leaves it up to the student to fill in the details.

Anyone who is following along ** should ** be able to reproduce those results.

(th)

Offline

#20 2022-09-28 10:26:04

tahanson43206
Moderator
Registered: 2018-04-27
Posts: 17,064

Re: Java (r) or Javascript Computer Language

This post reports success finding an html wrapper for javascript snippets....

Please note that the array expression must be edited after it is copied out of the quote below..

FluxBB uses square brackets for processing. Those had to be replaced in the copy.

// Copy of Sample from kirupa.com combined with sample from Book: Eloquent Javascript
// Please replace braces with brackets in line 37. FluxBB objects to brackets around i
<!DOCTYPE html>
<html>
<body>
    <h1>Example</h1>
    <script>
        console.log("inline 1");
    </script>
    <script src="external1.js"></script>
    <script>
        console.log("inline 2");
    </script>
    <script src="external2.js"></script>
    <script>
        console.log("inline 3");
    </script>
    <script>
// Run code here in the context of Chapter 0
console.log("Test inside book script");
console.log(sum(range(1, 10)));
function range(start, end, step) {
  if (step == null) step = 1;
  var array = [];
  if (step > 0) {
    for (var i = start; i <= end; i += step)
      array.push(i);
  } else {
    for (var i = start; i >= end; i += step)
      array.push(i);
  }
  return array;
}
function sum(array) {
  var total = 0;
  for (var i = 0; i < array.length; i++)
    total += array{ i }
  return total;
}
function factorial(n) {
  if (n == 0) {
    return 1;
  } else {
    return factorial(n - 1) * n;
  }
}
</script>
</body>
</html>

Reminder! The expression array{i} must be edited back to brackets before it is run in a browser

Note 2: If you want to experiment with the external file references, you can create little .js files.

The purpose of the demo is to show that you can call javascript on your hard drive from within a running JavaScript.

I'd be interested if any member is able to run the above. Remember that output is visible using the Console Log feature of your browser.

Also note! The console log feature is NOT activated when you first load the code.  Your procedure is to load the code, activate Console Log, and then refresh the page, using either F5 or the Refresh button of the browser.

(th)

Offline

#21 2022-09-28 10:43:10

tahanson43206
Moderator
Registered: 2018-04-27
Posts: 17,064

Re: Java (r) or Javascript Computer Language

For SpaceNut ... just FYI ... I've stored a generic html wrapper for JavaScript experiments in Post #1 of the topic.

A copy will be placed here for the record, but this copy will flow under the bridge to oblivion.

// Wrapper html from kirupa.com
<!DOCTYPE html>
<html>
<body>
    <h1>Example</h1>
    <script>
    // insert your script here
       console.log("inline 1");
    </script>
</script>
</body>
</html>
// Activate Console Log feature from Tools in your browser

(th)

Offline

#22 2022-09-28 12:40:41

tahanson43206
Moderator
Registered: 2018-04-27
Posts: 17,064

Re: Java (r) or Javascript Computer Language

SearchTerm:External resource for JavaScript run inside html wrapper

For SpaceNut .... just FYI ....

I built a bit on the sample code from kirupa.com ...

In this version, I've added a call to a local (hard drive) resource.

What I learned is NOT to put <script> </script> into the external resource....

Where this is headed (I hope) is the ability to rapidly try JavaScript snippets without having to restart the browser.

Instead, after updating the external resource, it should be possible to call it from the browser by just activating F5 or the browser refresh button.

In the mean time, here are the two elements needed:

Save the file below as (whateveryoulike).html

// Wrapper html from kirupa.com
<!DOCTYPE html>
<html>
<body>
    <h1>Example</h1>
    <script>
    // insert your script here
       console.log("inline 1");
    </script>
    <script src="external2.js"></script>
</body>
</html>
// Activate Console Log feature from Tools in your browser
// Refresh with F5 or button to repeat a run

Right click on the file you've created and select a browser to run the file.

Note that the external resource needs to be in the same directory/folder as the html file itself!

Save the file below as "external2.js"

console.log("inline 2 external");

Note: the file name of the external file ** must ** be all lower case, to match the JavaScript call.

Update after testing on Windows 7 (expect the same on Windows 10)

The file containing html must have a last name of ".htm"

when the Linux last name (file type) of html is used, the file is opened only as text.

Changing the file type to "htm" allowed the html to run as expected, and the output appears in the console.

Note that in the Edge running in Windows 7, the Console output window is found within a great number of developer features.

It is there, with the title: Console

Offline

#23 2022-09-28 17:50:19

kbd512
Administrator
Registered: 2015-01-02
Posts: 7,426

Re: Java (r) or Javascript Computer Language

tahanson43206,

It was simply something I forgot or left out.  This works for me in Firefox:

<html>
    <head>
        <title>JavaScript Test</title>
        <script type ="text/javascript">
            function fx_run() {
                var startID = document.getElementById('startingID').value;
                var endID = document.getElementById('endingID').value;
                window.alert('Starting ID: ' + startID + ' Ending ID: ' + endID);
            }
        </script>
    </head>
    <body>
        <input id="startingID" type="text"/>
        <input id="endingID" type="text"/>
        <button id="runScript" type="button" onclick="fx_run();">Click Here</button>
    </body>
</html>

Online

#24 2022-09-28 18:23:26

tahanson43206
Moderator
Registered: 2018-04-27
Posts: 17,064

Re: Java (r) or Javascript Computer Language

For kbd512 re #23

Thank you for whatever adjustments you made!  The revised sample program works on Microsoft Edge in Windows 7.

The button says: Click here 

The alert shows up as:

This page says

Starting ID: asdfasf Ending ID: asfasdf

[OK]

Nice!

Offline

#25 2022-09-28 18:30:17

tahanson43206
Moderator
Registered: 2018-04-27
Posts: 17,064

Re: Java (r) or Javascript Computer Language

For SpaceNut re update from kbd512 ...

You'll be testing on Windows (I'm pretty sure)

To insure the code from kbd512 works on your machine, be sure to save the file as type "htm"

The Linux type of "html" causes confusion, so that the program will not run.

When you click on the file and select Edge (or Firefox) the program should open and display:

[ starting ID window ]  [ Ending ID window ] [button Click here]

You can put anything you want into the windows at this point.

The button will display whatever you entered.

Thanks again to kbd512 for this running start!

(th)

Offline

Board footer

Powered by FluxBB