- Parrot 教程
- Parrot - 主頁
- Parrot - 概覽
- Parrot - 安裝
- Parrot - 說明
- Parrot - 垃圾回收
- Parrot - 資料型別
- Parrot - 暫存器
- Parrot - 操作
- Parrot - 分支
- Parrot 示例
- Parrot - 示例
- Parrot 資源
- Parrot - 快速指南
- Parrot - 實用資源
Parrot - 操作
你可以執行各種操作。例如,我們能夠打印出某個暫存器或常量的內容
set I1, 10 print "The contents of register I1 is: " print I1 print "\n"
上面的指令將生成 暫存器 I1 的內容是:10
我們可以在暫存器上執行數學運算
# Add the contents of I2 to the contents of I1 add I1, I1, I2 # Multiply I2 by I4 and store in I3 mul I3, I2, I4 # Increment I1 by one inc I1 # Decrement N3 by 1.5 dec N3, 1.5
我們甚至還可以執行一些簡單的字串操作
set S1, "fish" set S2, "bone" concat S1, S2 # S1 is now "fishbone" set S3, "w" substr S4, S1, 1, 7 concat S3, S4 # S3 is now "wishbone" length I1, S3 # I1 is now 8
廣告