====== IF ====== Evaluates a conditional expression with a boolean result **Implemented by:** [[:basics:Dartmouth:dartmouth1]], [[:basics:Dartmouth:dartmouth4]], [[:basics:ANSI:ansimin]], [[:basics:ANSI:ansifull]], [[:basics:decbasic:]], [[:basics:Altair:]], [[:basics:a2int:]], [[:basics:Applesoft:]], [[:basics:TI994:ti994ext]], [[:basics:CBM:]], [[:basics:Atari:]], [[:basics:msatari:]], [[:basics:trs80:]], [[:basics:trs80:level2]], [[:basics:trscolor:]], [[:basics:trscolor:colormc]], [[:basics:Sinclair:]], [[:basics:Atom:]], [[:basics:BBC:]], [[:basics:GWBASIC:]], [[:basics:MSX:]], [[:basics:bwbasic:]], [[:basics:bwbasic:bw32]], [[:basics:ABasiC:]], [[:basics:msqb:QBasic]], [[:basics:VBDOS:]], [[:basics:FreeBASIC:]], [[:basics:ugBASIC:]], [[:basics:minibasicmm:]], [[:basics:minibasicjs:]] **With variations:** [[:basics:hptsb:]], [[:basics:Applesoft:tasc]] (string-resulting expressions forbidden), [[:basics:TI994:]] (branches only), [[:basics:Atari:ataplus]] (multiline IF; with semicolon, no [[THEN]] after expression and[[ENDIF]]), [[:basics:Atari:atxl]] (multiline IF; with semicolon, no [[THEN]] after expression and[[ENDIF]]), [[:basics:Gambas:]], [[:basics:EndBASIC:]] (single-line or multiline) **Also written as: ** /* Alternative spellings and abbreviations this keyword has. No need to refer to a BASIC, there is a section for that later. */ ===== Usage ===== The primary and original purpose of IF was checking a condition for performing a jump to other line if it resulted true. For that, the condition is followed by [[THEN]] and/or [[GOTO]] keywords and the line number or label. ==== Variations ==== A number of BASICs inspired by [[:basics:decbasic]] allowed IF to be used like a "second order" command, in constructions such as ''PRINT A IF A < 10''((https://en.wikipedia.org/wiki/BASIC-PLUS)). ===== Examples ===== /* This is a code block, using GeSHi syntax highlighting for //gwbasic//. Other styles of interest might be //basic4gl//, //blitzbasic//, //freebasic//, //gambas//, //locobasic//, //purebasic//, //qbasic//, //sdlbasic//, //thinbasic//, //vb//, //vbnet//, //xbasic// or //zxbasic//. */ 10 PRINT "HELLO" ===== Comments ===== /* Origin of the keyword, opinions, history... */ ===== Related keywords ===== /* Keywords that are often or always used along this one */ * [[THEN]] * [[GOTO]] * [[GOSUB]] ===== Similar keywords ===== /* Keywords with the same or similar functionality found in other versions of BASIC */ ===== In other languages... ===== /* For parallels and comparisons with other modern-day languages */ ===== References ===== /* If you used the ((citation)) syntax elsewhere in the text, they will appear under this section. But you can write some recommendations of books, magazines, etc */ {{tag>Statements}}