Jump to content

Parse Error with SNPRINT


subtledoctor

Recommended Posts

I'm getting an error with SNPRINT but I don't know why. Here's what I'm trying to do: take the first 6 characters of a kit's clab.2da file, add "LU" in front, and thus end up with an 8-character name for an HLA table. As I iterate through the kits in kitlist.2da via ACTION_PHP_EACH, the CLAB file is in the variable %fox%. This is working - the mod does other things with %fox% successfully.

 

As a refresher, here is what the Weidu readme says about SNPRINT:

SPRINT "author" "Jason"

SNPRINT 3 "myvar" "1:%author%"

... assigns 1:J to myvar.

So I wrote,

SNPRINT 6 ~luclab~ ~%fox%~
...but that line is giving me the parse error. Can anyone spot why?

 

Here's a snip of the more complete code, if it helps:

 

ACTION_PHP_EACH d5_divine_kits AS fox => sox BEGIN
  ACTION_IF (%sox% = 3) BEGIN //...clerics
    SNPRINT 6 ~luclab~ ~%fox%~
    COPY ~f_n_p/spheres/hlas/luclxyz.2da~ ~override/lu%luclab%.2da~
    ACTION_PHP_EACH EVAL ~d5_%fox%_spheres~ AS hop => pop BEGIN
      ACTION_IF (~%pop%~ STRING_EQUAL_CASE ~major~) BEGIN
        COPY_EXISTING ~lu%luclab%.2da~ ~override~
          APPEND_FILE ~f_n_p/spheres/hlas/%hop%/hlas_%hop%.txt~
        BUT_ONLY
      END
    END
    COPY_EXISTING ~lu%luclab%.2da~ ~override~
      APPEND_FILE ~f_n_p/spheres/hlas/hla_table_end.txt~
    BUT_ONLY
    COPY_EXISTING ~luabbr.2da~ ~override~
      REPLACE_TEXTUALLY ~^\(%fox_1%[ %TAB%]+\).+$~ ~\1%luclab%~
    BUT_ONLY
  END
END

 

 

EDIT... looking at it with fresh eyes, could it possibly be that I need the SPRINT command just before SNPRINT? I omitted that, because I already have a string in the variable %fox%...

Link to comment

And just to clarify further:

 

"fox => sox" references an array constructed from kitlist that pairs each kit's clab file and class number. So "IF sox = 3" is a filter that limits us to only working with cleric kits.

 

"hop => pop" references a pre-constructed array that pairs spell spheres with that kit's sphere access (major/minor/none). This is saying, if a kit has major access to a sphere, append that sphere's HLA(s) to the kit's custom HLA table.

Link to comment

AH! (Stupid action/patch schism grumble mumble...) Hmm. Well, I guess I have some work to do figuring out how to integrate it then.

 

Hmm... I don't think I can do all this inside a PATCH because I need to go action-y stuff like COPYing and modifying luabbr.2da.

 

Maybe the SNPRINT needs to go in an OUTER_INNER_PATCH?

Link to comment

When you COPY a file, many of the patch commands operate on the contents of that file.

 

When you perform an OUTER_PATCH (or an INNER_PATCH), the patch functions instead operate on the contents of buffString.

 

So, if you did this:

 

OUTER_PATCH ~abcdef~ BEGIN

READ_ASCII 2 letter (1)

END

 

Then the variable letter would contain the character ~c~.

 

OUTER_PATCH will throw away any sort of modifications you make to the buffer, such as WRITEs. If you want to save those changes instead, use OUTER_PATCH_SAVE.

 

In this case, you could just as easily use OUTER_PATCH ~~ BEGIN.

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...