Gambas文档
编译和安装
错误消息
代码片段
翻译
废弃的组件
教程
开发环境文档
开发文档
名词解释
如何操作
说明
维基手册
维基搜索
维基许可协议
文档
应用程序仓库
语言概览
语言索引
#Else
#Endif
#If
+INF
-INF
Abs
Access
ACos
ACosh
Alloc
AND
AND IF
Ang
APPEND
AS
Asc
ASin
ASinh
Asl
Asr
ASSERT
ATan
ATan2
ATanh
Base$
Base64$
BChg
BClr
BEGINS
Bin$
Boolean@
BREAK
BSet
BTst
BYREF
Byte@
CASE
CATCH
CBool
Cbr
CByte
CDate
Ceil
CFloat
CHGRP
CHMOD
Choose
CHOWN
Chr$
CInt
CLASS
CLong
CLOSE
Comp
CONST
CONTINUE
Conv$
COPY
Cos
Cosh
CPointer
CREATE
CREATE PRIVATE
CREATE STATIC
CShort
CSingle
CStr
CString
CVariant
Date
Date@
DateAdd
DateDiff
Day
DConv$
DEBUG
DEC
Dec
DEFAULT
Deg
DFree
DIM
Dir
DIV
DO
DOWNTO
EACH
ELSE
END
ENDIF
ENDS
END SELECT
END STRUCT
END WITH
ENUM
Eof
ERROR
ERROR TO
Eval
Even
EVENT
EXEC
Exist
Exp
Exp2
Exp10
Expm
EXPORT
EXTERN
FALSE
FAST
FAST UNSAFE
FINALLY
Fix
Float@
Floor
FLUSH
FOR
FOR EACH
Format$
Frac
Free
FromBase
FromBase64$
FromUrl$
FUNCTION
GOSUB
GOTO
Hex$
Hour
Html$
Hyp
IF
IIf
IN
INC
INCLUDE or #INCLUDE
INHERITS
INPUT
INPUT FROM
InStr
Int
Int@
Integer@
IS
IsAlnum
IsAscii
IsBlank
IsBoolean
IsDate
IsDigit
IsDir
IsFloat
IsHexa
IsInf
IsInteger
IsLCase
IsLetter
IsLong
IsLower
IsMissing
IsNaN
IsNull
IsNumber
IsPunct
IsSpace
IsUCase
IsUpper
KILL
LAST
LCase$
Left$
Len
LET
LIBRARY
LIKE
LINE INPUT
LINK
LOCK
Lof
Log
Log2
Log10
Logp
Long@
LOOP
Lsl
Lsr
LTrim$
Mag
MATCH
Max
ME
Mid$
Min
Minute
MkBool$
MkBoolean$
MkByte$
MkDate$
MKDIR
MkFloat$
MkInt$
MkInteger$
MkLong$
MkPointer$
MkShort$
MkSingle$
MOD
Month
MOVE
NEW
NEXT
NOT
Now
NULL
Oct$
Odd
ON GOSUB
ON GOTO
OPEN
OPEN MEMORY
OPEN MEMORY
OPEN NULL
OPEN PIPE
OPEN PIPE
OPEN STRING
OPTIONAL
OR
OR IF
OUTPUT
OUTPUT TO
PEEK
Pi
Pointer@
PRINT
PRIVATE
PROCEDURE
PROPERTY
PUBLIC
QUIT
Quote$
Rad
RAISE
Rand
RANDOMIZE
RDir
READ
Realloc
REPEAT
Replace$
RETURN
Right$
RInStr
RMDIR
Rnd
Rol
Ror
Round
RTrim$
Scan
SConv$
Second
SEEK
Seek
SELECT
Sgn
SHELL
Shell$
Shl
Short@
Shr
Sin
Single@
Sinh
SizeOf
SLEEP
Space$
Split
Sqr
Stat
STATIC
STEP
STOP
STOP EVENT
Str$
Str@
String$
String@
StrPtr
STRUCT
SUB
Subst$
SUPER
SWAP
Tan
Tanh
Temp$
THEN
Time
Timer
TO
Tr$
Trim$
TRUE
TRY
TypeOf
UCase$
UnBase64$
UNLOCK
Unquote$
UNTIL
Url$
USE
Val
VarPtr
WAIT
WATCH
Week
WeekDay
WEND
WHILE
WITH
WRITE
XOR
Year
本地化和翻译函数
变量声明
常量表达式
常量声明
方法声明
复数
赋值
赋值操作
行标号
结构体声明
局部变量声明
逻辑运算
枚举声明
内置集合
内置数组
使用保留字作为标识符
事件声明
事件循环
属性声明
数据类型
数据类型的二进制表示形式
数组声明
算术运算
外部函数管理
外部函数声明
语言常量
运算符优先级
专用方法
字符串操作
主题
组件
最近的修改

赋值

[ LET ] Destination = Expression

表达式的值赋给下列元素之一:
  • 一个局部变量

  • 一个函数参数

  • 一个公共变量或者一个类变量

  • 一个数组元素

  • 一个对象公共变量

  • 一个对象属性属性

该命令不能用于设置函数返回的值。要给函数分配值,请使用RETURN语句。

许多有返回值的命令也可以使用赋值语法: EXECNEWOPENRAISESHELL

示例

iVal = 1972
Name = "[/def/gambas]"
hObject.Property = iVal
cCollection[sKey] = Name
...

Assignments of embedded structures or arrays

自从 3.17

If the assignment Destination is actually a structure or an embedded array, then the contents of Expression is recursively copied in the Destination.

Of course, Expression is first converted to the datatype of Destination before the copy is done.

When an array is copied, if the source and the destination do not have the same number of elements, then the smallest number of elements is used to do the copy.

The copy is done only when the structure or the array are embedded. If not embedded, then structures and arrays are normal Gambas objects, and the assignment is just a reference copy.

Examples

Struct Person
  FirstName As String
  LastName As String
  Age As Integer
  BirthDate As Date
  Height As Float
End Struct

Private $aPeople[16] As Struct Person
Private $hFirst As Struct Person
Private $aOther[4] As Struct Person

...

' Copy the 4th people into $hFirst
$hFirst = $aPeople[3]
' Copy the four first people into $aOther
$aOther = $aPeople
' Only the four first elements of $aPeople are modified
$aPeople = $aOther

参见