Author Topic: Patch request: items purchased  (Read 7633 times)

Offline Echon

  • Global Moderator
  • Planewalker
  • *****
  • Posts: 1944
  • Gender: Male
    • The Fields of the Dead
Re: Patch request: items purchased
« Reply #25 on: November 07, 2010, 03:05:53 PM »
Should I omit "" for integers and %% when reading variables? I am not sure if they were required when I started this FotD update but they were widely used. They seem to have become obsolete since then, however.

Offline the bigg

  • The Avatar of Fighter / Thieves
  • Moderator
  • Planewalker
  • *****
  • Posts: 3804
  • Gender: Male
Re: Patch request: items purchased
« Reply #26 on: November 07, 2010, 03:09:47 PM »
They became not needed before my time, actually. It's a matter of habit whether you use them or not.

Using them is also nice because you're sure that your tp2 isn't invalidated if one of your variables become a keyword in the tp2 synthax (although you could simply write in lower-case in that case).
« Last Edit: November 07, 2010, 03:14:10 PM by the bigg »
Author or Co-Author: WeiDU (http://j.mp/bLtjOn) - Widescreen (http://j.mp/aKAiqG) - Generalized Biffing (http://j.mp/aVgw3U) - Refinements (http://j.mp/bLHoCc) - TB#Tweaks (http://j.mp/ba02Eg) - IWD2Tweaks (http://j.mp/98OFYY) - TB#Characters (http://j.mp/ak8J55) - Traify Tool (http://j.mp/g1Ry9A) - Some mods that I won't mention in public
Maintainer: Semi-Multi Clerics (http://j.mp/9UeIwB) - Nalia Mod (http://j.mp/dng9l0) - Nvidia Fix (http://j.mp/aRWjjg)
Code dumps: Detect custom secondary types (http://j.mp/hVzzXG) - Stutter Investigator (http://j.mp/gdtBn8)

If possible, send diffs, translations and other contributions using Git (http://j.mp/aBZFrq).

Offline GeN1e

  • Planewalker
  • *****
  • Posts: 267
  • Gender: Male
Re: Patch request: items purchased
« Reply #27 on: November 07, 2010, 03:10:11 PM »
if an item is found, "%#items%" is set to zero, but the loop continues because the value is never read
:facepalm: I've been such a moron to not take a notice of PATCH_PRINTing even after the match...

Offline Mike1072

  • Planewalker
  • *****
  • Posts: 298
  • Gender: Male
Re: Patch request: items purchased
« Reply #28 on: November 07, 2010, 04:00:42 PM »
The resulting ugliness and extra typing involved with having unnecessary %s and "s around integers should be discouraged.

Use quotes around strings, not around variables.

Offline Miloch

  • Barbarian
  • Planewalker
  • *****
  • Posts: 1032
  • Gender: Male
Re: Patch request: items purchased
« Reply #29 on: November 07, 2010, 04:06:38 PM »
Last I checked, there were some statements that require both %% and quotes around variables, like STRING_EQUAL. Otherwise, it reads the variable as a string equalling the variable name, rather than the contents of the variable. But yeah, you don't need them in most cases, like the syntax above.

Offline Echon

  • Global Moderator
  • Planewalker
  • *****
  • Posts: 1944
  • Gender: Male
    • The Fields of the Dead
Re: Patch request: items purchased
« Reply #30 on: November 07, 2010, 04:19:33 PM »
I thought strings required ~~. Is this also a thing of the past?

Offline Mike1072

  • Planewalker
  • *****
  • Posts: 298
  • Gender: Male
Re: Patch request: items purchased
« Reply #31 on: November 07, 2010, 06:26:46 PM »
Last I checked, there were some statements that require both %% and quotes around variables, like STRING_EQUAL.
STRING_EQUAL works on strings.  ~%var%~ is a string containing only the contents of the variable named var.

I thought strings required ~~. Is this also a thing of the past?
~ ~ or " " or ~~~~~ ~~~~~ or the confusing % %.  A string can be declared without using quotes, but such a string can't contain spaces or certain special characters, can't substitute variables, and can't be empty.

Offline GeN1e

  • Planewalker
  • *****
  • Posts: 267
  • Gender: Male
Re: Patch request: items purchased
« Reply #32 on: November 07, 2010, 06:49:39 PM »
Last I checked, there were some statements that require both %% and quotes around variables, like STRING_EQUAL. Otherwise, it reads the variable as a string equalling the variable name, rather than the contents of the variable. But yeah, you don't need them in most cases, like the syntax above.
If you the string to be evaluated, then yes, ~%%~ should be used.

Arrays must take either ~%%~ or "%%" for indexes to be evaluated, and ~~ or "" otherwise.
SET $array("a""%b%"~%c%~)=d will work, but SET $array(a %b% c)=d failed the last time I've tried it.

Offline the bigg

  • The Avatar of Fighter / Thieves
  • Moderator
  • Planewalker
  • *****
  • Posts: 3804
  • Gender: Male
Re: Patch request: items purchased
« Reply #33 on: November 07, 2010, 07:04:04 PM »
Yes, I'm ashamed of how variables and strings are handled in WeiDU. No, I can't fix those oddities - Refinements (and, most likely, other mods too) was hand-crafted by a more naive myself to make sure that it essentially depends on every little exception in the string handling code.
Author or Co-Author: WeiDU (http://j.mp/bLtjOn) - Widescreen (http://j.mp/aKAiqG) - Generalized Biffing (http://j.mp/aVgw3U) - Refinements (http://j.mp/bLHoCc) - TB#Tweaks (http://j.mp/ba02Eg) - IWD2Tweaks (http://j.mp/98OFYY) - TB#Characters (http://j.mp/ak8J55) - Traify Tool (http://j.mp/g1Ry9A) - Some mods that I won't mention in public
Maintainer: Semi-Multi Clerics (http://j.mp/9UeIwB) - Nalia Mod (http://j.mp/dng9l0) - Nvidia Fix (http://j.mp/aRWjjg)
Code dumps: Detect custom secondary types (http://j.mp/hVzzXG) - Stutter Investigator (http://j.mp/gdtBn8)

If possible, send diffs, translations and other contributions using Git (http://j.mp/aBZFrq).

Offline Wisp

  • Moderator
  • Planewalker
  • *****
  • Posts: 1176
Re: Patch request: items purchased
« Reply #34 on: November 08, 2010, 03:25:57 AM »
but SET $array(a %b% c)=d failed the last time I've tried it.
You need to quote (or wavy-line) %b%. You can index an array with e.g. $array(a b) (if you don't need variable substitution etc).

 

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)?: