Any solution to having to scroll back up to the top of a program all the time to check variables declared? - variables

I am programming in Pascal (compiling with the Free Pascal IDE) but I imagine the following issue could be in all programming languages, whether you have to declare variables or not.
In Pascal you have to declare your variables before you can use them. They can only be declared at the top of a function/procedure or, in the case of global variables, at top of the main program.
As my program got longer over the past year and more and more variables were declared, I have had to scroll back up all the time to check which variables I have declared in order to use them in a function or main part of the program.
Is there any solution to not have to scroll back up all the time?
Putting variables in a separate unit file and having the file opened next to the main program file is the only thing I can think of, but at this stage I have too many functions and classes to shift everything around that way. Too much rework of the code would have to be done.

In Lazarus, the freeware and excellent IDE for FPC[1], there is a simple way to do this:
Place the mouse over a variable
If the variable has been declared, the IDE will visually mark it
If it is marked, single-clicking the variable will take you straight to where
it is declared.
More generally, when you hover the mouse over a variable, the IDE will change its background color to something like light grey[2], including any other occurrences of it which are on-screen
at the time, so by itself this is sufficient to locate the variable's declaration site if it happens to be on-screen, as it often is if the variable is a local.
[1] I don't know why anyone would use Notepad++ or another IDE for FPC considering
how good Lazarus is.
[2] The top and bottom pixel rows of the changed background color are drawn darker than the others, which makes it look rather like (wearing my spectacles) the variable name is underlined.

Delphi IDE although a paid solution offers free community packages for students and such. i had a great time using it for my college assignments. its more user friendly as I had a lot of trouble navigating Lazarus. on delph I there is a side-panel that shows you all your stated variables,constants,uses,procedures and more.

Related

Is there a way to make IDEs (IntelliJ, PyCharm, VS Code) have fewer popups but still have completion?

I learned to program 30 years ago with Emacs. I'm starting to learn moderns IDEs such as "IntelliJ IDEA", "PyCharm", and "VS Code".
It's hard to adjust to how visually "busy" they are, with constant pop-up menus appearing every character I type.
Of course I want to be able to get suggestions for completion or parameter hints or other popups when necessary. I just don't want them to appear by default.
Some people are asking why popups are annoying. The main problem is that popups cover code above or below where I'm typing.
Emacs has completion. But it doesn't need a popup. For instance, dynamic completion works just fine 90% of the time, even though it's not smart enough to parse syntax or look up function and method definitions.
So I'd like to know if there are settings in JetBrains or VS Code IDE's that would help.
I'm aware of two kinds of popups.
(1) An offer to complete my typing, which appears below.
(2) Annotation of argument names and definitions, which appears above.
There may be other popups as well.
I'm aware that a popup can be dismissed with ESC. But often they just come back the moment you type another character.
What would be great is if the popup would not appear by default, but I could cause it to appear with a single keystroke. Or I could dismiss it and it would stay dismissed.
For PyCharm You can also try writing in "Disctraction Free Mode"
View -> Enter Distraction Free Mode
Which should give you a little screen of calm which will feel a lot more like emacs to you.
It's possible to adjust the behaviour via "Settings".
In IntelliJ IDEA, goto Menu File --> Settings ... , then navigate to Editor --> General --> Code Completion , or type something in the search field (upper left).
Perhaps you find more settings when you browse through Settings dialog.
To be honest, I didn't make a lot of tests with these settings, because I find the helper popups very useful.
Another option to get rid of some "noise" is to adjust settings for displaying parameter names in the code editor.
I switched this off completely.
Go to Settings --> Editor --> General --> Appearance
The new IDEs are really busy looking for libraries, checking/auto closing balanced parentheses, indenting, surrounding methods/functions/procedures/classes as you type. Sometimes I feel the same, but these IDEs are not plain text editors anymore. Every key stroke triggers something which can be time consuming. When the project gets larger and when it has lots of libraries, it can get even slower. Some IDEs have options to turn some of these options off. Every feature turned off will have some positive effect on responsiveness to some degree
But I think, instead of turning these features off, the best way to have these features on a responsive modern IDE is to use a computer with a fast cpu, an ssd drive and sufficient memory.

Intellij: Highlight current block of code

I was wondering if it is possible to highlight the block of code you are working on in Intellij Idea.
There was a similar question here: Is there a way to highlight the currently active code block in Visual Studio 2010? .
So what I mean is that if you have clicked into e.g. a method or a while loop... ,the background of the whole block becomes a bit lighter or whatever.
There's already one such feature, but it's more subtle, in the form of a vertical line inside the left gutter... I can't recall whether it's enabled by default or not, but you can activate it by File -> Settings -> Editor -> General, scroll to the Highlight on Caret Movement section (about half of the page).
I looked around for a while but I have not yet found a way to change its appearance to match your description, although I personally prefer this less intrusive highlight than having all the background changed.
P.S. Not sure this is relevant or useful to you, but there was a plugin I tried a while ago called CodeGlance which offered a scrollable-map of the class:
I don't know when this feature was implemented. As of 2021, if you double click anywhere in the scope ( but not on text ), Intellij selects the current block of code ( text within two curly braces ).

Modifying window style by editing binary?

CyLog’s WildRename is a good program for performing batch-renames on files. The problem with it is that while the main window is resizable, it does not have the maximize box which makes it a little frustrating to size and use. Moreover, they have not made any updates in a long time, so the program is essentially discontinued.
I ran WildRename and used WinSpy++ to modify the style of its window to manually include the WS_MINIMIZEBOX style and bam!, it was now functioning as expected.
The question now is how to make this permanent.
My first instinct was to fire up ResHacker, but the problem is that the style that needs to be modified is that of the main window of a non-dialog application, so ResHacker has no way of doing this.
The next thing I tried was to open it in a hex-editor, to find the address(es) of the string corresponding to the titlebar. I then opened the file in W32Dasm and located the address of the code that references the address of the titlebar string. I did all this in an attempt to find the location of where the main dialog is created so that I can modify the style passed to CreateWindow(). Unfortunately, I cannot find a call to CreateWindow anywhere near the reference to the titelbar string and none of the calls to CreateWindowEx that I can find seem to be (obviously) the ones used to create the main window.
Is there an easy/automated way of modifying the style of the main window (assuming a non-dialog application)?
You could use a debugger like OllyDBG to dump the exe memory after the edit with WinSpy++, then use that exe or compare the files to see where the change is if you want to see what you've missed
There has to be a call to CreateWindow/Ex(), especially if it not a dialog from a resource. You just need to look harder. I would use IDA instead of WinDasm. It will decompile the assembly into more understandable code, and it has a built-in debugger. You can put a breakpoint on the title string and see in real-time which code actually touches it, and then follow it back to the accessing code.

Set breakpoint in VBA code programmatically

I have a very large piece of code written in VBA (>50,000 lines - numerous modules). There is one array of interest to me, and I'd like to find all the conditions under which the value of any element of this array changes. The values can change in any module. Running the script line by line is not the most efficient option due to the size of the code.
I am looking for better ways to solve this problem. Two ways that come to my mind is to programmatically set a breakpoint (which I am not sure if can be done) or programmatically insert an if-block after each assignment that somehow alerts me that the value has changed. (not preferred).
So my question boils down to:
Is it possible to programmatically set breakpoints in VBA code?
If the answer to the above question is No, what is an efficient way to solve this problem?
UPDATE:
Thanks for the comments/replies. As I had implied, I am interested in the least amount of modification to the current code (i.e. inserting if-blocks, etc) and most interested in the break-point idea. I'd like to know if it's doable.
Use the keyword STOP to break te code if a certain condition is true.
There are Two Ways to do that:
Use Stop Key word. Example as given below, set a break point at Stop
if (x = 21 ) Then
Stop
End If
Using Add Watch
Go to Debug -> Select Add Watch
NB:I know this is an old topic but this could help others.
You could use Watches:
Right click on the variables you wish to monitor -> Add Watch...
In Watch Type: 'Break when value changes'
While you run your code, you can check the status of your Watches thanks to the Watch Window (accessible from the 'View' menu)
in the hope someone can benefit from this :
In such situations regardless of the programming language used - writing a few lines of code either in Perl, AWK or even shell scripts can solve the problem :
search for a regular expression containing the array name (ignoring case).
Once you export all modules and classes in the Workbook(s) into a given directory - the scripts can search those for you.

Auto-Completion in Unix VI editor

After using graphical IDE's like Visual Studio, I'm used to pressing CTRL+Space to auto-complete a variable or function name. Now, I know such a thing isn't completely possible in VI, but I heard there was a list of commands that could be mapped that allowed automatic completion of variables and functions in the current file opened. Does anyone know what this sequence is?
Just noticed that you said "vi"; I hope that "vim" is also okay.
It depends on the particular programming language, but in general, the magic word is Omnicomplete.
Put this into .vimrc:
filetype plugin on
set ofu=syntaxcomplete#Complete
Press Ctrl+N or Ctrl+P to trigger the completion. This is insanely customizable; you might like the tips here that make it work more like other IDEs.