My final test program. This ensures you can multiple commands on the init line
#CHIP 18F27Q84, 64#OPTION Explicit//'==============================================================================//' TC01 - Single variable, no initializer//'==============================================================================//DimTemperatureReadingAsByte//' Expected: no synthetic assignment line generated (no "=" present)//'==============================================================================//' TC02 - Single variable, with initializer//'==============================================================================DimTemperatureReadingAsByte=72//' Expected DataSource after strip: Dim TemperatureReading As Byte//' Expected generated line: TemperatureReading = 72//'==============================================================================//' TC03 - Multiple variables, no initializer//'==============================================================================DimRedChannel,GreenChannel,BlueChannelAsByte//' Expected: no synthetic assignment line generated (no "=" present)//'==============================================================================//' TC04 - Multiple variables, shared initializer (core regression case)//'==============================================================================NOP:DimRedChannel,GreenChannel,BlueChannelAsword=512:ASMNOP//' Expected DataSource after strip: Dim RedChannel, GreenChannel, BlueChannel As Byte//' Expected generated lines://' RedChannel = 512//' GreenChannel = 512//' BlueChannel = 512//'==============================================================================//' TC05 - Location only, no type, no initializer//'==============================================================================DimWatchdogFlag1At0x500//' Expected: no synthetic assignment line generated (no "=" present)//'==============================================================================//' TC06 - Type and location, no initializer//'==============================================================================DimWatchdogFlag2AsByteAt0x501//' Expected: no synthetic assignment line generated (no "=" present)//'==============================================================================//' TC07 - Type, location, and initializer together//'==============================================================================DimWatchdogFlag3AsByteAt0x502=1//' Expected DataSource after strip: Dim WatchdogFlag As Byte At $100//' Expected generated line: WatchdogFlag = 1//'==============================================================================//' TC09 - Array declaration (GCBASIC does NOT support an inline array//' initializer -- arrays are declared, then loaded on a separate line)//'==============================================================================DimPixelBuffer(10)PixelBuffer=1,2,3,4,5,6,7,8,9,10//' Expected: the Dim line generates no synthetic assignment line.//' The "PixelBuffer = ..." line does not start with "Dim ", so it never//' enters the Dim parser at all -- it'shandledbyordinaryassignment//' parsing elsewhere in the preprocessor.//'==============================================================================//' TC10 - Metadata marker present after the initializer//' (";?F...L...S...I...?" is preprocessor-internal line metadata, appended//' automatically -- shown here to confirm it'scorrectlyseparatedfromthe//' initializer value rather than swallowed into it)//'==============================================================================DimLoopCounterAsByte=0//' Expected DataSource after strip: Dim LoopCounter As Byte //' Expected generated line: LoopCounter = 0//'==============================================================================//' TC11 - Initializer value itself contains "=" (string literal)//'==============================================================================//DimStatusMessageAsString="Code=Ready"//' Expected DataSource after strip: Dim StatusMessage As String//' Expected generated line: StatusMessage = "Code=Ready"//'==============================================================================//' TC12 - Negative numeric initializer//'==============================================================================DimTemperatureOffsetAsInteger=-5//' Expected DataSource after strip: Dim TemperatureOffset As Integer//' Expected generated line: TemperatureOffset = -5//'==============================================================================//' TC13 - Variable name containing "As"/"At" as a substring (not a keyword)//'==============================================================================DimDataTableIndexAsByte=0//' Expected DataSource after strip: Dim DataTableIndex As Byte//' Expected generated line: DataTableIndex = 0
❤️
1
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Praise goes to Angel for initial implementation and to me for a tidy up.
I did try using AI for this change, but, AI went a tad crazy by increasing the scope of the change. So, I wrote 'by hand' the update to parse the new construct and handle the change.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Dim Variable1, Variable2, Variable3 as Byte = 0
Is there a reason why this is not possible? Bad idea?
What does the error message mean?
Error: Multiple bits can only be set to a fixed value, not a variable
The help says this:
Dim variable[, variable2 [, variable3]] [As type] [At location] [= initialvalue]
https://gcbasic.sourceforge.io/help/_dim.html
Is that not what I am trying to do?
Last edit: Roger Jönsson 2026-07-06
Build 1607 ( when I get to building it ) will support
// '==============================================================================
// ' TC04 - Multiple variables, shared initializer (core regression case)
// '==============================================================================
Dim RedChannel, GreenChannel, BlueChannel As word = 512
// ' Expected DataSource after strip: Dim RedChannel, GreenChannel, BlueChannel As Byte
// ' Expected generated lines:
// ' RedChannel = 512
// ' GreenChannel = 512
// ' BlueChannel = 512
So, the method to set multiple variables was not implemented by Angel. I have added in 1607.
Good to have that working before and in the next general release!
Here you go.
https://1drv.ms/u/c/2f87ffe77f3dbec7/IQCo0aCT9MXhSqUK9PDDG68_Ad9ZcIaLUbD5CuvX2C25HOs?e=MUCFEY
My final test program. This ensures you can multiple commands on the init line
Thanks! Declaring several variables on one line with the same value, is SO nice!
Praise goes to Angel for initial implementation and to me for a tidy up.
I did try using AI for this change, but, AI went a tad crazy by increasing the scope of the change. So, I wrote 'by hand' the update to parse the new construct and handle the change.
In todays test program, ten lines of DIM and values became one easy to read and manage line!
Thank you both!