FB_UNIQUEID_POP
- 来源: https://www.freebasic.net/wiki/wikka.php?wakka=KeyPgDdfbuniqueidpop
- 最后更新: 2021-10-11
编译器执行的内置定义(宏)。
语法
` FB_UNIQUEID_POP( stack-id )
`
参数
stack-id
要弹出的栈名称
描述
从由 stack-id 标识的栈中弹出一个标识符(栈大小减少 1)。
(__FB_UNIQUEID__ 用于获取栈顶标识符,__FB_UNIQUEID_PUSH__ 用于向栈压入新的唯一标识符)
注意:
"stack-id" 名称本身与所有其他符号属于独立命名空间。
栈中只能包含"唯一标识符"。
"唯一标识符"是模块中唯一的 fb 符号名,不会与其他符号名冲突或遮蔽("唯一标识符"的名称形式为 "LT_xxxx",因此可能并非完全唯一)。
fb 内部使用 "LT_xxxx" 形式作为标签、符号、临时变量等(因此自版本 0.0 起,所有 fbc 程序都应避免将 fbc 符号命名为此形式)。
当此栈不再使用时,建议将其清空(最终应用的 __FB_UNIQUEID_POP__ 次数必须与该栈的 __FB_UNIQUEID_PUSH__ 次数相同)。
在使用的任意时刻,从开始累计应用的 __FB_UNIQUEID_POP__ 次数必须始终小于或等于累计应用的 __FB_UNIQUEID_PUSH__ 次数。
示例
另请参阅 __FB_UNIQUEID__ 示例。
start GeSHi
vb
#macro repeat ? ( count ) '' with user named variable
Scope
Dim __counter__ As UInteger = count
While( __counter__)
#endmacro
#macro end_repeat '' with user named variable
__counter__ -= 1
Wend
End Scope
#endmacro
Print "With user named variable:"
repeat 3
Print " outer"
repeat 2
Print " --- inner"
end_repeat
end_repeat
Print
#undef repeat
#undef end_repeat
#macro repeat ? ( count ) '' with "unique identifier" variable
__FB_UNIQUEID_PUSH__( ctx )
Dim __FB_UNIQUEID__( ctx ) As UInteger = count
While( __FB_UNIQUEID__( ctx ) )
#endmacro
#macro end_repeat '' with "unique identifier" variable
__FB_UNIQUEID__( ctx ) -= 1
Wend
__FB_UNIQUEID_POP__( ctx )
#endmacro
Print "With ""unique identifier"" variable:"
repeat 3
Print " outer"
repeat 2
Print " --- inner"
end_repeat
end_repeat
Sleep
/' Output:
With user named variable:
outer
--- inner
--- inner
outer
--- inner
--- inner
outer
--- inner
--- inner
With "unique identifier" variable:
outer
--- inner
--- inner
outer
--- inner
--- inner
outer
--- inner
--- inner
'/end GeSHi
第一段代码有效,因为 'counter' 变量定义在 [Scope...End Scope] 块中,因此允许嵌套。
第二段代码有效(无需 [Scope...End Scope] 块),因为使用了编译器提供的"唯一标识符"。
另请参阅 __FB_UNIQUEID_PUSH__ 示例。
版本
- 自 fbc 1.08.0 起
与 QB 的区别
- FreeBASIC 新增
另请参阅
__FB_UNIQUEID_PUSH____FB_UNIQUEID__
返回 目录