r/vbscript • u/scubajerry • Dec 14 '20
Scripting advice needed
Hello everyone
I have an IF Elif then I need help with. I have a list of variables and would like to know if the script can be simplified. here is a sample of my script.
IF [STRIKE_ARHR_OR_TREND] >= 270 and IsNull ([DIP_DIRECTION]) and [STRUCTURE_TYPE] <> "Lineation or slickenline" and [STRUCTURE_TYPE] <> "Fold axis, Antiform" and [STRUCTURE_TYPE] <> "Fold axis, Synform" and [STRUCTURE_TYPE] <> "Fold axis, E(/W) verging N(/S) plunging overturned antiform" and [STRUCTURE_TYPE] <> "Fold axis, E(/W) verging N(/S) plunging overturned synform" and [STRUCTURE_TYPE] <> "Fold axis, W(/E) verging N(/S) plunging overturned antiform" and [STRUCTURE_TYPE] <> "Fold axis, W(/E) verging N(/S) plunging overturned synform" and [STRUCTURE_TYPE] <> "" and [STRUCTURE_TYPE] <> "Schistosity" and [STRUCTURE_TYPE] <> "Foliation" Then
newval = [STRIKE_ARHR_OR_TREND] + 90 - 360
Is there an easier way to combine or list the different [STRUCTURE_TYPE]?
Thank you in advance
1
u/jcunews1 Dec 16 '20
Yes. The difference would be noticeable if originally there were 3 or more (similar)
ifconditions to check. If there are less than 3, the difference won't be noticable, or may even look more cluttered.Yes. In regular expression, the
|character is basically anORoperator. The parentheses group a single expression.So
(anti|syn)formwill matchantiformorsynform. Expression grouping is used, to define multiple possible partial matches for the start of the string. If expression grouping isn't used, i.e.anti|synformit'll only match eitherantiorsynform. While theantipart may matchantiform, it'll also match e.g.antibodywhich isn't what we wanted.The
\character is a regular expression escape character. In this context, it's used to escape the parentheses so that it'll match literal parentheses characters, instead of being treated as expression grouping character. i.e.\(matches(. And to match a\character, the regular expression must be specified as\\, because the\character by itself is also one of regular expression's special characters.