logo
down
shadow

can't get my program to return to main loop


can't get my program to return to main loop

By : Jobslash Australia
Date : October 19 2020, 08:10 AM
wish helps you I can't get the bottom part of this code to work. I want the user to be able to type "back" and return to the main menu. Is there anyone that can help, and that can explain why it wont work the way I have done it here? , You may want to change writetxtfile() to:
code :
def writetxtfile():
    try:
        openfile = input("Enter the .txt file name, or type 'back' to go back to menu: ")
        if openfile == "back":
            return
        else:
            with open(openfile, 'r') as rf:
                f_content = rf.read()
                print("Current file text:",f_content)
                print("\n")
            writeinput  = input("What would you like to write?")
            with open(openfile, 'a') as wf:
                wf.write(" " + writeinput)
                wf.close()
    except:
        print("Invalid input")
        writetxtfile()


Share : facebook icon twitter icon
Is there a function in Android analogous to "int main" in C/C++ which contains the program's main loop?

Is there a function in Android analogous to "int main" in C/C++ which contains the program's main loop?


By : Dennis
Date : March 29 2020, 07:55 AM
may help you . As far as an Android program is concerned there is no main(). There is a UI loop that the OS runs that makes calls to methods you define or override in your program. These methods are likely called from/defined in onCreate(), onStart(), onResume(), onReStart(), onPause(), onStop(), or onDestroy(). All these methods may be overriden in your program.
The fundamental issue is that the OS is designed to run in a resource constrained environment. Your program needs to be prepared to be halted and even completely stopped whenever the OS needs more memory (this is a multitasking OS). In order to handle that your program needs to have some of all of the functions listed above.
Use threading in a loop, how to finish for loop before reaching to end of the main program?

Use threading in a loop, how to finish for loop before reaching to end of the main program?


By : valander
Date : March 29 2020, 07:55 AM
wish help you to fix your issue You can use join() to wait for other thread to finish. Your code need to be updated as follows:
code :
public static void main( String [] args ) {

    System.out.println( "Starting Main" ) ;
        Thread numberThread;
        for ( int i = 1 ; i <= 5 ; i++ ) {
            numberThread = new Thread(new NumberTask(i)) ;
            numberThread.start() ;
        }
        numberThread.join();
        System.out.println( "Ending Main" ) ; 
    }
Does millis() count from the start of the main program loop or the setup loop?

Does millis() count from the start of the main program loop or the setup loop?


By : Ody dan Ica
Date : March 29 2020, 07:55 AM
seems to work fine The counter of millis() function starts from the start of your program, that means from the start of void setup() function.
Hope your confusion is solved.
Is main = return () a program?

Is main = return () a program?


By : aruntaru
Date : March 29 2020, 07:55 AM
may help you . Nothing about the definition of a program requires it to have explicit I/O. For example, consider /bin/sleep. It does literally nothing besides doing nothing for a fixed period of time. Ultimately, it does kind of have input/output, in that it "causes" (in a weak sense of the term) a change in the time.
Another example might be a Python program like:
code :
while True:
    pass
Can program return from main? Why link register has same value as that of program counter?

Can program return from main? Why link register has same value as that of program counter?


By : Spencer Redd
Date : March 29 2020, 07:55 AM
Related Posts Related Posts :
  • How to use an API that requires user's entry (Sentiment Analysis)
  • Django first app
  • Why is this regex code not working
  • Beautifulsoup - findAll not finding string when link is also in container
  • Python: any() to check if attribute in List of Objects matches a list
  • How do I "enrich" every record in a Pandas dataframe with an hour column?
  • Failing to open an Excel file with Python
  • Python function to modify string
  • Pandas DataFrame seems not to have "factorize" method
  • Row column operations in CSV
  • How to decrypt RSA encrypted file (via PHP and OpenSSL) with pyopenssl?
  • How can we use pandas to generate min, max, mean, median, ...as new columns for the dataframe?
  • Cython: creating an array throws "not allowed in a constant expression"
  • Different thing is shown in html
  • sublimetext3 event for program exit
  • Join contigous tokens if the token includes "@" char
  • transparent background in gif using Python Imageio
  • Enable autologin into flask app using active directory
  • Make a NxN array of 1x3 arrays of random numbers (python)
  • django how to use Max and Count on the same field in back-to-back annotations
  • Using the OR operator seems to only take the first of two conditions when used with np.where filter
  • Elegant Dataframe Operations in Pandas
  • Change metadata of pdf file with pypdf2
  • How can I animate a set of points with matplotlib?
  • error: (-215) count >= 0 && (depth == CV_32F || depth == CV_32S) in function arcLength
  • OpenStack KeyStone SSL Exception When Creating an Instance of KeyStone
  • pyspark: The system cannot find the path specified
  • How can I set path to load data from CSV file into PostgreSQL database in Docker container?
  • Summation in python dictionary
  • DRF 3.7.0 removed handling None in fields and broke my foreign key source fields. Is there a way around it?
  • Error with Padlen in signal.filtfilt in Python
  • Abstract matrix multiplication with variables
  • Reading binary data on bit level
  • How to replace multiple instances of a sub strings in a string using a for loop (in a function)?
  • py2neo cypher create several relations to central node in for loop
  • [python-3]TypeError: must be str, not int
  • How to exit/terminate a job earlier and handle the raised exception in apscheduler?
  • python, print intermediate values while loop
  • python to loop over yaml config
  • D3.js is not recognized by PyCharm
  • Access the regularization paths obtained from ElasticNetCV in sklearn
  • Pattern table to Pandas DataFrame
  • Get the earliest date from a column (Python Pandas) after csv.reader
  • Get SystemError: Parent module '' not loaded, cannot perform relative import when trying to import numpy in a Cython Ext
  • Bash or Python : Append and prepend a string recursively in all .tex files
  • Changing a certain index of boolean list of lists change others, too
  • complex dataframe filtering request on the last occurence of a value in Panda/Python [EDIT]
  • How to repeatedly get the contents of a Text widget every loop with tkinter?
  • How to call the tornado.queues message externally
  • How can I use regex in python so that characters not included are disallowed?
  • Discarding randmly scattered empty spaces in pandas data frame
  • Get sums grouped by date by same column filtered by 2 conditions
  • Element disappears when I add an {% include %} tag inside my for loop
  • Django Rest Framework with either a slug or a pk lookup field for the DetailAPIView
  • Flask doesn't stream on Lambda
  • Generate all permutations of fixed length where the elements come from two different sets
  • Making function for calculating distance
  • How to handle multiprocessing based on the limit of CPU's
  • Django - static files is not working
  • Remove x axis and y axis black lines with matplotlib
  • shadow
    Privacy Policy - Terms - Contact Us © voile276.org