Solved

help with combining small codes into one big one!

Posted on 2011-03-01
4
470 Views
Last Modified: 2012-06-21
i have three scripts i want to merge them together .. and so far i havent been successful!
import bugdisp
import time

 
for i in range(1, 2):
	bugdisp.sendCommand('savetext c:\hi2393993.txt ' )
	time.sleep(100)

Open in new window

import time
import bugdisp

for i in range(1, 10):
	bugdisp.sendCommand('x A90 1')
	time.sleep(1)

Open in new window

import os


os.system('wbugdisp.exe')
time.sleep(5)

Open in new window

0
Comment
Question by:zoomer003
  • 2
4 Comments
 
LVL 16

Expert Comment

by:sjklein42
ID: 35009288
I am not a Python expert but this should give you the idea.

You are merging three timer-based loops.  The way to do that is to create a new timer-based loop with the least-common-denominator of the individual timers.  In this case, I made it a one-second loop.  Each time through the loop, each of your actions "checks" to see if it is time for it to execute.  If so, it does.  Then wait a second and check again to see what needs to be done.

import bugdisp
import time
import os

# for 101 seconds, check each second ...

for i in range(0, 100):
	# First time only, start wbugdisp
	if ( i == 0 ): os.system('wbugdisp.exe')

	# First and last time, savetext
	if ( i == 0 ) || ( i == 100 ): bugdisp.sendCommand('savetext c:\hi2393993.txt ' )

	# Every ten seconds, do it
	if ( i < 10 ) == 0: bugdisp.sendCommand('x A90 1')

	# Wait for the next second to tick
	time.sleep(1)

Open in new window

0
 
LVL 6

Expert Comment

by:LeeeRussell
ID: 35009302
What do you want the merged script to do?  I don't think that's obvious from the question you've asked.
0
 
LVL 16

Accepted Solution

by:
sjklein42 earned 500 total points
ID: 35009374
Sorry, I had a typo in the last test.

import bugdisp
import time
import os

# for 101 seconds, check each second ...

for i in range(0, 100):
	# First time only, start wbugdisp
	if ( i == 0 ): os.system('wbugdisp.exe')

	# First and last time, savetext
	if ( i == 0 ) || ( i == 100 ): bugdisp.sendCommand('savetext c:\hi2393993.txt ' )

	# For the first ten seconds, do this
	if ( i < 10 ): bugdisp.sendCommand('x A90 1')

	# Wait for the next second to tick
	time.sleep(1)

Open in new window

0
 

Author Closing Comment

by:zoomer003
ID: 35018140
Thank you
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Variable is a place holder or reserved memory locations to store any value. Which means whenever we create a variable, indirectly we are reserving some space in the memory. The interpreter assigns or allocates some space in the memory based on the d…
Here I am using Python IDLE(GUI) to write a simple program and save it, so that we can just execute it in future. Because when we write any program and exit from Python then program that we have written will be lost. So for not losing our program we…
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question