Staredit Network > Forums > SC1 UMS Theory and Ideas > Topic: Find&Replace Program for text based Triggers
Find&Replace Program for text based Triggers
Feb 3 2009, 6:26 pm
By: Ahli  

Feb 3 2009, 6:26 pm Ahli Post #1

I do stuff and thingies... Try widening and reducing the number of small nooks and crannies to correct the problem.

Since I need to practice c++, I will create a program that can replace Strings in trigger texts.

Other programs I found for free were not good enough.

What my program could be able to do in the end:
  • don't override the source file, create new file with the replaced data done
  • the find and replace list should be easily swappable done, but in 2 files :S not that easy to edit like a table
  • shouldn't replace already replaced names [/color] done
    (replace zergling with Overlord; later: replace Overlord with Zergling)
    {user won't have troubles with a wrong order in his lists}
  • a mode that disables the possibility to override not variable parts in the trigger text like overriding "Set Deaths"
  • a mode that won't allow to replace strings in operations that create/remove/modify units or centering locations
    (I would have needed that feature when you try tp get your trigger code out of your map's finished triggers)

I need more ideas for the program's functions.

Atm, I already made a running program that can replace Strings (executes wrong order) like every basic find&replace program.
Currently used files excluding the program's exe:
  • find.ini
    contains the list of the elements that should be replaced
  • replace.ini
    contains the list of the Strings that should be appear instead of the one in the replace.ini in the same row
  • data.trigger
    contains the trigger text
  • settings.ini
    unused atm. It will contain the mode settings.
I would like to use a system that would allow you to have a table in 1 file and easily switch both sides.
Excel can do that but I cannot read data out of excel's data format.
Maybe somebody has better ideas for that.


So, Ideas for my project please... :D

Post has been edited 2 time(s), last time on Feb 5 2009, 11:32 am by Ahli.




Feb 3 2009, 7:27 pm PridefulOne Post #2



For the Find/Replace table, you could just have a list of all units, then a "|" followed by the replacement surrounded by Quotes. This isn't quite a Data Table, but if you could make your program decipher it, it'd be almost equally useful.



None.

Feb 3 2009, 7:54 pm NudeRaider Post #3

We can't explain the universe, just describe it; and we don't know whether our theories are true, we just know they're not wrong. >Harald Lesch

When using find or find/replace display lines before AND after the found entry.
In notepad you have trouble determining which trigger is found, because you can't see anything above the line you found.




Feb 3 2009, 8:05 pm Ahli Post #4

I do stuff and thingies... Try widening and reducing the number of small nooks and crannies to correct the problem.

Quote from NudeRaider
When using find or find/replace display lines before AND after the found entry.
In notepad you have trouble determining which trigger is found, because you can't see anything above the line you found.
atm I would only replace all data...
but that is sth I could do later on (mode).

Note that you have only window's console as output dfor that purpose.

Post has been edited 1 time(s), last time on Feb 3 2009, 8:50 pm by Ahli.




Feb 3 2009, 10:08 pm Demented Shaman Post #5



About a month or two ago I made a simple program for my own use that could replace based on two different lists of input.


I also had another replace function in a duplicator program I made that could do multiline replace, but it only allowed for one set of input.

Of course, what you're doing is much more complex with more features.



None.

Feb 3 2009, 10:10 pm Ahli Post #6

I do stuff and thingies... Try widening and reducing the number of small nooks and crannies to correct the problem.

how did you do the GUI?




Feb 3 2009, 10:12 pm Demented Shaman Post #7



It's in VB. The top text box is for the input text and the bottom two smaller text boxes are for the things to be searched for and replaced. The two replace buttons just say which way to do the swap, so you can replace back and forth.



None.

Feb 4 2009, 6:59 am Esponeo Post #8



I used to follow these steps but under Windows XP they no longer seem to work properly. Windows XP is a total piece of shit and does weird crap when you try to do this. Maybe someone else can make it work, I am fed up with Windows' bullshit.

1. Download http://angusj.com/resourcehacker
2. Use it to open WINDOWS\system32\comdlg32.dll
3. Modify Diaglog/1541 to have larger, multi-line text boxes for Find/Replace.
4. Save to a new folder as comdlg33.dll (Note: You may use any file name, as long as it it is exactly 8 characters)
5. Download http://www.hexworkshop.com/
6. Use it to open WINDOWS\system32\notepad.exe
7. Replace both instances of "comdlg32.dll" with the new file name.
8. Save to your new folder.
9. Enjoy



None.

Feb 4 2009, 5:26 pm Ahli Post #9

I do stuff and thingies... Try widening and reducing the number of small nooks and crannies to correct the problem.

Someone knows a char that won't appear in Strings normally?

I could use a special char in the string to mark already replaced parts of the whole string -> parts won't be replaced again (just need to check if the current string is inside of an earlier one in the list).

I already tried some controle chars, but they showed up as some strings or filenames inside my current program. :S

EDIT:
Atm, I'm using a user defined String in the config.ini.

Post has been edited 1 time(s), last time on Feb 4 2009, 9:49 pm by Ahli.




Feb 5 2009, 12:16 am Falkoner Post #10



ASCII values 00, 08, 09, and 0A(or 0, 8, 9, and 10) all are blank, at least in the command prompt.



None.

Feb 5 2009, 2:29 am Ahli Post #11

I do stuff and thingies... Try widening and reducing the number of small nooks and crannies to correct the problem.

I have problems using that chars like I mentioned in the last post :S

But I already found a solution (see my last post) and I implemented that method to work properly...
Now I only could need to implement a search at start that search my controle string inside all data... (to see if it is valid to use).

Atm I have a % in the config.ini and that method works.

EDIT:
I wrote a new system and the new one is way better and faster than the old one. The old one was very slow (~1kb/s). My new method is much faster (~140kb/s).
In my new system I store the string data (offste to start, offset to end, index in replace vector) before the replacement in a vector and the actual replacement is done after that.
Now I need no new sign and don't write into the strings all the time.

Post has been edited 1 time(s), last time on Feb 8 2009, 11:31 pm by Ahli.




Mar 14 2009, 11:01 am Ahli Post #12

I do stuff and thingies... Try widening and reducing the number of small nooks and crannies to correct the problem.

v.1.0:
Read the Readme for detailed information.

I finished this a few weeks ago. But I didn't create all of my first ideas. Only the "1 time string replace" is implemented.

Attachments:
FindRepl.rar
Hits: 3 Size: 122.04kb




Mar 14 2009, 6:46 pm Wormer Post #13



Ahli, it's nice to see progress. But right now it is only another find/replace tool...



Some.

Mar 15 2009, 4:14 am Scienthsine Post #14



I just use awk or grep and regular expressions to do find/replace work if in linux. If in windows, I run the text through a small lua program using it's regular expressions... it'd be hard to beat...



None.

Mar 24 2009, 5:27 pm rockz Post #15

ᴄʜᴇᴇsᴇ ɪᴛ!

Uhm, two things I'd like, not necessarily string related.

One is a simple gui which reads an address of a program (specifically to read BW memory to see the download status. Since it doesn't actually modify the data, it should be undetectable. Artmoney does this, but a small program would be nice.)

Another is more related, one which organizes triggers alphabetically based on owner.



"Parliamentary inquiry, Mr. Chairman - do we have to call the Gentleman a gentleman if he's not one?"

Mar 24 2009, 7:15 pm Ahli Post #16

I do stuff and thingies... Try widening and reducing the number of small nooks and crannies to correct the problem.

The unrelated thing is totally beyond my current skills.
I only know some basic c++ aspects.

A program that sorts the triggers related to the owner# would be possible.

edit: Vrael makes a program for that purpose now.

edit:
version 1.1 fixes a bug with empty files.

Post has been edited 2 time(s), last time on Dec 28 2009, 7:37 pm by Ahli.




Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[03:08 pm]
Oh_Man -- example of wat u mean?
[05:59 am]
NudeRaider -- *is
[05:17 am]
NudeRaider -- despite all its flaws the sound design its fantastic
[10:29 pm]
Oh_Man -- homeworld 3 = massive disappointment
[2024-5-14. : 10:05 am]
Moose -- ya
[2024-5-14. : 5:23 am]
zsnakezz -- yes
[2024-5-12. : 8:51 pm]
l)ark_ssj9kevin -- Are you excited for Homeworld 3?
[2024-5-12. : 8:44 pm]
l)ark_ssj9kevin -- Hi Brusilov
[2024-5-12. : 4:35 pm]
O)FaRTy1billion[MM] -- Brusilov
Brusilov shouted: Hey, what happened to EUDDB? Is there a mirror for it somewhere? Need to do a little research.
my server that was hosting it died
[2024-5-10. : 8:46 pm]
NudeRaider -- Brusilov
Brusilov shouted: Hey, what happened to EUDDB? Is there a mirror for it somewhere? Need to do a little research.
https://armoha.github.io/eud-book/
Please log in to shout.


Members Online: 5milae97100yM0