BASIC Variables BASIC is designed to allow simple programs to be developed quickly,and is widely used on micro-computers.There are many versions of BASIC:However an ANSI standard does exist. Most versions are interpreted interactively, with, statements checked as they are typed in. The end of a line serves to delimit declarations and statements.Colons can be used in most versions of BASIC to separate statements on the same line. All lines have to be numbered, and these numbers serves labels used as the destination of GOTO and GOSUB (subroutine call) statements.Standard BASIC allows up to two characters to be used as identifiers:a letter followed by a digit. Comments are prefixed by REM (for remark). Types available vary with different versions.On the PET personal computer, there are point floating numbers (the default assumption for an identifier),integers (identifiers ending in%)and strings(identifiers ending in$).Variables of these types don’t have to be declared-, numbers have value()NN-handiest used, strings are null when first used . Howe herewith BASIC on some machines. variables do not have default initialization and an error is indicated if one tries to use an undefined variable.Explicit type con-version is possible, e.g. VAL converts a string representing a number to that number. Multi -dimensional arrays are static and declared using DIM.There are no records. 翻译: BASIC语言变量 BASIC语言设计得允许迅速开发简络程序,同时它也被广泛地用到微机土。BASIC语言有许多版本,但的确存在着一种ANSI标准文本。大多数版本的BASIC语言,当其语句被键入时,该语句一边被检查,一边被交互地解释。 行结束符是用来给说明及语句定界的,大多数BASIC的版本中, 冒号被用来将同一行的语句分开。 所有的行均必须加以编号,这些编号被用作GOTO和GOSUB(一子程序 调用)语句的目的地的标号。标准的BASIC允许用多达二个字符作为 标识符:一个字母后跟一位数字, 注释前面冠有REM(注释)标志。 可用的变量类型随版本不同而 各异。在PET个人计算机中,有浮点 数型(缺省值假定为某一标识 符)、整型〔标识符用%来结尾〕和 字符串型(标识符用¥)。若这些 类型的变量末被说明,则当它们第 一次被用到时,数字值为O,字符串则为空。但是,在某些机器的BASIC中,变量并没有缺省值初始 化,如果有谁试图使用一个未加定义的变量的话,机器将批示为错误。类型的简易转换是可能的,如VAL可将代表一个数的串转换为该 数。多维数组是静态的,DIM利用 加以说明,BASIC中没有一记录。 |