Author Topic: Features not covered in the readme  (Read 1077 times)

Offline Galactygon

  • Modding since 2002
  • Planewalker
  • *****
  • Posts: 378
  • Gender: Male
  • Creator of spells
Features not covered in the readme
« on: November 03, 2016, 05:35:33 AM »
There is WeiDU functionality that exists but is not fully covered in the readme.

1. BIT... and `BIT...

BIT0  0b00000001 (covered under section "15 WeiDU constants")
`BIT0  0b11111110 (not mentioned at all)

For example you can disable the hostile flag of a .spl without writing out all the 1's and 0's
Code: [Select]
PATCH_IF (BYTE_AT 0x19 BAND BIT2) = BIT2 BEGIN // if hostile flag enabled
WRITE_BYTE 0x19 (THIS BAND `BIT2) // disable hostile flag
END

Note: The (`) symbol is not the same as the apostrophe symbol (')

2. Using ^ inside brackets regexps

You can exclude certain characters by using "^"s. Wikipedia does a fine job explaining regular expressions with some examples. Note that regular expressions in WeiDU deviate somewhat, for example the "|" expression corresponds to "\|" in WeiDU.

Some examples in WeiDU:
Code: [Select]
OUTER_SPRINT test "alan"
ACTION_IF "%test%" STRING_MATCHES_REGEXP "[^a]lan" = 0 BEGIN // This will not return true
PRINT "%test%"
END
ACTION_IF "%test%" STRING_MATCHES_REGEXP "[^abc]lan" = 0 BEGIN // This will not return true
PRINT "%test%"
END
ACTION_IF "%test%" STRING_MATCHES_REGEXP "[^a-z]lan" = 0 BEGIN // This will not return true
PRINT "%test%"
END
OUTER_SPRINT test "blan"
ACTION_IF "%test%" STRING_MATCHES_REGEXP "[^a]lan" = 0 BEGIN // This will return true
PRINT "%test%"
END
ACTION_IF "%test%" STRING_MATCHES_REGEXP "[^abc]lan" = 0 BEGIN // This will not return true
PRINT "%test%"
END
ACTION_IF "%test%" STRING_MATCHES_REGEXP "[^a-z]lan" = 0 BEGIN // This will not return true
PRINT "%test%"
END
OUTER_SPRINT test "2lan"
ACTION_IF "%test%" STRING_MATCHES_REGEXP "[^a]lan" = 0 BEGIN // This will return true
PRINT "%test%"
END
ACTION_IF "%test%" STRING_MATCHES_REGEXP "[^abc]lan" = 0 BEGIN // This will return true
PRINT "%test%"
END
ACTION_IF "%test%" STRING_MATCHES_REGEXP "[^a-z]lan" = 0 BEGIN // This will return true
PRINT "%test%"
END
ACTION_IF "%test%" STRING_MATCHES_REGEXP "[^0-9]lan" = 0 BEGIN // This will not return true
PRINT "%test%"
END
OUTER_SPRINT test "22lan"
ACTION_IF "%test%" STRING_MATCHES_REGEXP "[^0-9]lan" = 0 BEGIN // This will not return true
PRINT "%test%"
END

Offline Mike1072

  • Planewalker
  • *****
  • Posts: 298
  • Gender: Male
Re: Features not covered in the readme
« Reply #1 on: November 03, 2016, 09:13:17 PM »
The backtick functionality is documented under BNOT.

Cam wrote a great tutorial on bitwise patching.  Unfortunately, it doesn't contain any examples using the BIT variables or BNOT.  Maybe a small tutorial on those could be included as an addendum or sequel.

Offline Wisp

  • Moderator
  • Planewalker
  • *****
  • Posts: 1176
Re: Features not covered in the readme
« Reply #2 on: November 05, 2016, 02:55:52 PM »
2. The documentation of character sets explains the use of the caret. Though it describes it as a set complement, which I suppose can be confusing and/or maybe incorrect. Additionally, Perl-compatible regexps are not the only style, though it is the style du jour. WeiDU uses a basic set of Emacs-compatible regexps (because that's what OCaml uses).
« Last Edit: November 05, 2016, 03:01:05 PM by Wisp »

 

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Name: Email:
Verification:
Type the letters shown in the picture
Listen to the letters / Request another image
Type the letters shown in the picture:
What color is grass?:
What is the seventh word in this sentence?:
What is five minus two (use the full word)?: