Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7756997
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:58:05+00:00 2026-06-01T12:58:05+00:00

Well, here is what I wanna do: I have a text field and a

  • 0

Well, here is what I wanna do:
I have a text field and a textarea that both act as a console window. I am developing a very basic simulation of an interpreter with its own programming language with javascript (jQuery), so when I start executing a program that the user has previously typed, I go through all the instructions and when an special instruction is reached (“leer”) The user has to type something into this console and pause the execution of the program, I know that the user is done typing when the ‘return’ key is pressed. When that happens the program continues its normal execution flow.

Now, this behavior is quite similar to the one of a confirmation box, because it waits for an input and when the user presses any button (yes/no) the execution continues.

I hope I have explained clear enough so that all of you guys know what my problem is. I know it would be great to place some code here, but I don’t really know what part of it would help, so in case you need some chunk of code just let me know.

Here is how the page looks like.
chmaquina execution

and here is the code used to execute every single program:

this.ejecutarPrograma = function(pidprograma) {
    var programa = this.listaProgramas[pidprograma];
    if(programa == undefined) throw "ERROR!, PID no encontrado"
    var posIni, posEnd;
    posIni = programa.obtenerRbp();
    posEnd = programa.obtenerRlc();
    this.cp = posIni;
    var temp = this.memoria[this.cp].split(/\s+/);
    while (this.cp < posEnd || temp[0] != "retorne") {
        try {
            if (temp[0] == "vaya") {
                this.cp = ACCIONES[temp[0]](this.cp, temp[1], programa);
            }
            else if (temp[0] == "vayasi") {
                this.cp = ACCIONES[temp[0]](this.memoria[0], this.cp, temp[1], temp[2], programa);
            }
            else if (temp[0] == "nueva" || temp[0] == "etiqueta" || temp[0] == "retorne") {
                // nada de nada por aca porque estos ya estan implementados
                this.cp++;
            }
            else {
                this.memoria[0] = ACCIONES[temp[0]](this.memoria[0], temp[1], programa);
                this.cp++;
            }
            var temp = this.memoria[this.cp].split(/\s+/);
        }
        catch (e) {
            throw "Linea " + (this.cp).toString() + ": " + e;
        }
    }
};

ACCIONES is an associative array that keeps the names of the instruction and as a value has the function, the instruction “leer” is empty it just gets a value from the input and copies that value in a variable of the program

Thanks for everyone’s help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T12:58:06+00:00Added an answer on June 1, 2026 at 12:58 pm

    I’m not sure I completely understand the question, but it sounds like you’re looking for the prompt function.

    For example:

    prompt('Please enter your input.');
    

    After the user clicks OK, the input is returned as a string. If they click cancel, null is returned.

    Edit:

    After seeing your comments on imsky’s answer, I think I have a better understanding of what you want to do. Correct me if I’m wrong.

    You have a loop that you want to run continuously until the user does something, at which point you want your loop to wait for the user to finish, then continue execution of the loop?

    If this is the case, try putting your loop in a function and use setTimeout(yourfunction,0); Every iteration of the function, check if the user has done something (which means setting a variable when the user does something and checking it from within yourfunction(). If the user hasn’t done something, continue looping (by using the setTimeout trick), otherwise do whatever you need to, after which you can again call yourfuntion(). The only catch here is that you can’t interrupt yourfunction in the middle of exectution, just inbetween each “loop”.

    Here’s an example: http://jsfiddle.net/PYabX/

    Does this make sense, or am I completely off?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Well, here is my problem: I have an application that uses a custom Javascript
OK, I have my site going pretty well here: http://www.marioplanet.com But I've realized that
I have some code like this, well here is the part that is most
Well here is the thing, I have MainForm that call OrderForm.Show(). Now I want
I have a code that works well here: #!/usr/bin/perl use strict; use warnings; use
Here is my code (well, some of it). The question I have is, can
If the title wasn't clear, ill try to explain it well here. I have
Well here is my query and and it works fine and the field friend_id
Well here's my problem I have three tables; regions, countries, states. Countries can be
Well here is my problem: I have a table with an iframe in the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.