Bug? Problem with b4A editor - perfect example

aedwall

Active Member
Licensed User
Longtime User
This editor makes me so mad sometimes. Here is a perfect example. I was running in DEBUG mode and then had to make a few changes in my code. The editor decided to delete and swap various characters all around and make it next to impossible for me to straighten things out. Not easy to tell what changed. Luckily, I had done a file save so I could do a file compare. The editor has some kind of serious problem, at random times.
 

Attachments

  • Perfect example.jpg
    Perfect example.jpg
    383.3 KB · Views: 180

stevel05

Expert
Licensed User
Longtime User
2500+ lines is a lot for a single module, I would suggest splitting it (just my observation).
 
Last edited:

aedwall

Active Member
Licensed User
Longtime User
When the editor changes the syntax of what I have written so that the code no longer compiles, it does not matter what the definitions are or anything else. The editor has changed things it shouldn't have touched. That is a bug.
 

Sandman

Expert
Licensed User
Longtime User
This sounds very strange. If this was a known problem, you would see lots of people complain loudly about it. But this is the first time ever I've heard about this issue, so chances are that the problem is with your installation.

As for what the problem could be, I couldn't tell you. I can't really help with that beyond a hand-wavy "try reinstalling B4A from scratch, and make sure to carefully follow all instructions".
 

peacemaker

Expert
Licensed User
Longtime User
Neural networking virus fixing "errors" :)
Skynet is near
 

AnandGupta

Expert
Licensed User
Longtime User
This editor makes me so mad sometimes. Here is a perfect example. I was running in DEBUG mode and then had to make a few changes in my code. The editor decided to delete and swap various characters all around and make it next to impossible for me to straighten things out. Not easy to tell what changed. Luckily, I had done a file save so I could do a file compare. The editor has some kind of serious problem, at random times.
My guess, as I develop in variety of ide (B4X, B4J, VS, SciTE etc.), text editor (UE, Vs Code, Notepad++, even Notepad), the B4A ide is trying to check for syntax coloring, errors, auto fill code etc. in this huge code lines, and sometimes its memory allocation gets muddled up resulting in the bug.

Please note that B4A ide is developed in C++ (AFAIK) and can be very tricky in memory handling for huge memory allocation if required.

Solution, as @stevel05 suggested, keep lines smaller in each module/file.

I too have faced such problem in compiling my Xbase++ codes if one prg become very very big (in number of lines), and I break it in different prgs to solve it.
 

aedwall

Active Member
Licensed User
Longtime User
I think it is better to stop debugging and then only edit the code.
Yes. I have considered going this route. But that is inconvenient. And editors should just work properly. All my other IDE's work as expected. Perhaps I should try and turn off all code-checking syntax (if b4X even has that ability). Thank you all for your ideas.

>> 2500+ lines is a lot for a single module,

That is not a lot, IMO. I have lots more lines than that using VB or PhpED. In b4X, modules are a pain to work with, having to reference various routines in each one individually because b4X apparently isn't smart enough to be able to find things like other IDE's I have (VB 5/6 and PhpED).

>> This sounds very strange. If this was a known problem, you would see lots of people complain loudly about it.

I agree. Why am I afflicted and others aren't? I do not yet know.

>> so chances are that the problem is with your installation.

I made sure I followed the steps very carefully when I installed v13.10. The installation apparently went off without a hitch as I saw no problems and got no error messages, etc. And programs compiled and ran successfully.
 

aeric

Expert
Licensed User
Longtime User
I understand that without a consistent reproduction of the bug, it is difficult to report this bug to Erel.

It could just happen randomly.

I also experienced weird code change before but I can't collect any proof.

It may due to many possibilities.

I suspected the auto save or backup features.
It may because of the debugging process keep another copy of memory of the compiled machine code.
It may comes from a bug from the C# WPF tool use to build the IDE.
I only can guess.

It can be very complicated as we are not expert.
 

Sandman

Expert
Licensed User
Longtime User
In b4X, modules are a pain to work with, having to reference various routines in each one individually because b4X apparently isn't smart enough to be able to find things like other IDE's I have (VB 5/6 and PhpED).
Write a Wish. Make sure to explain with details and, if possible, screenshots. If you can make a good case for improving the developer experience, there's a good chance it will be implemented at some point.
 

aedwall

Active Member
Licensed User
Longtime User
Write a Wish. Make sure to explain with details and, if possible, screenshots. If you can make a good case for improving the developer experience, there's a good chance it will be implemented at some point.
I am used to VB 5/6. Modules were automatically recognized and I didn't have to put "modulename." in front of sub-routines I call between modules. That's "stupid" to have to do that. I also don't have problems with Global variables. They are global and I don't have to set them as global in more than one place. b4X, even when I put the same variables name in two different "Process_Globals" subs, I still don't see some variables as global in my module. Yes, it's me at fault, but I don't have these issues with VB. So if they can do that, why can't b4X?
 

aeric

Expert
Licensed User
Longtime User
I am used to VB 5/6. Modules were automatically recognized and I didn't have to put "modulename." in front of sub-routines I call between modules. That's "stupid" to have to do that. I also don't have problems with Global variables. They are global and I don't have to set them as global in more than one place. b4X, even when I put the same variables name in two different "Process_Globals" subs, I still don't see some variables as global in my module. Yes, it's me at fault, but I don't have these issues with VB. So if they can do that, why can't b4X?
I use to love VB6 too but what you described above is what made VB6 or prior version lacking in Object Oriented Programming. It was suitable in small projects. When programming becoming more and more complex, it need to be evolve.
 

aedwall

Active Member
Licensed User
Longtime User
I use to love VB6 too but what you described above is what made VB6 or prior version lacking in Object Oriented Programming. It was suitable in small projects. When programming becoming more and more complex, it need to be evolve.
Well, all I know is that VB5 and 6 worked fine to make a .exe file that was 35 MB in size. I didn't need OOP or anything "fancy". The project had dozens and dozens of forms and tons of modules. It just worked. Sometimes "simpler" is better. But I am a dinosaur now and I don't understand why we need all these new languages, etc. Seems like every "dog" that comes along has to pee on the same fire hydrant to try and leave their mark or brand. Yet has any of that helped the fire hydrant or make it better? Just frustration speaking.
 

aeric

Expert
Licensed User
Longtime User
Well, all I know is that VB5 and 6 worked fine to make a .exe file that was 35 MB in size. I didn't need OOP or anything "fancy". The project had dozens and dozens of forms and tons of modules. It just worked. Sometimes "simpler" is better. But I am a dinosaur now and I don't understand why we need all these new languages, etc. Seems like every "dog" that comes along has to pee on the same fire hydrant to try and leave their mark or brand. Yet has any of that helped the fire hydrant or make it better? Just frustration speaking.
My short answer is VB5/6 was design to produce exe for old system (16/32 bit). That was windows 3.1 or 95 UI that time. There was no touchscreen, no transparency or 3D UI, not so much security vulnerability, not so much standards, etc.
 

Cableguy

Expert
Licensed User
Longtime User
I am used to VB 5/6. Modules were automatically recognized and I didn't have to put "modulename." in front of sub-routines I call between modules. That's "stupid" to have to do that.
It's stupid to think that, having multiple code modules that have a common named sub, like "initialize", or "calculate", the IDE would know which module YOU are targeting with your code...
Is like telling a cab driver "take me to the restaurant" and expect him to know which one you fancy

Also, take a look at the discussion here:
You will see that there's some interesting info and considerations in there.
 

aedwall

Active Member
Licensed User
Longtime User
I have tried to start a new project using b4XPages and taking some of my code and putting it into a code module ("Module1.bas). But I am having trouble with the Global variables not being "passed" or "recognized" between the "Module1.bas" code and the code in the ".b4A" main file. I know there are "Process_Globals" subs in each file. But where do my global defines go? Which file? I also see that sometimes there is a "Starter.bas" file in a project. Perhaps my global definitions should go in there. Can anyone please tell me how to make this work, in a simple presentation? Thank you. If I can't get the global variables to work, then there is no good reason to try and deal with smaller and multiple modules, and I am then stuck.
 

aeric

Expert
Licensed User
Longtime User
I have tried to start a new project using b4XPages and taking some of my code and putting it into a code module ("Module1.bas). But I am having trouble with the Global variables not being "passed" or "recognized" between the "Module1.bas" code and the code in the ".b4A" main file. I know there are "Process_Globals" subs in each file. But where do my global defines go? Which file? I also see that sometimes there is a "Starter.bas" file in a project. Perhaps my global definitions should go in there. Can anyone please tell me how to make this work, in a simple presentation? Thank you. If I can't get the global variables to work, then there is no good reason to try and deal with smaller and multiple modules, and I am then stuck.
If you have new question, please start in question forum.

In my case, I prefer to use Main module to declare my global variables.
You can also declare global variables in any B4X pages including B4XMainPage when needed.
 

Cableguy

Expert
Licensed User
Longtime User
I have tried to start a new project using b4XPages and taking some of my code and putting it into a code module ("Module1.bas). But I am having trouble with the Global variables not being "passed" or "recognized" between the "Module1.bas" code and the code in the ".b4A" main file. I know there are "Process_Globals" subs in each file. But where do my global defines go? Which file? I also see that sometimes there is a "Starter.bas" file in a project. Perhaps my global definitions should go in there. Can anyone please tell me how to make this work, in a simple presentation? Thank you. If I can't get the global variables to work, then there is no good reason to try and deal with smaller and multiple modules, and I am then stuck.
B4X:
Sub Process_Globals
    'These are Project Globals, "known" by the whole project'
    'Only "Main" has these type of globals in B4Pages
    'In classic Activities, each activity has a Process Global sub'
    'Not all types can be process globals'
    Public ActionBarHomeClicked As Boolean
End Sub

Sub Globals
'These are Module Globals, known only throughout the Module they are declared on
End Sub

The Starter.bas is a "service" that was introduced with B4Pages to ease the entry point specially when coming From Background to foreground (ie: the user sennds your app to background to consult an sms and then comes again into your app)
In the Activities framework, yhe app would be killed by the OS after some time, or when the OS needed the space... The starter service tries to keep the app alive, even if it's in background for long.

You should consult @klaus booklets about B4X, they are accessible from his signature
 
Last edited:

aedwall

Active Member
Licensed User
Longtime User
If you have new question, please start in question forum.

In my case, I prefer to use Main module to declare my global variables.
You can also declare global variables in any B4X pages including B4XMainPage when needed.
Doesn't work. I copied this to "Process_Globals" in the Main module and I cannot compile:

Public swe1 As SwissEph

Error description: Undeclared variable 'swe1' is used before it was assigned any value.
Error occurred on line: 60 (B4XMainPage)
swe1.swe_set_ephe_path(File.DirInternal)
 

Cableguy

Expert
Licensed User
Longtime User
what is SwissEph? if its a lib, you forgot to initialize it, no?
 
Top