RandomCoder Well-Known Member Licensed User Longtime User Sep 10, 2015 #21 Look what you've started now @ilan
Erel B4X founder Staff member Licensed User Longtime User Sep 10, 2015 #22 ilan said: Btw, is it possible to add in an if statement ":" like in vb? Click to expand... No. This is by design. ilan said: And also what could be a great update to the next version is to be able to test a code without to install on the phone. Like i can do in java or xcode. Sometimes i only want to test a code and get the result to the log so no need to connect phone to run it... would be great to have such a feature. Click to expand... It is already implemented with Debug (rapid) mode.
ilan said: Btw, is it possible to add in an if statement ":" like in vb? Click to expand... No. This is by design. ilan said: And also what could be a great update to the next version is to be able to test a code without to install on the phone. Like i can do in java or xcode. Sometimes i only want to test a code and get the result to the log so no need to connect phone to run it... would be great to have such a feature. Click to expand... It is already implemented with Debug (rapid) mode.
ilan Expert Licensed User Longtime User Sep 10, 2015 #23 RandomCoder said: Look what you've started now @ilan Click to expand... i am a forum trouble maker Last edited: Sep 11, 2015
ilan Expert Licensed User Longtime User Sep 10, 2015 #24 Erel said: It is already implemented with Debug (rapid) mode. Click to expand... really? sorry i didnot knew that, so i can run without to install the app on phone or VM?
Erel said: It is already implemented with Debug (rapid) mode. Click to expand... really? sorry i didnot knew that, so i can run without to install the app on phone or VM?
S sorex Expert Licensed User Longtime User Sep 10, 2015 #25 it installs once and then updates code parts. (untill you stop the app) so it's not really a valid answer
it installs once and then updates code parts. (untill you stop the app) so it's not really a valid answer
Erel B4X founder Staff member Licensed User Longtime User Sep 10, 2015 #26 You need to install the app. But later when you modify the code it doesn't need to be reinstalled (not in all cases). Didn't you notice it in B4i? That you don't need to approve the installation each time you run?
You need to install the app. But later when you modify the code it doesn't need to be reinstalled (not in all cases). Didn't you notice it in B4i? That you don't need to approve the installation each time you run?
S sorex Expert Licensed User Longtime User Sep 10, 2015 #27 if it is just a code sub it could build to a plain java jar. if it involved GUI stuff that would be harder ofcourse.
if it is just a code sub it could build to a plain java jar. if it involved GUI stuff that would be harder ofcourse.
ilan Expert Licensed User Longtime User Sep 10, 2015 #28 Erel said: You need to install the app. But later when you modify the code it doesn't need to be reinstalled (not in all cases). Didn't you notice it in B4i? That you don't need to approve the installation each time you run? Click to expand... oh, i didnot mean that option, i noticed it of course, i only wonder after watching some java tutorials if it could be possible to do simple code without install the app. like i have a list and want to get to the log the item in index 12 but dont want to install now the app only see if code if working or to get a true false, .. also to explain maybe b4x with simple code snippets it would be very good to have such an option, it could be also a different app no need to implement it in b4a/b4i. something where i can put a code and test if it is working and if not to find the error.. https: //www.youtube.com/watch?v=jWTjHmuuvJs EDIT: this could be a great tool to make b4x tutorials... Last edited: Sep 11, 2015
Erel said: You need to install the app. But later when you modify the code it doesn't need to be reinstalled (not in all cases). Didn't you notice it in B4i? That you don't need to approve the installation each time you run? Click to expand... oh, i didnot mean that option, i noticed it of course, i only wonder after watching some java tutorials if it could be possible to do simple code without install the app. like i have a list and want to get to the log the item in index 12 but dont want to install now the app only see if code if working or to get a true false, .. also to explain maybe b4x with simple code snippets it would be very good to have such an option, it could be also a different app no need to implement it in b4a/b4i. something where i can put a code and test if it is working and if not to find the error.. https: //www.youtube.com/watch?v=jWTjHmuuvJs EDIT: this could be a great tool to make b4x tutorials...
RandomCoder Well-Known Member Licensed User Longtime User Sep 10, 2015 #29 This would be like the Immediate window in VB6 or the shell in MySQL. It would be a great addition to be able to test simple subs.
This would be like the Immediate window in VB6 or the shell in MySQL. It would be a great addition to be able to test simple subs.
S sorex Expert Licensed User Longtime User Sep 10, 2015 #30 which part of that 3 hours movie are you refering too? I don't have that much time at work to look at all of that
which part of that 3 hours movie are you refering too? I don't have that much time at work to look at all of that
ilan Expert Licensed User Longtime User Sep 10, 2015 #31 it should be only a tool that test simple code that doesnot need libs and all output will be to log..
it should be only a tool that test simple code that doesnot need libs and all output will be to log..
ilan Expert Licensed User Longtime User Sep 10, 2015 #32 sorex said: which part of that 3 hours movie are you refering too? I don't have that much time at work to look at all of that Click to expand... see in the middle how he put codes and test it and get result in log.
sorex said: which part of that 3 hours movie are you refering too? I don't have that much time at work to look at all of that Click to expand... see in the middle how he put codes and test it and get result in log.
S sorex Expert Licensed User Longtime User Sep 10, 2015 #33 I like the idea. eiter a seperate code panel that compiles to a JAR and outputs to the log or use something like in MS (transact)SQL where you select the lines of code and press execute now I have a _test folder with a lot of mini projects just because of small routines I wrote to help the forum users.
I like the idea. eiter a seperate code panel that compiles to a JAR and outputs to the log or use something like in MS (transact)SQL where you select the lines of code and press execute now I have a _test folder with a lot of mini projects just because of small routines I wrote to help the forum users.
ilan Expert Licensed User Longtime User Sep 10, 2015 #34 sorex said: I like the idea. eiter a seperate code panel that compiles to a JAR and outputs to the log or use something like in MS (transact)SQL where you select the lines of code and press execute now I have a _test folder with a lot of mini projects just because of small routines I wrote to help the forum users. Click to expand... exactly. this is what i meant...
sorex said: I like the idea. eiter a seperate code panel that compiles to a JAR and outputs to the log or use something like in MS (transact)SQL where you select the lines of code and press execute now I have a _test folder with a lot of mini projects just because of small routines I wrote to help the forum users. Click to expand... exactly. this is what i meant...
T Troberg Well-Known Member Licensed User Longtime User Sep 10, 2015 #35 sorex said: it seems that from the moment when ELSE is used it forces you to use multiline. this works then Code: Copy If x<=10 Then Log(1):Log(2) Else Log(3):Log(4) End If End Sub Click to expand... I don't remember if B4X has IIf or not. If not, it's very easy to write one yourself: Code: Copy Sub IIf(Condition as boolean, TruePart as object, FalsePart as object) as object If Condition then Return TruePart Else Return FalsePart End If End Sub Then, just call it like this for an inline if: Log(IIf(ErrorString="", "OK", ErrorString)) That call will log the content of ErrorString if there is an error, or "OK" if it is empty (which I assume, in this context, means no error). Very neat, very useful for such things as providing default values or simple ifs (such as placing something at different positions depending on screen orientation).
sorex said: it seems that from the moment when ELSE is used it forces you to use multiline. this works then Code: Copy If x<=10 Then Log(1):Log(2) Else Log(3):Log(4) End If End Sub Click to expand... I don't remember if B4X has IIf or not. If not, it's very easy to write one yourself: Code: Copy Sub IIf(Condition as boolean, TruePart as object, FalsePart as object) as object If Condition then Return TruePart Else Return FalsePart End If End Sub Then, just call it like this for an inline if: Log(IIf(ErrorString="", "OK", ErrorString)) That call will log the content of ErrorString if there is an error, or "OK" if it is empty (which I assume, in this context, means no error). Very neat, very useful for such things as providing default values or simple ifs (such as placing something at different positions depending on screen orientation).
S sorex Expert Licensed User Longtime User Sep 10, 2015 #36 actually the point was to be able to use the : to concatenate command or even end up in a 1 line if then/else statement like other languages allow you to do.
actually the point was to be able to use the : to concatenate command or even end up in a 1 line if then/else statement like other languages allow you to do.
T Troberg Well-Known Member Licensed User Longtime User Sep 10, 2015 #37 Yeah, several commands on one line is useful. My favourite is: Code: Copy Select x Case 0 : Difficulty=5 : StartGame Case 1 : Difficulty=8 : StartGame Case 2 : Difficulty=9 : StartGame Case 3 : Difficulty=11 : StartGame Case 4 : GameWon End Select However, in many cases, the inline if allows you to achieve what you want. Not all cases, but many.
Yeah, several commands on one line is useful. My favourite is: Code: Copy Select x Case 0 : Difficulty=5 : StartGame Case 1 : Difficulty=8 : StartGame Case 2 : Difficulty=9 : StartGame Case 3 : Difficulty=11 : StartGame Case 4 : GameWon End Select However, in many cases, the inline if allows you to achieve what you want. Not all cases, but many.
HotShoe Well-Known Member Licensed User Longtime User Sep 10, 2015 #38 Many languages allow stacking statements on a single line. I personally never use it simply because it makes the code so much harder to read (for me at least) later on. I rarely even use single line IF statements hehe. --- Jem
Many languages allow stacking statements on a single line. I personally never use it simply because it makes the code so much harder to read (for me at least) later on. I rarely even use single line IF statements hehe. --- Jem
T Troberg Well-Known Member Licensed User Longtime User Sep 11, 2015 #39 HotShoe said: Many languages allow stacking statements on a single line. I personally never use it simply because it makes the code so much harder to read (for me at least) later on. I rarely even use single line IF statements hehe. Click to expand... I agree, I seldom use them myself. My excetions are the Select variant above, where the contents of the Case is trivial and similar for each Case, and when I have similar repeating sequences of lines, such as: Code: Copy txtInput1.Visible = True : txtInput1.Text = "" txtInput2.Visible = True : txtInput2.Text = "" txtInput3.Visible = True : txtInput3.Text = "" txtInput4.Visible = True : txtInput4.Text = "" It groups things together, so that the pattern is clearer. I get a clear block of similar lines, and it would be easy to spot a mistake. If I hadn't stacked the statements like this, I would have gotten a zig-zag pattern which hid the "same-ness" of the lines: Code: Copy txtInput1.Visible = True txtInput1.Text = "" txtInput2.Visible = True txtInput2.Text = "" txtInput3.Visible = True txtInput3.Text = "" txtInput4.Visible = True txtInput4.Text = ""
HotShoe said: Many languages allow stacking statements on a single line. I personally never use it simply because it makes the code so much harder to read (for me at least) later on. I rarely even use single line IF statements hehe. Click to expand... I agree, I seldom use them myself. My excetions are the Select variant above, where the contents of the Case is trivial and similar for each Case, and when I have similar repeating sequences of lines, such as: Code: Copy txtInput1.Visible = True : txtInput1.Text = "" txtInput2.Visible = True : txtInput2.Text = "" txtInput3.Visible = True : txtInput3.Text = "" txtInput4.Visible = True : txtInput4.Text = "" It groups things together, so that the pattern is clearer. I get a clear block of similar lines, and it would be easy to spot a mistake. If I hadn't stacked the statements like this, I would have gotten a zig-zag pattern which hid the "same-ness" of the lines: Code: Copy txtInput1.Visible = True txtInput1.Text = "" txtInput2.Visible = True txtInput2.Text = "" txtInput3.Visible = True txtInput3.Text = "" txtInput4.Visible = True txtInput4.Text = ""
ilan Expert Licensed User Longtime User Sep 11, 2015 #40 just wrote this in my new b4i game Code: Copy If finishCD = 210 Then Player_Jump(-Player.Jump_Velocity * 0.33) : If soundon = 1 Then mpjump.Play isn't it simpler like this? ok, this is not working like it should... it handle it like there are 2 different if statements... Last edited: Sep 11, 2015
just wrote this in my new b4i game Code: Copy If finishCD = 210 Then Player_Jump(-Player.Jump_Velocity * 0.33) : If soundon = 1 Then mpjump.Play isn't it simpler like this? ok, this is not working like it should... it handle it like there are 2 different if statements...