Share My Creation Device Basic language IDE

agraham

Expert
Licensed User
Longtime User
I can't try it properly as you haven't included either of the actual scripts. However if it works when stepping I would guess it's a timing problem of some sort when trying to start the Script activity before the Main activity is fully resumed. Try starting a Timer in Main.Activity_Resume, disable the Timer in its Tick event and start the Script activity there. Start with a couple of seconds delay and if it works play with smaller delay values.
 

JesseW

Active Member
Licensed User
Longtime User
I tried your timer suggestion, and 1000ms was sufficient on an emulator running 2.2, but 100ms was not. I had already thought of that, and thought the idea was a bad fix rather than a good solid implementation.

But I was able to fix it rather eloquently, though. Instead of activity script falling back to main to do the processing, then finding a way to restart script, I created a third activity, Chain, which has a empty activity_create, and activity_resume has only one statement, activity.finish, then all the processing is done on the way out in activity_pause. This way, activity script comes back up into play naturally, instead of having to find a way to force it or wait for it, and processing resumes naturally. Since activity_resume is called instead of _create when script comes back to focus, I had to call _create from _resume, but it works like a champ. Every time. I'm glad its behind me.

I also added a Run command to compliment Chain, that loads and runs another script without sending an array as Args(), and SavedData() is dimmed back to 0.

Unfortunately, against what you had hinted to in an earlier post, these mods have necessitated modifications as well as additions, so now I have the daunting task of going through my script.bas and comparing it line-by-line with 2.9 script.bas, ensuring the new 2.9 is fully equipped with my changes. I was hoping for a way around this, as to why I mentioned it up front, but the extra work is DEFINITELY worth the outcome.

Andrew, you're the man! Thank you one more time

ps. As soon as I'm done converting script.bas to 2.9, I will start a new thread for B4Script and post the project there.
 

agraham

Expert
Licensed User
Longtime User
You can use your existing 2.8 script.bas with no worries under 2.9. The only difference is the addition of

B4X:
Dim args(3) As String
args(0) = "Fred"
args(1) = "Bill"
args(2) = "Charlie"
Blib.Run(args)
in Activity_Create to test the args array length fix.
 

JesseW

Active Member
Licensed User
Longtime User
Tested. You forgot to tell me to change the ver# >D'Oh!<

Sorry everyone, I don't have the time now to update the help comments in all the new additions and properly post the project file in a new thread. I will soon.
 
Last edited:

JesseW

Active Member
Licensed User
Longtime User
Andrew, I just discovered, after pulling most of my hair out, that the StrRemove function has been actually coded as StRemove. If / when you resolve this, would you leave StRemove intact? Thanks..

Jesse
 

JesseW

Active Member
Licensed User
Longtime User
Andrew, I've found two bugs:

1. if there isn't a blank line at the very end of a script, adding line no's deletes the last line.

2. the ElseIf statement always throws an exception after a previous ElseIf has tested true. In the code below, line 5 will always throw an error.

B4X:
 if false then
  a = 1
elseif true then
  a = 4
elseif false then
  a = 5
elseif true then
  a = 6
endif

ps. nevermind in leaving StRemove intact when you correct it to its proper StrRemove name.

Thanks again for this wonderful tool.
 

agraham

Expert
Licensed User
Longtime User
Version 2.91 now posted fixes the typo in the name of the StrRemove function and the also the ElseIf problem.

You could have fixed the line number "feature" as it is in Basic4android code in Sub AddLineNumbers - but I have done it anyway, though I didn't note it in the versioning comments and can't be bothered to go through packaging and uploading this version again just to correct that.
 

JesseW

Active Member
Licensed User
Longtime User
thanks for the fixes I know I could have fixed the line # thing, but it still would have needed correcting in your version anyway. thanks again..

were any changes made to script.bas?
 

JesseW

Active Member
Licensed User
Longtime User
Andrew, would you consider a mod that would allow the underscore char _ to begin a variable name? ie. Dim _id(0)

thank you again, so much
 

JesseW

Active Member
Licensed User
Longtime User
Andrew, finding some issues in the math functions.

1. the Round throws an illegal argument exception no matter how it is used

2. Int(4.8) returns 4.8 instead of 4

3. all of them seem to choke on a fraction without a leading zero, ie. .5 - is this an android thing?

thank you sir
 

agraham

Expert
Licensed User
Longtime User
Version 2.92 now posted. Round and Int, which suffered in the transition from C# to Java are now fixed and underscore is now accepted as the start of a variable name.

Numeric literals must start with one of the numeric characters 0 to 9 because "." is a keyword used in the syntax for accessing the elements of a structure variable and if present at the beginning of a number will be parsed as the keyword and not as a decimal point.
 

JesseW

Active Member
Licensed User
Longtime User
Thank you very much. I understand the "." keyword. I REALLY like the concept of using the array indices behind the dot! I use it all the time. I continually find myself wanting to use numeric literals instead of variables tho... like array.1 or array.23 - hint... hint... In the meantime I just have a few variables, zero, one, two, etc... and use array.zero

Thanks again
 

JesseW

Active Member
Licensed User
Longtime User
Thanks for the update

But... In the zip file in post 1, BasicLib.jar and .xml are inside instead of BasidLibIDE.jar and .xml. I installed them anyway, and started b4a, and BasicLibIDE ver is still 1.92

If it makes you feel any better, I uploaded the last ver of B4Script without any help files >blush<

Thanks
 

JesseW

Active Member
Licensed User
Longtime User
Andrew, found an anomaly with the For statement: it will always iterate at least once, even when its condition is pre-satisfied and shouldn't iterate at all. Typical Basic behavior dictates a For Next loop can skip iterating altogether if the exit condition exists at the onset. Here is an example

B4X:
item = 0
for n = item - 1 to 0 step -1
  msgbox(n, "")
next
#

although no one would ever need to write a hard coded loop that would never execute, I do have a routine that responds to a touch from a list of items, then looks for a non-zero value in the items above it, but if the first item is touched, as in the example above, it still eiterates when it shouldn't, causing an error because there is no -1 item in the list.

I can work around this, if this behavior is intentional. Just bringing it to your attention.
 

agraham

Expert
Licensed User
Longtime User
By design - yes, but only because I didn't take this possibility into acount. I've checked what Basic4ppc does, which is the reference for the behaviour of this library and it does not iterate in this situation so I'll implement that same behaviour. It's an easy fix which I've done and checked in my C# master version. I'll do the Java library mod later tomorrow.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…