cancel
Showing results for 
Search instead for 
Did you mean: 

Allow trailing semicolons on last item in a code block

Currently in block of code (such as in an OnSelect property), while semicolons (in at least US English) are used to separate functions/actions, the LAST one cannot have a semicolon without PowerApps complaining (often confusingly).   


From a coding perspective, this is very annoying and wastes a lot of the time, especially when one may add or remove functions from a code block, especially when nested in If() and other statements.  For example in the below:

 

 

 

Set( VarA, 123 );
Set( VarB, 456 );
ClearCollect( MyCollection, 
     {     A: 1, B: 2, C: 3    },
     {     A: 4, B: 5, C: 6   }
);
Set( VarC, 789 )

 

The last statement must NOT have a semicolon at the end.  However, if I remove this, then I'll also need to remove the semicolon after the end of the ClearCollect().  

 

But then if I again add another statement at the end again - I'll not only have to readd the semicolon to the end of the ClearCollect(), but will also have to make sure not to have one at the end of the last statement.

 

While this makes sense from a "list" perspective (where you only use a comma for instance between items), from a coding perspective this is annoying, wastes time, and goes against what most other languages allow.  In some languages everything must end in a semicolon whether last one or not.  But virtually all at least ALLOW the final statement to have a semicolon (Yes, I can think of a few other exceptions).  

 

This just simply wastes time of the user.  Please change the parser to allow an OPTIONAL semicolon at the end of statements at the end of a code block (including code blocks within other calls, like If(), etc).

 

Status: Completed
Comments
Level: Powered On

Definitely agree with you, that would help in making the formula system feel better and less aggravating to troubleshoot.

 

Even just an error message that directly indicates that the trailing semicolon is the problem would make a big difference. As is now, it just states that an operand is expected, but that's not even very clear as that doesn't state that a function is missing but simply a value (eg. 1, "Hello", True); that doesn't do a good job of indicating that the problem lies with the trailing semicolon as opposed to within a function.

Level 8

I've wasted a LOT of time due to lack of ability for a trailing semicolon.

 

Biggest issue is when you comment out large lines of code for testing purposes.  (I do thank Microsoft for FINALLY adding proper commenting ability).  This has made a BIG difference positively (just the ability to disable code is HUGE).  

 

So back to the semicolon - not allowing for a trailing semicolon can really be a pain when commenting out large lines of code.  You need to remember to remove the semi in some cases, adn then later add it back in.

 

And since PowerApps doesn't always do a great job highlighting the errors (often it marks in red all over the place on a minor error) - I've spent a couple of hours lately all due to a semicolon issue...  (now that I know this, its the first thing I check now).  

 

 

Level: Powered On

This is an easy parser change to make developing apps much easier while reducing frustration. Great thought.

Level 8

FYI - in the meantime, here is a short workaround that i use during development:

 

So at the bottom of each page with code (especially those with more than one line):

 

If(false, Set( gDummy, 0 ) )

So by doing this as the last statement in the code block (which would not have a ";" at the end), I don't have to worry about things in between.  

 

And the code above shouldn't really do anything (hence the If(false)) including the setting of the variable.  I'm basically just trying to do a "NOOP" here, perhaps there is something shorter to do so.  :-)    

 

That said - this doesn't resolve the annoyances of inner code blocks (nested inside other function calls) - only for the whole page.

 

But it has 

PowerApps Staff
Status changed to: Under Review

Updating status and adding @GregLi and @LanceDelano

Level: Powered On

Instead of using a If statement you could just add false at the end a few lines down. 


//Code........; false
Level 8

@Borton - Excellent point...  I may do this instead for the time being.

PowerApps Staff
Status changed to: Completed
Level 8

Great to see this one delivered!