VS Code Fix Variable Name Upper/Lower case

jordi79
Member Posts: 280
Hi,
Dynamics BC variable names are not case sensitive.
E.g. you can declare a variable with name of "PurchLine", and you can refer to this variable when coding with "pUrChLiNe".
e.g.
DateRec in snippet above is not in correct case, but VS Code still accepts this. But is there anyway for VS Code to autofix the variable names? so that the case is as per what is declared in the variable?
I know it's probably not important as the code compiles and runs anyway, but my inner OCD is bugging me.
Dynamics BC variable names are not case sensitive.
E.g. you can declare a variable with name of "PurchLine", and you can refer to this variable when coding with "pUrChLiNe".
e.g.
field("Date Filter"; DateFilter) { ApplicationArea = All; Description = 'Specify Date Filter'; trigger OnValidate() var >> DateRec: record "Date"; begin >> daterec.setfilter("Period Start", DateFilter); datefilter := daterec.getfilter("Period Start"); end; }
DateRec in snippet above is not in correct case, but VS Code still accepts this. But is there anyway for VS Code to autofix the variable names? so that the case is as per what is declared in the variable?
I know it's probably not important as the code compiles and runs anyway, but my inner OCD is bugging me.
0
Best Answer
-
There is a VSCode extension that fixes the casing of AL keywords, the "AL Variable Helper", see screenshot. So if you convert some code from C/AL you'll see a lot of SETFILTER and FIND and such, those can be fixed by the extension. It didn't always work properly but that's probably because I wasn't using it right, but it's helpful nonetheless
1
Answers
-
You can put your cursor at the end of the variable name and invoke intellisense, it'll drop down the variable name and replace it. No way that I know of, other than Find/Replace, to do it at scale.
Dirty trick could be to do F2 on the variable name, change it to something else and then back to the proper case. Copy DateRec to clipboard, F2 and change it to 'dummy', F2 and paste DateRec, should be fixed.
To satisfy your OCD, you should develop a habit of never typing in the wrong case. Use IntelliSense. In this function you could type 'dr' and that should dropdown IntelliSense and then you can pick the right variable name.0 -
There is a VSCode extension that fixes the casing of AL keywords, the "AL Variable Helper", see screenshot. So if you convert some code from C/AL you'll see a lot of SETFILTER and FIND and such, those can be fixed by the extension. It didn't always work properly but that's probably because I wasn't using it right, but it's helpful nonetheless
1 -
Thanks a bunch.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions