Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

help with combining small codes into one big one!

Posted on 2011-03-01
4
Medium Priority
?
474 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

This article will show the steps for installing Python on Ubuntu Operating System. I have created a virtual machine with Ubuntu Operating system 8.10 and this installing process also works with upgraded version of Ubuntu OS. For installing Py…
When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
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…
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
Suggested Courses

722 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