Re: missing block

[email protected] (ToddAndMargo via perl6-users)
Newsgroups perl.perl6.users
Message-ID <[email protected]>
On 3/3/24 04:25, Elizabeth Mattijsen wrote:
>> On 3 Mar 2024, at 05:12, ToddAndMargo via perl6-users <[email protected]> wrote:
>> $ raku -I./ -c CobianWrapper.pl6
>> Missing block
>> at /home/CDs/Windows/NtUtil/CobianWrapper.pl6:1000
>>
>> 1000 is the last line in my code.  I presume by
>> "block" they mean something like "]" or "}"
>>
>> Do I really have to read 1000 lines of code to find my screw
>> up?   Anyone have a tip on how to find it quicker?
> 
> I use `vim` as the editor.
> 
> In `vim` if I have this situation, then I put the cursor on the first opening {  and press `%`.  This brings me to the corresponding closing }.
> 
> If the associated closing curly does not match your expectations, then you're nearing the source of the problem.
> 
> I assume other code editor have a similar `%` functionality.

Hi Elizabeth,

I learned vi about 35 years ago.  I still use
it occasionally.  I will have to try out that
% feature out.  Thank you!   (I just made
a quick "Keeper" out of it.)

I use Geany for programming a lot.  Primarily
as is works well with ssh X11 over poor internet
connections.

Geany has a thing were you park on a bracket of
some type and it will turn the other end blue.
So, something similar to vi (an alias to vim).

To work around the missing block issue, I always
place both sides of a {} before writing inside
them.  It does not always work if I ramble too much.

And it is the tip off that I have rambled on too
much and need to put some things into subs.
Considering I am a YUGE proponent of "top down"
programming, I really should know better.

This is what became of your help:

sub SortList( @List, Str $Msg, Bool $NoDebug )  {
    my @Sorted = Empty;
    @Sorted = @List.sort(*.split(/\d+/, :kv).map({ (try .Numeric) // 
$_}).List);

    if  %Options< Debug >  && not $NoDebug  {
       print "$Msg";
       for @Sorted.kv -> $Index, $Element  {
           print "   Element [$Index]  <$Element>\n";
       }
    }
    return @Sorted;
}


sub ListParentDir( Str $Msg, Bool $NoDebug = False  )  {
    # list and sort %Options<ParentDir>
    my @List = Empty;
    for dir( %Options<ParentDir> ) { push @List, $_.Str };
    @List = SortList @List, $Msg, $NoDebug;
    return @List;
}


It really cut down on the clutter and made missing
bracket much easier to find.

Oh and you helped me fix a bug in my program that I
had though was a Windows error that had been going
on for years.  Thank you again!

-T
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.