Jump to content
Macro Express Forums

Text Processing


Avarion
 Share

Recommended Posts

Hello, I have a huge problem. I've scanned a book with spells for the game AD&D. Now I want put the data into a database, but the data are not in the right format.

 

The data now has the following format:

 

Dancing Lights
(Alteration)
Range: 40 yds. + 10 yds./level          Components: V, S, M
Duration: 2 rds./level                       Casting Time: 1
Area of Effect: Special                     Saving Throw: None
When a dancing lights spell is cast, the wizard creates, at his option, from one to four lights that resemble either torches or lanterns (and cast that amount of light), glowing spheres of light (such as evidenced by will-o-wisps), or one faintly glowing, vaguely manlike shape, somewhat similar to that of a creature from the Elemental Plane of Fire. The dancing lights move as the spellcaster desires, forward or back, straight or turning corners, without concentration upon such movement by the wizard. The spell cannot be used to cause blindness (see the 1st-level light spell), and it winks out if the range or duration is exceeded.
The material component of this spell is either a bit of phosphorus or wychwood, or a glowworm.
Detect Magic

 

And I need this format:

 

"Dancing Lights";"(Alteration)";"40 yds. + 10 yds./level";"V, S, M"
.
.
.

 

Every field has to be in "" and the fieldnames have to be cut out. I am willing to preprocess the textfile and insert a empty line between the spells but it would be great if the macro can handle the other work.

 

Has anyone an idea?

Link to comment
Share on other sites

This looks pretty exciting but it's hard to tell what to do with the story.

Can you remove the story and give a better example of what the data is for each line?

With this being present;

 

Dancing Lights

(Alteration)

Range: 40 yds. + 10 yds./level Components: V, S, M

 

and this being your requested output;

 

"Dancing Lights";"(Alteration)";"40 yds. + 10 yds./level";"V, S, M"

 

I'm having a hard time seeing what the next row would be..maybe I'm old..:)

Would this be next;

"Dancing Lights";"(Alteration)";"2 rds./levell";"1"

"Dancing Lights";"(Alteration)";"special";"none"

Link to comment
Share on other sites

Ok, Sorry for this. Here are two spells for example:

 

Dancing Lights
(Alteration)
Range: 40 yds. + 10 yds./level          Components: V, S, M
Duration: 2 rds./level                       Casting Time: 1
Area of Effect: Special                     Saving Throw: None
When a dancing lights spell is cast, the wizard creates, at his option, from one to four lights that resemble either torches or lanterns (and cast that amount of light), glowing spheres of light (such as evidenced by will-o-wisps), or one faintly glowing, vaguely manlike shape, somewhat similar to that of a creature from the Elemental Plane of Fire. The dancing lights move as the spellcaster desires, forward or back, straight or turning corners, without concentration upon such movement by the wizard. The spell cannot be used to cause blindness (see the 1st-level light spell), and it winks out if the range or duration is exceeded.
The material component of this spell is either a bit of phosphorus or wychwood, or a glowworm.
Enlarge
(Alteration) Reversible
Range: 5 yds./level                                    Components: V, S, M
Duration: 5 rds./level                                 Casting Time: 1
Area of Effect: 1 creature or object              Saving Throw: Neg.
This spell causes instant growth of a creature or object, increasing both size and weight. It can be cast only upon a single creature (or a symbiotic or community entity) or upon a single object that does not exceed 10 cubic feet in volume per caster level. The object or creature must be seen to be affected. It grows by up to 10% per level of experience of the wizard, increasing this amount in height, width, and weight.
All equipment worn or carried by a creature is enlarged by the spell. Unwilling victims are entitled to a saving throw vs. spell. A successful saving throw means the spell fails. If insufficient room is available for the desired growth, the creature or object attains the maximum possible size, bursting weak enclosures in the process, but it is constrained without harm by stronger materials-—the spell cannot be used to crush a creature by growth.
Magical properties are not increased by this spell--a huge sword +1 is still only +1, a staff-sized wand is still only capable of its normal functions, a giant-sized potion merely requires a greater fluid intake to make its magical effects operate, etc. Weight, mass, and strength are affected, though. Thus, a table blocking a door would be heavier and more effective, a hurled stone would have more mass (and cause more damage), chains would be more massive, doors thicker, a thin line turned to a sizeable, longer rope, and so on. A creature's hit points, Armor Class, and attack rolls do not change, but damage rolls increase proportionately with size.
For example, a fighter at 160% normal size hits with his long sword and rolls a 6 for damage. The adjusted damage roll is 10 (that is, 6 x 1.6 = 9.6, rounded up). Bonuses due to Strength, class, and magic are not altered.
The reverse spell, reduce, negates the enlarge spell or makes creatures or objects smaller. The creature or object loses 10% of its original size for every level of the caster, to a minimum of 10% of the original size. Thereafter, the size shrinks by 1 -foot increments to less than 1 foot, by 1-inch increments to 1 inch, and by 1/10-inch increments to a minimum of 1/10 of an inch—-the recipient cannot dwindle away to nothingness.
For example, a 16-foot-tall giant reduced by a 15th-level wizard (15 steps) would be reduced to 1.6 feet (in nine steps), then to 6/10 of a foot or 7.2 inches (in one step), and finally to 2.2 inches (in the last five steps). A shrinking object may damage weaker materials affixed to it, but an object will shrink only as long as the object itself is not damaged. Unwilling creatures are allowed a saving throw vs. spell.
The material component of this spell is a pinch of powdered iron.

 

And this is how they should be:

"Dancing Lights";"(Alteration)";"N";"40 yds. + 10 yds./level";""V, S, M";"2 rds./level";"1";"Special";"None";"When a dancing lights spell is cast, the wizard creates, at his option, from one to four lights that resemble either torches or lanterns (and cast that amount of light), glowing spheres of light (such as evidenced by will-o-wisps), or one faintly glowing, vaguely manlike shape, somewhat similar to that of a creature from the Elemental Plane of Fire. The dancing lights move as the spellcaster desires, forward or back, straight or turning corners, without concentration upon such movement by the wizard. The spell cannot be used to cause blindness (see the 1st-level light spell), and it winks out if the range or duration is exceeded.
The material component of this spell is either a bit of phosphorus or wychwood, or a glowworm."
"Enlarge";"(Alteration)";"Y";"5 yds./level";"V, S, M";"5 rds./level";""1";"1 creature or object";"Neg.";"This spell causes instant growth of a creature or object, increasing both size and weight. It can be cast only upon a single creature (or a symbiotic or community entity) or upon a single object that does not exceed 10 cubic feet in volume per caster level. The object or creature must be seen to be affected. It grows by up to 10% per level of experience of the wizard, increasing this amount in height, width, and weight.
All equipment worn or carried by a creature is enlarged by the spell. Unwilling victims are entitled to a saving throw vs. spell. A successful saving throw means the spell fails. If insufficient room is available for the desired growth, the creature or object attains the maximum possible size, bursting weak enclosures in the process, but it is constrained without harm by stronger materials-—the spell cannot be used to crush a creature by growth.
Magical properties are not increased by this spell--a huge sword +1 is still only +1, a staff-sized wand is still only capable of its normal functions, a giant-sized potion merely requires a greater fluid intake to make its magical effects operate, etc. Weight, mass, and strength are affected, though. Thus, a table blocking a door would be heavier and more effective, a hurled stone would have more mass (and cause more damage), chains would be more massive, doors thicker, a thin line turned to a sizeable, longer rope, and so on. A creature's hit points, Armor Class, and attack rolls do not change, but damage rolls increase proportionately with size.
For example, a fighter at 160% normal size hits with his long sword and rolls a 6 for damage. The adjusted damage roll is 10 (that is, 6 x 1.6 = 9.6, rounded up). Bonuses due to Strength, class, and magic are not altered.
The reverse spell, reduce, negates the enlarge spell or makes creatures or objects smaller. The creature or object loses 10% of its original size for every level of the caster, to a minimum of 10% of the original size. Thereafter, the size shrinks by 1 -foot increments to less than 1 foot, by 1-inch increments to 1 inch, and by 1/10-inch increments to a minimum of 1/10 of an inch—-the recipient cannot dwindle away to nothingness.
For example, a 16-foot-tall giant reduced by a 15th-level wizard (15 steps) would be reduced to 1.6 feet (in nine steps), then to 6/10 of a foot or 7.2 inches (in one step), and finally to 2.2 inches (in the last five steps). A shrinking object may damage weaker materials affixed to it, but an object will shrink only as long as the object itself is not damaged. Unwilling creatures are allowed a saving throw vs. spell.
The material component of this spell is a pinch of powdered iron."

 

The third field is an boolean for the point "reversible". If there is no reversible as in enlarge then the field is N for NO else Y for YES.

 

I have three more fields but I think I can insert em myself as soon I understand the macro itself.

 

I hope it will help you to understand the problem I have.

Link to comment
Share on other sites

Hmm. I am unsure I understand you. The spell story in the first code-part is the raw information in the textfile. The second code-part is the information I need. Macro Express should now reformate the Data, cut the descriptions like "Duration", "Area of Effect" and so on and put all in quotationmarks and put all in one line.

Link to comment
Share on other sites

hi,

This replicates the example, but I'm still not sure either if is is exactly what you want ; all now ascii-quotes including the text as a single field.

Try it.

Best, Randall

// Set tab / CRLF name [i am presuming the problems are the tabs?.... if they are spaces, I'm wrong]

Variable Set %T2% to ASCII Char of 10

Variable Set %T3% to ASCII Char of 13

Variable Modify String: Append %T2% to %T3%

Variable Modify String: Save %T3% to Environment Variable

Variable Set %T2% to ASCII Char of 9

Variable Modify String: Save %T2% to Environment Variable

Delete File or Files: "examplebook2.txt"

// Whatever the file name, process line by line

Variable Set String %T3% """

Text File Begin Process: "examplebook.txt"

  Variable Set Integer %N1% from Length of Variable %T1%

  Variable Modify String: Copy Part of %T1% to %T2%

  // If last character not a period, then replace tabs with ";" etc

  If Variable %T2% <> "."

    OR

  If Variable %T1% contains "%TAB%"

    If Variable %T3% = "%CRLF%"

      // Is this what you want before next spell starts; or ";"  ?

      Variable Set String %T3% ""%CRLF%""

    Else

      Variable Set String %T3% """

    End If

    Replace "%T1%" with "%T3%%T1%";" in %T1%

    Replace "%TAB%" with "";"" in %T1%

    Variable Modify String: Append %T1% to Text File

    Variable Set String %T3% """

  Else

    // If last character is a period,

    Replace "%T1%" with "%T3%%T1%" in %T1%

    Variable Modify String: Append %T1% to Text File

    // CRLF, no quotes for next line at start if it remains a sentence next line

    Variable Set String %T3% "%CRLF%"

  End If

Text File End Process

// Add a quote at the total end

Variable Set String %T1% """

Variable Modify String: Append %T1% to Text File

Program Launch: "examplebook2.txt"

try1.mxe

Link to comment
Share on other sites

by the way, in relation to my presumption for it to work at present in those first few lines(that it was a tab mark), if there was more than one, you would need to replace strings of tabs until there was just a single tabl for this macro towork to come before starting it (or on each line).

 

Alternatively, of course if they are spaces, you would need to replace a string of spaces with at least one tab before that! I hope that all works.

Best, Randall.

by the way, if you wish to actually "attach" part of a text file at least as an attachment, we can check whether those marks are tabs or whatever; you may be able to see in Word, for instance anyway.

Link to comment
Share on other sites

Ok, here are two Files. The file called "Hauptbuch.txt" is the original data. The file "HB 2.txt" is handmade as I need it for the database.

 

Hmm. It seems I am not able to add RAR-Files, so it is a bigger ZIP-file. Sorry.

 

Edit: there are some changes in the HB 2 compared with my description, like I put the spellcomponents, normally a part of the spelldescription, in a seperate field and I added a field with the value 1 in it as a description from what book I took the data. Dont get confused.

AD_D.zip

Link to comment
Share on other sites

Hauptbuch.txt looks pretty interesting.

The words that are surrounded by ( ) ...some have another word after and some don't. It looks like if you remove all of the spell text information that explains the spell, you're left with the data that you need to manipulate. And it seems that a search for the left paren indicates a new line?

Link to comment
Share on other sites

Hauptbuch.txt looks pretty interesting.

The words that are surrounded by ( ) ...some have another word after and some don't.  It looks like if you remove all of the spell text information that explains the spell, you're left with the data that you need to manipulate.  And it seems that a search for the left paren indicates a new line?

 

The problem is that I need the spellinformation in the last field.

The database field are:

Spellname, Book (in this Book are all HB for "Hauptbuch"), Spelllevel, Reversible true/false, Wildmagic true/false (is not in the Spelldescription only in the spellist. Have to make it with my own hands), School (Necromancy, Alteration, Evocation and so on), Range, Components, Materialcomponents (only if there is a M in Components. Described in the Spelldescription. I'll make it myself), Spellduration, Castingtime, Area of Effect, Savingthrow, Spelldescription

 

As a matter of clearness i moved the materialcomponents from Spelldescription in a seperate field. Perhaps I should mark the components before running the macro. Would be easier to seperate the fields.

Link to comment
Share on other sites

I've read it and I am sure I understand not more than 2/3 of it. The removing of "Range: ", "Duration: " and so on is easy, i can handle it by myself. The one problem I can not solve is a missing ; at end of every spelldescription.

I've found you comment about this point in the source but I don't know exactly how to add the semicolon.

Link to comment
Share on other sites

Hi,

The line which detects end of spell and inserts a CRLF, ready for next line is;

      // Is this what you want before next spell starts; or ";"  ?

      Variable Set String %T3% ""%CRLF%""

Change this to asemicolon instead?; -it means you have no endofline there; but I'm not sure how you are processing this? - presumably NOT (as I might) by using "ASCII file process"?)

      // Is this what you want before next spell starts; or ";"  ?

      Variable Set String %T3% "";""

Hope this help, Randall

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...