Solved

help with combining small codes into one big one!

Posted on 2011-03-01
4
473 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 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

Enroll in July's Course of the Month

July's Course of the Month is now available! Enroll to learn HTML5 and prepare for certification. It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

"The time has come," the Walrus said, "To talk of many things: Of sets--and lists--and dictionaries-- Of variable kinks-- And why you see it changing not-- And why so strange are strings." This part describes how variables and references (see …
The purpose of this article is to demonstrate how we can use conditional statements using Python.
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 modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…

626 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