/    Sign up×
Community /Pin to ProfileBookmark

IF… IF… IF… ELSE… not working

[FONT=Courier New] ? Can somebody tell me why this code is screwing up?…
(I will use underscores to format it)

function whatever() {
___if SP = 1 {
_
__
___if (t==’*’) {
_
__
______do this;
_
__
______do that;
_
__
______etc…
_
__
___}
_
__
___if (t==’^‘) {
_
__
______do this;
_
__
______do that;
_
__
______etc…
_
__
___}
_
__
}
___else {
_
__
___do this;
_
__
___do that;
_
__
___etc…
_
__
}
}[/FONT]

[COLOR=Navy][B][I][FONT=Comic Sans MS]Regards;
The Kooky Dutchman[/FONT] :rolleyes: [/I]
[/B]
[/COLOR]

to post a comment
JavaScript

23 Comments(s)

Copy linkTweet thisAlerts:
@Willy_DuittJul 25.2005 — Prolly because all of those stupid underscores...

That and you're missing an else/if amongst your psuedo conditionals...

[b]BTW:[/b] Get rid of the underscores and use [b][[/b][b]code] -CODE HERE- [/code][/b] tags when posting code...
Copy linkTweet thisAlerts:
@rbleskow999authorJul 25.2005 — you should READ what I wrote...

I said:

(I will use underscores to format it)

[COLOR=Navy][B][I][FONT=Comic Sans MS]Regards;

The Kooky Dutchman[/FONT] :rolleyes: [/I]
[/B]
[/COLOR]
Copy linkTweet thisAlerts:
@rbleskow999authorJul 25.2005 — [B][COLOR=Navy]P R O B L E M . . . S O L V E D [I]! ! ![/I][/COLOR][/B]

I needed brackets around the: SP = 1

simple oversight.

[COLOR=Navy][B][I][FONT=Comic Sans MS]Regards;

The Kooky Dutchman[/FONT] :rolleyes: [/I]
[/B]
[/COLOR]
Copy linkTweet thisAlerts:
@Willy_DuittJul 25.2005 — [B][COLOR=Navy]P R O B L E M . . . S O L V E D [I]! ! ![/I][/COLOR][/B]

I needed brackets around the: SP = 1

simple oversight.[/QUOTE]


Those would be: [b]parenthesis[/b]....

I noticed that but what am I to know from poorly formatted [i]psuedo[/i] code...

Glad to hear you got it fixed...

But please remember, we work best with absolutes...

.....Willy
Copy linkTweet thisAlerts:
@ExuroJul 25.2005 — I needed brackets around the: SP = 1[/QUOTE]
Those would be: [b]parenthesis[/b]....[/QUOTE]
Jeez, give him a break. He's probably British or something, or just unfamiliar with programming terminology.
Copy linkTweet thisAlerts:
@Willy_DuittJul 25.2005 — Jeez, give him a break. He's probably British or something, or just unfamiliar with programming terminology.[/QUOTE]

[b]SHUT UP STUPID[/b]...

Whatever remarks I made had to do with his adding underscores for foramtting...

Step off your "I'm [b]L33T[/b]" and kiss my a$$...

.....Willy
Copy linkTweet thisAlerts:
@Willy_DuittJul 25.2005 — [b]SHUT UP STUPID[/b]...

Whatever remarks I made had to do with his adding underscores for foramtting...

Step off your "I'm [b]L33T[/b]" and kiss my a$$...

.....Willy[/QUOTE]


Oh... I forgot... ?
Copy linkTweet thisAlerts:
@ScriptageJul 25.2005 — Jeez, give him a break. He's probably British or something, or just unfamiliar with programming terminology.[/QUOTE]
Excuse me? Are British people thick? Do British people not know programming terminology? God you people make me sick.

You probably need to change the line: if SP = 1 {

to if(SP [B]==[/B] 1) {

the if statement if(SP=1) does not actually test SP against the value on the right hand side ("1"). The if statement can be translated as:

if 1 can be assigned to SP then...

The line if(SP [B]==[/B] 1) can be translated as:

if SP is equal to 1 then ...

Regards
Copy linkTweet thisAlerts:
@rbleskow999authorJul 25.2005 — Thanks [B]Scriptage[/B] for your "positive" input. ?

Bye the way, the calculations work when I use "=", and they [U]don't work[/U] when I use "==". go figure...

I'm sure that willy guy has a chip on his shoulder (that he knows about, but he ignores it). It's a superiority complex. We'll just have to live with it.

Even Albert Einstein didn't know what Babe Ruth's batting average was....

Let's all try to relax, shall we?

By the way willy: (brackets == parenthesis) on THIS planet, too. :p

[COLOR=Navy][B][I][FONT=Comic Sans MS]Regards;

The Kooky Dutchman[/FONT] :rolleyes: [/I]
[/B]
[/COLOR]
Copy linkTweet thisAlerts:
@JPnycJul 25.2005 — Actually you don't have to live with it. He's banned.
Copy linkTweet thisAlerts:
@rbleskow999authorJul 25.2005 — WOW!... That was quick!
Copy linkTweet thisAlerts:
@Compguy_PeteJul 25.2005 — We aim to please!
Copy linkTweet thisAlerts:
@ExuroJul 25.2005 — Excuse me? Are British people thick? Do British people not know programming terminology? God you people make me sick.[/QUOTE]
?

I didn't mean any of those things at all. All I was saying is that I'm pretty sure they call parentheses "brackets" in Britain (am I wrong?), and that if he's new to programming he might not know that that's what you're supposed to call them.
Copy linkTweet thisAlerts:
@KravvitzJul 25.2005 — By the way willy: (brackets == parenthesis) on THIS planet, too. :p[/QUOTE]

Not technically correct. This is like the square/rectangle thing -- a square is always a rectangle, but a rectangle is not necessarily a square.

One kind of bracket is the parenthesis, but since there are multiple kinds of brackets, they are not necessarily the same.

Types of brackets:
[list]
  • [*]() parenthesis

  • [*][] square brackets

  • [*]<> angle brackets

  • [*]{} (curly) braces

  • [/list]




    I would appreciate it if you would refer to "(" and ")" as parenthesis to avoid confusion.
    Copy linkTweet thisAlerts:
    @the_treeJul 25.2005 — function whatever()
    {
    if (SP == 1) {
    switch(t){
    case '*':
    // when t = '*'
    break
    case '^':
    // when t = '^'
    break
    default:
    // otherwise
    }
    }
    }
    http://www.w3schools.com/js/js_conditionals.asp
    Copy linkTweet thisAlerts:
    @rbleskow999authorJul 25.2005 — oh, brother
    Copy linkTweet thisAlerts:
    @omnicityJul 26.2005 — Types of brackets:
    [list]
  • [*]() parenthesis

  • [*][] square brackets

  • [*]<> angle brackets

  • [*]{} (curly) braces

  • [/list]




    [/QUOTE]




    Not technically correct either.



    In English, parenthesis means a collection of braces, for which the singular is bracket. Your naming convention above is normal for programmers, but not outside that field.

    There is no 'angle' bracket in English.
    Copy linkTweet thisAlerts:
    @rbleskow999authorJul 26.2005 — HERE YOU GO! enough with the brackets already... :mad:

    Brackets are punctuation marks, used in pairs to set apart or interject text within other text. Types of brackets include parentheses ( ), (the singular is parenthesis) square brackets [ ], braces { }, and angle brackets (chevrons) &#9001; &#9002; (< >). All these forms may be used according to typographical conventions that may vary from publication to publication and may vary even more from language to language. Some typical uses in English texts follow.

    Types of brackets - Parentheses ( )

    Parentheses are used to contain parenthetical (or optional, additional) material in a sentence that could be removed without destroying the meaning of the main text. For example, "George Washington (the father of his country) was not the wooden figure with wooden teeth that many think him." Indeed, such an interjection is called a parenthesis, and may also be set off with dashes or commas. Overuse of parentheses is usually a sign of a badly structured text; unfortunately this is pretty common in the Wikipedia.

    Parentheses may be used to add supplementary information, such as "Sen. Kennedy (D., Massachusetts) spoke at length".

    Historically, parentheses have been used in place of the solidus in order to depict alternatives, such as "parenthesis)(parentheses".

    Parentheses may also be nested (with one set inside another set (this is not commonly used in formal writing)). Sometimes square brackets will be used for the inner set of parentheses.

    Any punctuation inside parentheses or other brackets is independent from the rest of the text: "Mrs. Pennyfarthing (What? Yes, that was her name!) was my landlady".

    In mathematics, parentheses are used to signify a different precedence of operators. For example, 2 + 3 × 4 would be 14, since the multiplication is done before the addition. (2 + 3) × 4 is 20, because the parentheses override normal precedence, causing the addition to be done first. They are also used to set apart the arguments to mathematical functions. For example, f(x) is the function f applied to the variable x.

    Parentheses are sometimes called round brackets, curved brackets or, colloquially, parens, or fingernails. John Lennard (in "The exploitation of parentheses in English printed verse") usefully coined the term lunula to refer specifically to the opening curved bracket, the closing curved bracket and the textual contents between.

    ===================================

    [U][B]PARENTHESIS CONSPIRACY[/B][/U]

    [U]Frequently asked questions[/U]

    [I]I think I have contracted parenthesitis. What should I do?[/I]

    The first step is to not panic. After that, you should definitely consider joining the conspiracy (see above).

    I think I have contracted parenthephobia. What should I do?

    There is no known cure to parenthephobia, but here are some things you might want to try: buy a large set of parentheses and keep them in your desk, ready for you. Try re-reading everything you’ve written and seeing if there is anywhere that you can add parentheses (and there is always room for parentheses and brackets). If none of these work, you are suffering from an acute case of parenthephobia and more direct measures are necessary.

    [I]When using Chinese Boxes (parentheses within parentheses) would it be more appropriate to first use a bracket and then a parenthesis inside it or would it be best to use a parenthesis within a parenthesis as you did on your website? Inquiring (albeit sick) minds want to know.[/I]

    Well, it depends. Some people use normal brackets (like these—what you’d call parentheses) for different purposes to square brackets [like these]. (For example, square brackets might be used indicate references or footnotes.) In these cases, it’s best to stick to using the same type of brackets when you’re nesting parentheses. On the other hand, it’s common in mathematics (where brackets inside brackets inside brackets are a lot more common than in most people’s writing) to use (large brackets (on the outside)) or [square brackets] or even {curly brackets [which (for some reason) Americans call “braces”]}. So if you aren’t already using square brackets or curly brackets for anything else, it would perhaps be clearer to use distinct types of brackets when you’re nesting them.

    Brackets are punctuation marks, used in pairs to set apart or interject text within other text. Types of brackets include parentheses ( ), (the singular is parenthesis) square brackets [ ], braces { }, and angle brackets &#9001; &#9002;. All these forms may be used according to typographical conventions that may vary from publication to publication and may vary even more from language to language. Some typical uses in English texts follow.
    Copy linkTweet thisAlerts:
    @rbleskow999authorJul 26.2005 — More on: [B][I]brackets[/I][/B]

    [B][I][U]Types of brackets[/U][/I][/B]

    [U]Parentheses ( )[/U]

    Parentheses are used to contain parenthetical (or optional, additional) material in a sentence that could be removed without destroying the meaning of the main text. For example, "George Washington (the father of his country) was not the wooden figure with wooden teeth that many think him". Indeed, such an interjection is called a parenthesis, and may also be set off with dashes or commas. Overuse of parentheses is usually a sign of a badly structured text.

    Parentheses may be used to add supplementary information, such as "Sen. Kennedy (D., Massachusetts) spoke at length".

    Historically, parentheses have been used in place of the slash in order to depict alternatives, such as "parenthesis)(parentheses".

    Parentheses may also be nested (with one set inside another set (this is not commonly used in formal writing)). Sometimes square brackets will be used for the inner set of parentheses (in other words, a secondary phrase in parentheses).

    Any punctuation inside parentheses or other brackets is independent from the rest of the text: "Mrs. Pennyfarthing (What? Yes, that was her name!) was my landlady".

    In mathematics, parentheses are used to signify a different precedence of operators. For example, 2 + 3 × 4 would be 14, since the multiplication is done before the addition. (2 + 3) × 4 is 20, because the parentheses override normal precedence, causing the addition to be done first. They are also used to set apart the arguments to mathematical functions. For example, f(x) is the function f applied to the variable x. In the coordinate system, parentheses are used to denote a set of coordinates. For example, (4,7) represents the point located at 4 on the x-axis and 7 on the y-axis.

    Parentheses are sometimes called round brackets, curved brackets or, colloquially, parens, or fingernails. John Lennard (in "The exploitation of parentheses in English printed verse") usefully coined the term lunula to refer specifically to the opening curved bracket, the closing curved bracket and the textual contents between.

    [U]Square brackets [ ][/U]

    Square brackets are used to enclose explanatory or missing [...] material, especially in quoted text. For example, "I appreciate it [the honor], but I must refuse". Or, "the future of psionics [See definition] is in doubt".

    The bracketed expression [sic] (Latin for "thus") is used to indicate errors that are "thus in the original"; a bracketed ellipsis [...] is used to indicate deleted material; bracketed comments are used to indicate when original text has been modified for clarity: "I'd like to thank [several unimportant people] and my parentals [sic] for their love, tolerance [...] and assistance [italics added]".

    Square brackets are also sometimes used as parentheses within parentheses - "secondary parentheses" as mentioned earlier.

    With the International Phonetic Alphabet, square brackets are used to indicate a phonetic transcription (as opposed to a phonemic one).

    In chemistry, square brackets can also be used to represent the concentration of a chemical substance, or to denote a complex ion.

    In wikis like Wikipedia, double square brackets ( [[ ]] ) are used to form wiki links to other pages.

    [U]Curly brackets or braces { }[/U]

    Curly brackets (so-called in European English; North American English prefers braces) are sometimes used in prose to indicate a series of equal choices: "Select your animal {goat, sheep, cow, horse} and follow me". They are used in specialized ways in poetry and music (to mark repeats or joined lines). In mathematics they are used to delimit sets.

    Presumably due to the similarity of the words brace and bracket (they share an etymology), many people casually treat brace as a synonym for bracket. Therefore, when it is necessary to avoid any possibility of confusion, such as in computer programming, it may be best to use the term curly bracket rather than brace. However, general usage in North American English favors the latter form. The term curly braces is redundant since that is the only kind of braces there are.

    In computer programming, curly brackets sometimes denote the beginning and ending of a sequence of statements.

    Angle brackets or Chevrons &#9001; &#9002;

    Angle brackets (&#9001;, &#9002? are often used to enclose highlighted material. Some dictionaries use angle brackets to enclose short excerpts illustrating the usage of words. True angle brackets are not available on a typical computer keyboard, so the "less than" and "greater than" symbols are used instead (<, >). These are often loosely referred to as angle brackets when used in this way. For example, the symbols < and > are often used to set apart URLs in text, such as "I found it in Wikipedia <http://www.wikipedia.org/>".

    Angle brackets are used in mathematics and logic to delimit ordered n-tuples.

    Single and double angle brackets (&#9001;&#9001;, &#9002;&#9002? or pairs of the appropriate comparison operators (<<, >>) are sometimes used instead of guillemets when the proper glyphs are not available.

    The mathematical or logical symbols for greater-than (>) and less-than (<), when used as such, are not punctuation marks.

    [U]In computing[/U]

    Opening and closing parentheses correspond to Unicode and ASCII characters 40 and 41, or 0x0028 and 0x0029, respectively.

    For square brackets corresponding values are 91 and 93, or 0x005B and 0x005D.

    For braces, 123 and 125, or 0x007B and 0x007D.

    True angle brackets are available in Unicode at code points 9001 and 9002, or 0x2329 and 0x232A. The less than and greater than symbols can be found in both Unicode and ASCII at code points 60 and 62 respectively, or 0x003C and 0x003E.

    [U]Also, in many computer languages:[/U]

    "(" and ")" are used to contain the arguments to functions: substring($val,10,1). Parentheses are so ubiquitous in the Lisp programming language that the name is said to be an acronym for "Lots of Irritating Superfluous Parentheses". They may also be used to indicate the start and end of lists.

    "[" and "]" are used to define the number of elements in an array, or reference one of those elements: $queue[3]. In MediaWiki's syntax, a double square-bracket set is used to make a wikilink to the term defined inside: [[Bracket]].

    "{" and "}" are used to define the beginning and ending of blocks of code or define the initial contents of an array. To complicate things, in the Pascal programming language, "{" and "}" define the beginning and ending of comments. Languages which use the former convention are said to belong to the curly brace family of programming languages.

    "<" and ">" are used in SGML (and other formats based on SGML, such as HTML and XML), to enclose code tags: <div>.

    In quantum mechanics, brackets are also used as part of Dirac's formalism to note vectors form the dual spaces of the Bra <A| and the Ket |B>.
    Copy linkTweet thisAlerts:
    @omnicityJul 26.2005 — If we are going to go to these lengths, then I think that we need a little context.

    While it does not have the lineage of the OED, Collins has been around for a while, and has the advantage of being available on-line:

    [B][U]parenthesis [/U] [/B] noun -ses

    1. a phrase, often explanatory or qualifying, inserted into a passage with which it is not grammatically connected, and marked off by brackets, dashes, etc.

    2. [U]Also called: bracket [/U] either of a pair of characters, (), used to enclose such a phrase or as a sign of aggregation in mathematical or logical expressions

    3. an intervening occurrence; interlude; interval

    4. in parenthesis inserted as a parenthesis

    History: C16: via Late Latin from Greek: something placed in besides, from parentithenai, from para-1 + en-2 + tithenai to put

    parenthetic or parenthetical adjective

    parenthetically adverb [/QUOTE]


    [B][U]brace[/U][/B] noun

    1. In full: hand brace a hand tool for drilling holes, with a socket to hold the drill at one end and a cranked handle by which the tool can be turned See also: brace and bit

    2. something that steadies, binds, or holds up another thing

    3. a structural member, such as a beam or prop, used to stiffen a framework

    4. a sliding loop, usually of leather, attached to the cords of a drum: used to change its tension

    5. a pair; two, esp of game birds a brace of partridges;

    6. either of a pair of characters, , used for connecting lines of printing or writing or as a third sign of aggregation in complex mathematical or logical expressions that already contain parentheses and square brackets

    7. Also called: accolade a line or bracket connecting two or more staves of music

    8. (often plural) an appliance of metal bands and wires that can be tightened to maintain steady pressure on the teeth for correcting uneven alignment

    9. any of various appliances for supporting the trunk, a limb, or teeth

    10. another word for: bracer 2:

    11. (in square-rigged sailing ships) a rope that controls the movement of a yard and thus the position of a sail

    12. See: braces

    13. verb (mainly tr) to provide, strengthen, or fit with a brace

    14. to steady or prepare (oneself or something) as before an impact

    15. (also intr) to stimulate; freshen; invigorate sea air is bracing;

    16. to control the horizontal movement of (the yards of a square-rigged sailing ship)

    History: C14: from Old French: the two arms, from Latin bracchia arms [/QUOTE]




    [B][U]bracket [/U] [/B] noun

    1. an L-shaped or other support fixed to a wall to hold a shelf, etc

    2. one or more wall shelves carried on brackets

    3. a support projecting from the side of a wall or other structure See also: corbel ancon console 2:

    4. [U]Also called: square bracket [/U] either of a pair of characters, , used to enclose a section of writing or printing to separate it from the main text

    [U]5. a general name for parenthesis, square bracket and brace (sense 6) [/U]

    6. a group or category falling within or between certain defined limits the lower income bracket;

    7. the distance between two preliminary shots of artillery fire in range-finding

    8. a skating figure consisting of two arcs meeting at a point, tracing the shape -kets -keting -keted

    9. verb (transitive) to fix or support by means of a bracket or brackets

    10. to put (written or printed matter) in brackets, esp as being irrelevant, spurious, or bearing a separate relationship of some kind to the rest of the text

    11. to couple or join (two lines of text, etc.) with a brace

    12. (often foll by with) to group or class together to bracket Marx with the philosophers;

    13. to adjust (artillery fire) until the target is hit

    History: C16: from Old French braguette codpiece, diminutive of bragues breeches, from Old Provençal braga, from Latin braca breeches [/QUOTE]
    Copy linkTweet thisAlerts:
    @KravvitzJul 26.2005 — I guess this is a difference between American English and British English.
    Copy linkTweet thisAlerts:
    @JPnycJul 26.2005 — There's plenty of differences.
    Copy linkTweet thisAlerts:
    @BeachSideJul 28.2005 — nvr mind... sorry :o
    ×

    Success!

    Help @rbleskow999 spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 4.25,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,

    tipper: @Samric24,
    tipped: article
    amount: 1000 SATS,
    )...