Solved

help with combining small codes into one big one!

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

"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 …
Article by: Swadhin
Introduction of Lists in Python: There are six built-in types of sequences. Lists and tuples are the most common one. In this article we will see how to use Lists in python and how we can utilize it while doing our own program. In general we can al…
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 …

757 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now