Click here to Skip to main content
15,887,585 members
Please Sign up or sign in to vote.
2.00/5 (2 votes)
See more: (untagged)
I have about 25 files all are written with code that I need to edit to a particular format. Instead of editing all the files which would probably take me about a month to do; I would like to know if there is a way to create a program or an import/export plugin for notepad, to automatically change this code. I prefer a "drag and drop into a window" program that converts and saves in a location set in a .ini file.


For example: (this is only part of a original file)

ÿÿÿÿ  classname cell  	 TargetName Outside1   SkyboxOnly 0 
  DynamicMusic dyn  	 Music 1stfloor  
 AmbientSound citynight   Multilevels 0   NoiseLevel 0   Atmosphere 0   LightLevel 0   UseFlashlight 1  
 origin -503 54 -174   cell_index 1    ÿÿÿÿ


now here is what it looks like after editing(keep in mind that this is only a snippet of the code and the code that I am editing is very long, and is very tedious work)Each block(by block I mean the square thingy in the code) in the above code has different hex values throught the code, and must be edited using hex values, not just creating strings to replace the text. In addition, every file has different values after things like "AmbientSound".

{
"classname" "cell"
"TargetName" "Outside1"
"SkyboxOnly" "0"
"DynamicMusic" "dyn"
"Music" "1stfloor"
"AmbientSound" "citynight"
"Multilevels" "0"
"NoiseLevel" "0"
"Atmosphere" "0"
"LightLevel" "0"
"UseFlashlight" "1"
"origin" "-503 54 -174"
"cell_index" "1"
}


I have predetermined most of the hex values that need to be replace with new code to create the finished code. This list of predetermined hex values is very long, and in some instances like removing double spaces, the code must be run twice. (similar to what a program would do)

Here is an Example of editing the code using the find/replace tool in my hex program.
(to remove the double spacing within the hex code we all know that the hex will look like this)
change 2020 to 20
my hex program then alerts me that "there are 2431 instances of this, would you like to replace all?" of course I selected yes.

I am including a test file to be converted. If anyone could set up a program or an import/export plugin for notepad I would appreciated it. The source files for a program that you create does not have to contain all the hex values that need to be replaced, just a few so I can get an idea of where to start inputting the remaining instances of hex values to be replaced. for example just the above mentioned find/replace I did.

The test file you can download here...

http://www.mariachimaestro.com/Swat3/Last_Resort_Stuff/codeproject_test_file.txt

Also if you are creating a program name it scn2map.exe

Copy-Cat
Posted
Updated 25-Jan-10 15:09pm
v5

1 solution

Copy-Cat wrote:
If anyone could set up a program or an import/export plugin for notepad I would appreciated it.


We are not here to do work for you. Although, we can give you an idea of how to accomplish this yourself.

Create a C# console application. Get the filenames from the args parameter of the Main method. Load the text from each file and use whatever technique you like to replace text (I like regular expressions, but some go with simple string replacement techniques). Then save the text back to the file.

To use your application, compile the EXE. Then drag your text files onto the EXE and watch it perform its magic.

By the way, if you are not a programmer and do not understand how to do the above, then you are not in the right place... this is a forum for programmers to help programmers.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900