Searching in files for some code lines. My script for first line:
FileReadLine, OutputVar, C:\Files\prog.txt, 1
If (OutputVar = "FileRead, OutputVar, C:\Files\prog1.txt")
MsgBox Code line found
else
MsgBox Code line not found
How searching by this method in some area? Lines from 50 to 250, 205 to 551, etc.
Use a file parsing loop: http://ahkscript.org/docs/commands/LoopReadFile.htm
Loop, read, C:\Files\prog.txt
{
If (A_LoopReadLine = "FileRead, OutputVar, C:\Files\prog1.txt") {
MsgBox, An interesting code line was found.
} Else If (A_LoopReadLine = "blablabla") {
MsgBox, An interesting code line was found.
} Else If (A_LoopReadLine = "some other text line") {
MsgBox, An interesting code line was found.
;} Else {
; MsgBox, Nothing important was found
;}
}
Related
I hope that when I press enter, Can judge whether there is "好" or "玩啊" or "GO" or "要",If not, it will be executed "Game termination!"
%pylab inline
start = input("玩猜數字遊戲嗎?")
if start in "好" or "玩啊" or "GO" or "要":
print("遊戲開始`enter code here`,已從0-100產生一個數字")
print("您有3次錯誤的機會")
a = randint(0, 101)
print(a)
for i in range(3):
s = input("請輸入一個數字")
s = float(s)
if s == a:
print("恭喜你答對了!!!!!!!!")
break
else:
print("答錯了,已使用{}條命".format(i+1))
i = i+1
while i ==3:
print("遊戲結束Game Over")
break
else:
print("Game termination!")
But I found that as long as there is the same as [start = input("玩猜數字遊戲嗎?")] , If you can’t judge, you will execute if,not else
you need to use
if start in ["好", "玩啊", "GO", "要"]:
just put all the items to be compared inside a list.
can you guys help me, i have added a flag, however it skips teleport() and keeps walksouth() any idea why? I'm kinda newbie here i hope you guys help me
walk1 := 0
loop {
teleport()
}
teleport()
{
if (walk1 => 1) ;this never worked even i added flag walk1:=1 :( please help
send, {f9}
sleep, 500
walk1 := 0
return
} else if (walk1 <= 0){
walksouth()
return
}
}
walksouth() { ;this keeps running and skipping teleport()
send, {f5}
sleep, 500
walk1 := 1 ;added flag 1 to run the teleport, but still skipping
return
}
This is your corrected and refactored code:
walk := false
loop {
teleport()
}
teleport()
{
global walk
if (walk) {
send {f9}
walk := false
} else {
send {f5}
walk := true
}
sleep 500
}
Bugs in your code:
Variables in functions have local scope unless they are declare using global. So the walk1 variables in your functions and the global walk1 are all different variables
You are missing an open brace { after if (walk1 => 1)
My program stucks while executing a command. Can we add a delay timeout in order to proceed even if there is no response from command line ?
try {
if (System.getProperty("os.name").toUpperCase().indexOf("WINDOWS") != -1)
{
p = Runtime.getRuntime().exec("cmd.exe /C " + line);
int exitCode = p.waitFor();
}
else
{
p = Runtime.getRuntime().exec( line );
}
Your question is very vague; I can't really tell what you're asking. However, from what I understand, a break() statement may be of use to you. Perhaps using Thread.sleep() followed by a break()?
I am trying to instrument all the if statements in a C program. For example
if(condition)
statement1;
else
statement2;
is instrumented to
if(condition)
{
statement1;
}
else
{
statement2;
}
I have the following code for instrumentation
void MyRecursiveASTVisitor::InstrumentStmt(Stmt *s)
{
// Only perform if statement is not compound
SourceLocation ST = s->getLocStart();
if (!isa<CompoundStmt>(s)) {
//insert an opening brace if not present
Rewrite.InsertText(ST, "{\n", true, true);
ST = s->getLocEnd();
ST = ST.getLocWithOffset(1);
Rewrite.InsertText(ST, "\n}\n", true, true);
}
return true;
}
This works fine for almost all of the cases. However, in the case when the statement is a MACRO expansion
else
WARN((stderr,"%s: %s is a directory -- ignored\n", progname, ifname));
I get an assertion failure
Assertion `0 && "Invalid SLocOffset or bad function choice"' failed.
Can anyone explain why is this happening? Is there some special case for handling macros in clang?
I am creating an application which is text file reader but It reads the text file content line by line and then if a reserved word is red a function will execute.
For example I have a text file that contains the reserve word [PlaySound]+ sound file on its first line, when the reader reads the line a function will execute and plays the music file that is with the reserve word.
So is it possible to create this? and if it is how can i make the line reader?
File file = new File("inputFile.txt");
Scanner sc = null;
try {
sc = new Scanner(file);
String line = null;
while (sc.hasNextLine()) {
String soundFile = null;
line = sc.nextLine();
if (line.indexOf("[PlaySound]") >= 0) {
soundFile = // some regex to extract the sound file from the line
playSoundFile(soundFile);
}
}
sc.close();
}
catch (FileNotFoundException e) {
e.printStackTrace();
}
finally {
if (sc != null) { sc.close(); }
}