PDA

View Full Version : Notepad++ color codes



SailorLovins
April 13th, 2018, 15:03
Hello everyone. I am just getting started with my exciting journey with XML using Notepad++ (64 bit) V.7.5.6
I noticed that as I'm looking at different mods in the program there are different colors for different things (for lack of better terms). For example...most everything is predominately blue. Some are red and others are purple. There is also green in places. An example is <Name type="string'> Some Black Text </name> Name is in blue, Type is red and string is purple. Would someone be side kind as to educate me on why these are colored as such? I am assuming the "string" example is some form of a command name recognized in XML. I've a long way to go before I can effectively code XML but I am a fast learner.

dulux-oz
April 13th, 2018, 15:16
Hello Sailor (I've always wanted to say that :) )

Notepad colour-codes different parts of a program file (XML & LUA in our case) to help distinguise one part or type from another. At lot of advanced text/code editing apps do this, and while it looks strange at first you quickly become used to it and it help speed up your coding because you quickly get to see when the syntax of your code is right or wrong.

does that help?

Mortar
April 13th, 2018, 15:20
Once you save the file as XML file the various colors will appear in the file. They are indicating, as you assumed, a specific XML syntax. The color can be used to help identify if you have a missing closing tag, missing " or / in the code. Best way to understand it is create some sample entries within the FG ruleset of your choice and export it. Once you export it, open it up and see how the XML is laid out.

This page will become your friend, (or hated enemy :P): https://www.fantasygrounds.com/wiki/index.php/Special:AllPages

Trenloe
April 13th, 2018, 15:28
Also, changing the "Language" to XML in Notepad++ will change the highlighting appropriately.

SailorLovins
April 13th, 2018, 16:24
Thanks for the informative replies. I really appreciste it. I admit that with the blank xml sheet I began writing on wasn't saved (its still open on my pc at home). I had opened my exported module I am working on with notepad and though I see similar entries, it doesn't seem to be in the same order as the 5E asset module I am comparing to. There are no "list" entries that I can see and the data for evrrything else seems very... Scattered and disorganized. I definitely want to follow a consistent format.

Mortar
April 13th, 2018, 16:48
The difference in the formatting you see in an exported module, an unpacked module/ruleset, and the code snippets you see in screenshots are all due to the way FG is set up to export data. FG exports alpha-numerically, in that when you open a module you could or will see <combat>, <encounters>,<image>, <library>, <lists>, <reference> as the second level tags under the <root> tag. If its in an unpacked ruleset or module, especially an older one, things can get really messy as data maybe in a similar order, or not depending on the original creator.

In Notepad++, use the line numbers, indentation and the tree on the left hand side to collapse different tag levels to help you get an idea of how they interact. It aids greatly in keeping data organized.

I try to keep my the same from module to module (doesn't always happen) and I tend to go in this order: <library>, <image>, <lists>, <reference>, then <combat> or <encounters> as needed

SailorLovins
April 13th, 2018, 18:07
Reporting back. Everything is working beautifully. I have a physical book I am trying my new found magic on by making a private module based on this small book. Notepad is picking up the language as fast as I type it, everything is neat and sensable columns and that color coding sure does make it a lot easier to spot errors. Haveing a lot of fun.

Mortar
April 13th, 2018, 18:47
That's how it begins. Now its an addiction.

A couple tips to remember...

1. Save often.
2. Take a look at the particular ruleset you are using and its wiki. Some of the rulesets have particular syntax for certain data that may differ.

3. Take breaks.....keep the fun it

4. Save often.!! <<<< Very important to remember

5. Ask questions!!

dulux-oz
April 14th, 2018, 03:38
That's how it begins. Now its an addiction.

A couple tips to remember...

1. Save often.
2. Take a look at the particular ruleset you are using and its wiki. Some of the rulesets have particular syntax for certain data that may differ.

3. Take breaks.....keep the fun it

4. Save often.!! <<<< Very important to remember

5. Ask questions!!

And one more thing - SAVE OFTEN!!!!!! (and no, we're not kidding) :)

Mortar
April 14th, 2018, 03:56
And one more thing - SAVE OFTEN!!!!!! (and no, we're not kidding) :)

^^^^^^ What he said!!!!!!!!

SailorLovins
April 14th, 2018, 04:20
Thanks for the tips guys. I really appreciate it. I went a bit overboard today and I'm not sure what the average production speed is but I punched out a good 500 lines of code. It sure felt like a lot and my brain is all washed out. I pushes myself to see what sort of mistakes I would make by unintentional complacency. Sure enough so of my lines werent collapsing for some reason and I knew it was some minute detail. Turns out I forgot to close a single text tag with the backslash. So once I have a modestly working product what is the save order to get it into FG? I know I had to open the mod file with winrar... Unzip it and then edit with notepad++. Is there some reverse order ill need to follow to ensure my external assets go along with my work?

Mortar
April 14th, 2018, 04:37
If you watch the tree along the left side carefully, you'll see when a tag isn't closed properly. The tree will have an unexpected collapsible mark at the point where you are missing a tag.

Mod, ppk (portrait modules), and rulesets are all renamed zip files. I use 7zip and edit the db.xml or client.xml directly in the mod file. It saves a bit of time. You can do this while FG is running. Once you save the file and close notepad++, on the mod archive in 7zip you will have the option of updating the archive - click yes. In FG close and reopen the module, and the module will now have all the changes you just made. If you have an error in your XML, the console will pop up with a warning telling of a faulty tag and give a line number. The bad tag will be ABOVE that line number in the relevant XML file.

Not sure if winrar gives you that ability to edit the file directly in the module.

dulux-oz
April 14th, 2018, 04:41
I actually do all my editing and testing in FG in the raw file formats - I only zip them up (7-Zip's my app of choice) once I'm actually ready to publish (ie they're finished).