| Author |
Message |
   
Anonymous
| | Posted on Sunday, Aug 4, 2002 - 14:51: | |
I am attempting to write a script to search for markers and am encountering some difficulty. I find the first marker ok and it does what I want it to do within a loop which then starts my problem is that when it should move on to find the next occurence of the marker it is starting from the beginning of the file and finding the same one again.I have tried moving the braces but have not as yet been able to make it move on. I realise that I am missing something very basic but I have never attempted to write a script before and would appreciate any indicators which would help me to resolve this matter. |
   
Stefan Fleischmann (Admin)
| | Posted on Sunday, Aug 4, 2002 - 15:00: | |
By default, the Find command searches the entire file or disk. Use the "Down" parameter to search only from the current position down, e.g. Find "John" MatchWord Down |
   
Anonymous
| | Posted on Sunday, Aug 4, 2002 - 23:04: | |
Thanks for your prompt reply I should have said that I had tried using the "down" parameter without success. The format I am using for the script is as follows: Find 0xVALUE 1 {iffound messagebox "text" else messagebox "text" endif move X read myvariable Y ifequal myvariable VALUE messagebox "text" endif THERE FOLLOW MORE ifequal& endif STATEMENTS AND SOME jumpto continuehere STATEMENTS THEN: ifequal myvariable VALUE messagebox "text" else messagebox "text" endif find 0xVALUE 1 down} label continuehere REST OF SCRIPT When I run the script it keeps finding the value 1 at the first ofsett it occurs at although it should have moved beyond as a result of the move statement. I am still scratching my head. |
   
Stefan Fleischmann (Admin)
| | Posted on Sunday, Aug 4, 2002 - 23:15: | |
If X is negative, and Y <= |X|, the second Find would find the same occurrence of "VALUE 1" again. It all depends on the current cursor position, not on where the last occurrence was found. You could insert another "Move Z" statement with Z>0 before Find, to be sure. |
   
Anonymous
| | Posted on Monday, Aug 5, 2002 - 0:16: | |
i have tried inserting a move statement before the find statement prior to the end of the loop to ensure that it is beyond the first occurence of value 1 but with the same result. Value 1 is found at offset 20AD5 prior to reading myvariable Y I am assuming that the cursor position should then be on the byte after myvariable Y, which is where it appears after I have cancelled.I have tried using both up and down as the parameter for the find statement but with the same result. myvariable Y occurs after value 1. I am running windows XP. |
   
Stefan Fleischmann (Admin)
| | Posted on Monday, Aug 5, 2002 - 18:00: | |
I believe that something is wrong in your script. To demonstrate that the Find command works correctly, create a text file with the following contents: "JustATestJustATestJustATest". Then run the following script on it: Goto 0 { Find "Just" Down Move 1 }[3] The Move command is needed to ensure that the same occurrence of "Just" is not found over and over again. The loop is executed three times. When script execution completes, the cursor is blinking in the last occurrence of "Just". You could start with a script as simple as this and refine it step-by-step, or send me a copy of your current script, so I can have a look. |
   
Anonymous
| | Posted on Tuesday, Aug 6, 2002 - 1:36: | |
Thank you for your advice, when I run the script suggested above the cursor remains on the second byte of the file at position Ox0001 this occurs every time I run the script. It would seem that somthing is not correct would it possibly help to try reinstalling winhex? |
   
Anonymous
| | Posted on Tuesday, Aug 6, 2002 - 3:47: | |
I have now attempted to run the script you suggested above in both win98se and xp and have tried reverting back to Winhex V10.47 on both operating systems with the same result i.e. the cursor remains on 0x0001 it appears to make the 'move 1' in line 4 and then stop! |
   
Stefan Fleischmann (Admin)
| | Posted on Tuesday, Aug 6, 2002 - 18:46: | |
Sorry, I have no explanation. Please contact me by e-mail and include your full name, thanks. |
   
Carl Garon
| | Posted on Tuesday, Aug 6, 2002 - 21:49: | |
Hi! I have tried the script: Goto 0 { Find "Just" Down Move 1 }[3] and it work well: when script execution completes, the cursor is blinking in the last occurrence of "Just". I have tried it with winhex 10.5sr-1 and win98se. |
   
Anonymous
| | Posted on Wednesday, Aug 7, 2002 - 3:21: | |
Thanks for your posting Carl I have just got it to work by copying and pasting from this page into a text file. When I write into a file I cannot get it to work. Maybe a problem with my keyboard setup as on examination the hex from the files using the different methods is not the same - I suspect the braces as it does not loop. |
   
Stefan Fleischmann (Admin)
| | Posted on Wednesday, Aug 7, 2002 - 12:28: | |
I examined the script you sent me and found out what is wrong. The documentation does not explicitly say so, but the parameters of the Find command are case-sensitive. They must be written exactly as specified. So just replace "down" with "Down" to make WinHex recognize this parameter. To avoid such errors in the future, I promise the next service release of WinHex will recognize parameters regardless of the case. |
   
Anonymous
| | Posted on Wednesday, Aug 7, 2002 - 19:14: | |
Problem solved thank you. |
   
Anonymous
| | Posted on Wednesday, Apr 9, 2003 - 5:56: | |
I have a script that opens multiple files and does a find, if found, replaces text,save then close. if not found close, then loops loop is Unlimited. How do I find out if all windows are close, what is the variable? I need it so I can exitloop. |
   
Stefan Fleischmann (Admin)
| | Posted on Wednesday, Apr 9, 2003 - 11:14: | |
ExitIfNoFilesOpen aborts script execution if no files are open in WinHex. |
   
Anonymous
| | Posted on Wednesday, Apr 9, 2003 - 22:29: | |
Please tell me why I get a BLock error. Open "C:\Documents and Settings\abc\My Documents\ABC_TEST.TXT" Goto 0 Find "XYZ" Down IfFound Assign BeginBlock CurrPos MessageBox CurrPos MessageBox "Marking Beginning Block" EndIf //Goto 0 { Find 0x0A333130 Down Move 1 }[3] Move 1 Find 0x0D0A Down Move 1 Assign EndBlock CurrPos Block BeginBlock EndBlock CopyIntoNewFile "C:\Documents and Settings\abc\My Documents\NEW_ABC.TXT" CloseAll |
   
Stefan Fleischmann (Admin)
| | Posted on Thursday, Apr 10, 2003 - 0:20: | |
I guess the problem is that the variable BeginBlock may be undefined, depending on IfFound. |
   
Troy Sorzano
| | Posted on Tuesday, Sep 13, 2005 - 15:30: | |
>>Please tell me why I get a BLock error. CurrPos is not valid you should use CurrentPos. Here is the corrected script. Open "C:\Documents and Settings\abc\My Documents\ABC_TEST.TXT" Goto 0 Find "XYZ" Down IfFound Assign BeginBlock CurrentPos MessageBox CurrentPos MessageBox "Marking Beginning Block" EndIf //Goto 0 { Find 0x0A333130 Down Move 1 }[3] Move 1 Find 0x0D0A Down Move 1 Assign EndBlock CurrentPos Block BeginBlock EndBlock CopyIntoNewFile "C:\Documents and Settings\abc\My Documents\NEW_ABC.TXT" CloseAll ------------------------------------------------------------------------ Troy Sorzano, Director www.Netforcement.com 610.260.9989 office 484.557.0125 cell PGP KeyID: 0x29D52802 285E 1829 10C1 7AC0 9D27 7077 F423 B289 29D5 2802 ------------------------------------------------------------------------ |