开发者

An object as both an array and a variable?

I inherited this old TurboBasic code base, and I am converting it to something more modern. Can you explain how in this code snippet Wind can be both a variable and an array?

Dim Wind(1:3,2:3)

Sub WindFunction

     Shared Wind()
  开发者_如何学编程   local var
     Erase Wind

     Wind = 123

     var = Wind

     Wind(1,2) = 567

End Sub


The wikipedia page on Turbo Basic suggests that it is one of the dialects where

  • A ... double
  • A$ ... string
  • A(...) ... array of double

are treated as totally separate variables, so in your case you have

  • Wind(...) ... an array of double
  • Wind ... a double

These dialects treat most variables' types just by their name. Only arrays need to be declared. Sometimes even arrays can be addressed without declaration, they are then assumed to be an array with one dimension and a size of 10.

Some more links can be found here on SO (oh, just saw it's by you, too *g*): https://stackoverflow.com/questions/4147605/learning-turbobasic

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜