What's the best method find out which '}' is for their respective '{' symbol when they are merged together? - Forum

Forum Navigation
You need to log in to create posts and topics.

What's the best method find out which '}' is for their respective '{' symbol when they are merged together?

Basically I want to know what method and technique a programming language use to find out which } (endif) is for which { (if) when they are stacked inside each other like this:

If
If
If

Endif
Endif
Endif

I've thought about counting them but I was wondering if there is a better way (formula, technique, method) to do it.

Hello,

Since neoscript does not use  () or [] or {} te best method is to use code indentation.

If

  If

    If

    Endif
  Endif
Endif

You may also use extensive commenting to comment for what a endif is for.

Together with a good Editor this will let you keep control over bigger sources.

Regards

Hans-Peter

 

SmnMhmdy has reacted to this post.
SmnMhmdy

Hi!

Any EndIf always refers to the closest unclosed If.

In the same way, Else always refers to the closest unclosed If.

Uploaded files:
  • You need to login to have access to uploads.
SmnMhmdy has reacted to this post.
SmnMhmdy

When writing code (in my opinion) it is better to avoid (if possible) multiple "If - EndIf" attachments, and use "IfEx - EndIf"

Regards

Andrei (as3856)

SmnMhmdy has reacted to this post.
SmnMhmdy

Thank you @hpw @vadim @as3856 I think I actually explained it wrong. I'm working on a scripting system that needs to process If, for, while, ... arguments. The rough syntax is looking like this:

If {

If{

If{

Command

}

}

}

So I'm looking for a technique to find which '}' symbol represents the end of its respective '{' symbol and therefore not executing the commands inside of them by skipping to the specific line which holds the right '}' symbol if the argument is not valid.

You can count the number of opening brackets coming one after another. Therefore, each subsequent closing bracket will correspond to a known opening number. For example, if three opening brackets are found, then the fourth (closing) will correspond to the third (opening). The fifth bracket (closing) will correspond to the second (opening). The sixth (closing) will correspond to the first (opening).

You can also consider consecutive IF and IFEx.

SmnMhmdy has reacted to this post.
SmnMhmdy

Hello,

I do not get the Point? A Scripting System inside the Scripting System?

There are several plugins offering alternative Scripting languages yet.

Regards

Hans-Peter

SmnMhmdy has reacted to this post.
SmnMhmdy

@vadim Thanks I guess there's no other way than counting them.

@hpw I'm doing this mostly for educational purposes and personal and/or in-house usage. On the same note, Is there any plugin for c/c++ programming inside nb? or is it possible to write an nb plugin using those languages?

See also the hpwControl (Hans-Peter Wickern) plugin. Maybe he will help you.

Yes, somewhere on this site there is SDK for writing plugins. Senior colleagues will direct you. You can write plugins and functions in different languages.

Some useful information can be gleaned from my article (Google will help translate it into the desired language):
https://habr.com/ru/post/451346/

SmnMhmdy has reacted to this post.
SmnMhmdy

Hello,

In the download section are some SDK Versions:

The most used SDK is for delphi. There are 2 Downloads. One for delphi 10 and the other for all older versions.

(Delphi was used to write VisualNeo software)

And there is a version for C#.

There were other more experimental Versions for powerbasic, purebasic, freepascal.

In theory a experienced C-Programmer should be able to write a plugin for his own.

It is a quite clear Interface spec with function-pointers and PChar parameter-strings.

Regards

Hans-Peter

 

 

 

Vadim and SmnMhmdy have reacted to this post.
VadimSmnMhmdy

Thanks for the clear explanation @vadim @hpw !

I'll definitely look into the mentioned documents.

And btw counting the open brackets and subtracting the number from the closed brackets seems to have worked.