T Troberg Well-Known Member Licensed User Longtime User Mar 27, 2015 #1 I very often find myself writing code such as: Code: Copy Dim n as int For n=0 to 100 'Do stuff Next Now, some languages have a neat construct which saves a mostly unnecessary line. In Basic, it would be something like: Code: Copy For n as int=0 to 100 'Do stuff Next Basically, an inline Dim where the variable is dimmed on first use. Somewhat like an even shorter form of: Code: Copy Dim x as int = 0 as a substitute for: Code: Copy Dim x as int x=0 Personally, I wouldn't use it on important or complex variables, but for trivial ones like in the example, it's very practical.
I very often find myself writing code such as: Code: Copy Dim n as int For n=0 to 100 'Do stuff Next Now, some languages have a neat construct which saves a mostly unnecessary line. In Basic, it would be something like: Code: Copy For n as int=0 to 100 'Do stuff Next Basically, an inline Dim where the variable is dimmed on first use. Somewhat like an even shorter form of: Code: Copy Dim x as int = 0 as a substitute for: Code: Copy Dim x as int x=0 Personally, I wouldn't use it on important or complex variables, but for trivial ones like in the example, it's very practical.
Erel B4X founder Staff member Licensed User Longtime User Mar 27, 2015 #2 You don't need to call dim here at all. A for loop automatically declares an int value (if it is not already declared). Last edited: Mar 27, 2015
You don't need to call dim here at all. A for loop automatically declares an int value (if it is not already declared).
Jaames Active Member Licensed User Longtime User Mar 28, 2015 #4 Erel said: You don't need to call dim here at all. A for loop automatically declares an int value (if it is not already declared). Click to expand... And it is working like that from the first version I bought 1.8 (year 2012)
Erel said: You don't need to call dim here at all. A for loop automatically declares an int value (if it is not already declared). Click to expand... And it is working like that from the first version I bought 1.8 (year 2012)