Page 2 of 2 FirstFirst 12
Results 11 to 15 of 15

Thread: skip several lines of unnecessary code in thinBASIC

Share/Bookmark
  1. #11
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    6,760
    Blog Entries
    3
    Rep Power
    689
    Edcronos,

    for case like the one you demonstrated I would recommend to go more highlevel by adopting use of state machine engine for your problem.
    It is a common practice in the automation industry.

    It would be worth some time to research and develop a state machine engine - sure doable in ThinBASIC!
    For more read: https://en.wikipedia.org/wiki/Finite-state_machine


    Petr
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 7 64bit - Intel Core 2 Duo T6600 @ 2.2GHz - 4 GB RAM - NVIDIA GeForce G210M 512MB
    Windows 8 64bit - Intel Core i5-3350P @ 3.1GHz - 8 GB RAM - NVIDIA GeForce GT640 3GB

  2. #12
    Then you are wanting someone who only knows how to use "if then else, for next, variables and jumps" to do what you want, design a rocket

    To tell you the truth, I'm not calling goto anymore.
    Even without it, and even more complex, I could do things

    My discouragement now, is about the lack of a minimum standard, and the lack of portability of the codes among the many basics created there

    The strength of the other languages ​​is not about the ability of the syntax but rather about the standard, basically only if you change ide and if you add optional functions

    Like, C ++ that has a basic syntax and simple functions, but if you add capability and functions through #include

    If a simple function that only has some variables, a "for" loop, a few if's does not work from one basic to another, what about more complex implementations?

    What destroys language is not goto and gosub, it is not the ease of learning
    It is rather the lack of firm foundations,
    The engineers, instead of making small reforms, are knocking down what has ready and built everything again,
    If the structure of the house is weak, have to play the furniture and everything else that was built in the house outside why not fit in another

    aí voce está querendo que alguem que só sabe usar " if then else, for next, variaveis e saltos" para fazer o que quer , projete um foguete

    para falar a verdade nem estou mais ligando para o goto
    mesmo sem ele , e mesmo sobre uma maior complexidade, eu conseguiria fazer as coisas

    meu desanimo agora, é sobre a falta de um padrão minimo, e a falta de portabilidade dos codigos entre os tantos basics criados por aí

    a força das outras linguagens não é sobre capacidade da sintaxe e sim sobre o padrão, basicamente só se troca de ide e se adiciona funções opcionais

    como, o C++ que tem um sintaxe basica e funções simples, mas se adiciona capacidade e funções através do #include

    se uma simples função que só tem algumas variaveis, um laço "for" , alguns poucos if´s não funciona de um basic para outro, oque se pode falar de implementações mais complexas?

    o que destrói a linguagem não é o goto e o gosub, não é a facilidade de aprendizagem
    é sim a falta de alicerces firmes ,
    os engenheiros, em vez de faz de pequenas reformas, ficam derrubando o que tem pronto e construido tudo novamente,
    se a estrutura da casa se mostra fraca, tem que jogar os moveis e tudo mais que se construiu na casa fora por que não cabe em outra

  3. #13
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    6,760
    Blog Entries
    3
    Rep Power
    689
    I get your point, Edcronos. And believe me or not, this fact was part of my motivation to start working on ThinBASIC interpreter.
    I loved PowerBASIC at the time, and there was no other BASIC like that. Frustrating!

    So... I feel your pain.

    To be fair - C++ code portability is also discutable, I am afraid. Just reading through C++ Primer, Fifth Edition, you will find many notes regarding oddities even at the most basic level - the data types.

    There is standard of C++, but again, there are no complete implementations. Just look at what Microsoft says about his C++ compiler:
    https://blogs.msdn.microsoft.com/vcb...-2015-preview/
    (older link, but more can be found if you have time for google run).

    Initiating a movement for 21st century BASIC standard is sure very tempting! ...And incredibly challenging task at the same time


    Petr
    Last edited by Petr Schreiber; 24-01-2017 at 22:32.
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 7 64bit - Intel Core 2 Duo T6600 @ 2.2GHz - 4 GB RAM - NVIDIA GeForce G210M 512MB
    Windows 8 64bit - Intel Core i5-3350P @ 3.1GHz - 8 GB RAM - NVIDIA GeForce GT640 3GB

  4. #14
    I understand that it is not 100%
    But it's more than basic

    I can quote points that I found

    Functionname = value
    Function = value
    Return value
    ----------------------
    Sub namesub()
    Sub namesub
    Without sub
    --------------------
    Long A
    A As Long
    Double
    Long Long
    variant
    Do not have variant
    ---------------------------
    Array (L, C)
    Array [L] [C]
    -------------------------
    Base 0
    Base 1
    ----------------------
    $Let
    Let
    -----------------
    Among many others

    From there you can have real compilers and interpreters
    ======================================================


    At least one could create a site where the staff could vote the basic characteristics of BASIC
    And implementers would decide whether to follow the most voted pattern or not
    Or at least if you had an opposite opinion leave an optional

    I was even tempted to create a group on the face,
    https://www.facebook.com/Programming...8714663280647/

    But let's face it

    I do not know English,
    This is necessary to reach the programmers of greater performance and importance in the generation of opinions

    I'm not a programmer,
    Would not know how to cover the most important points

    And I do not even know how to use it in groups and I do not like the face
    Among other things

  5. #15
    About state machine until I found some codes and explanations
    public class Lamp : StateMachine
    {
        // Triggers (or events, or actions, whatever) that our
        // state machine understands.
        [Trigger]
        public readonly Action PressSwitch;
    
        [Trigger]
        public readonly Action GotError;
    
        // Actual state machine logic
        protected override IEnumerable WalkStates()
        {
        off:                                       
            Console.WriteLine("off.");
            yield return null;
    
            if (Trigger == PressSwitch) goto on;
            InvalidTrigger();
    
        on:
            Console.WriteLine("*shiiine!*");
            yield return null;
    
            if (Trigger == GotError) goto error;
            if (Trigger == PressSwitch) goto off;
            InvalidTrigger();
    
        error:
            Console.WriteLine("-err-");
            yield return null;
    
            if (Trigger == PressSwitch) goto off;
            InvalidTrigger();
        }
    }
    
    But honestly I did not understand how to apply this in this situation of execution blocks
    It would be simpler to create functions with passages of the parameters by reference

    With the conditional goto would be something like
    If Primary_key(1) = "on" Then
    
    
         If Key(1) = "on" Then
              If test1 Then
                   For n = 1 To k
                        If matriz(n) = "pronto" Then
                             Key(n) = off:
                           GoTo Key_1
                        End If
                   Next
                  GoTo Primary_key1 'off
              End If
    
              If inversion_keys Then
                   For n = 1 To UBound(Key)
                        If Key(n) = off Then Key(n) = "on" Else Key(n) = off
                   Next
                   GoTo Primary_key1 'off
              End If
    Key_1:               'off
         End If
    
         If Key(2) = "on" Then
         
              If test1 Then
                   For n = 1 To k
                        If matriz(n) = False Then GoTo Key_2
                   Next
              End If
              If x Then Call f
              If y Then Call g
    
    Key_2:'off
         End If
    
         If Key(3) = "on" Then
              If Key(4) = "on" Then
    
    Primary_key1:'off
              End If  'Primary_key1
              If Primary_key(2) = "on" Then
    
    At least I find something simple and logical, of course a native instruction already encapsulated would be much better

Page 2 of 2 FirstFirst 12

Similar Threads

  1. Splitting code on multiple lines
    By TBUser54 in forum thinBasic General
    Replies: 2
    Last Post: 09-02-2012, 10:23
  2. Replies: 1
    Last Post: 11-11-2010, 14:29
  3. Playing with lines based on tutorial code
    By kryton9 in forum TBGL General
    Replies: 21
    Last Post: 04-02-2007, 00:27

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •