Page 3 of 4 FirstFirst 1234 LastLast
Results 21 to 30 of 38

Thread: Tbo2

  1. #21
    I'm intrigued by immutability. Do you find it useful in RUST?
    A language without variables and only constants would surely send me over the edge.
    ScriptBasic Project Manager
    Project Site
    support@scriptbasic.org

  2. #22
    Thanks, Petr,

    With regard to RUST's immutability rules, Would this construction be acceptable:

    do {
       let a=inkey()
       if a<32 { exit do }
    }
    

  3. #23
    Rust variables are immutable by default, but you can override it using mut. In other languages, they are mutable by default but you can use const to make it immutable. So, the same rules, but reversed.
    Forum: http://www.jose.it-berater.org/smfforum/index.php<br />Website: http://www.jose.it-berater.org/index.html<br />SED Editor, TypeLib Browser, headers and examples.

  4. #24
    How are arguments passed to a function viewed in Rust? Is there any concept of LOCAL?
    ScriptBasic Project Manager
    Project Site
    support@scriptbasic.org

  5. #25
    Constants can only be defined in terms of other constant expressions. They can be resolved at compile-time, whereas immutables may also be set by variable expressions in run-time (once only).

    I'm interested in providing an immutability mode in o2, but I am puzzled as to how it could be used advantageously.


    PS:
    RUST has local variables, and parameter passing byval / byref, much the same as C / Basic.

  6. #26
    i believe the Rustologists only rename the jargon of C/Basic, beautifying it with Philosophy .
    i have stopped to learn Rust after looking at this (simple program!!)
    https://stackoverflow.com/questions/...g-to-hit-enter
    extern crate termios;
    use std::io;
    use std::io::Read;
    use std::io::Write;
    use termios::{Termios, TCSANOW, ECHO, ICANON, tcsetattr};
    
    fn main() {
        let stdin = 0; // couldn't get std::os::unix::io::FromRawFd to work 
                       // on /dev/stdin or /dev/tty
        let termios = Termios::from_fd(stdin).unwrap();
        let mut new_termios = termios.clone();  // make a mutable copy of termios 
                                                // that we will modify
        new_termios.c_lflag &= !(ICANON | ECHO); // no echo and canonical mode
        tcsetattr(stdin, TCSANOW, &mut new_termios).unwrap();
        let stdout = io::stdout();
        let mut reader = io::stdin();
        let mut buffer = [0;1];  // read exactly one byte
        print!("Hit a key! ");
        stdout.lock().flush().unwrap();
        reader.read_exact(&mut buffer).unwrap();
        println!("You have hit: {:?}", buffer);
        tcsetattr(stdin, TCSANOW, & termios).unwrap();  // reset the stdin to 
                                                        // original termios data
    }
    
    will focus on Basic Languages only
    BUT i will stay watching the subject occasionally

  7. #27
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    51
    Posts
    8,338
    Blog Entries
    2
    Rep Power
    10




    Too complex to me
    www.thinbasic.com | www.thinbasic.com/community/ | psch.thinbasic.com
    Win10Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

  8. #28
    Here is the Script BASIC version of the GetKey Rust program.

    IMPORT CIO.sbi
    Start:
    PRINT "Hit a key! "
    buffer = CIO::getch()
    IF buffer = 27 THEN GOTO Done
    PRINT "\nYou have hit: ","[",FORMAT("%~000~",buffer),"] - ",CHR(buffer),"\n"
    GOTO Start
    Done:
    

    C:\ScriptBASIC\examples\test>scriba getch.sb
    Hit a key!
    You have hit: [001] - ☺
    Hit a key!
    You have hit: [002] - ☻
    Hit a key!
    You have hit: [003] - ♥
    Hit a key!
    You have hit: [065] - A
    Hit a key!
    You have hit: [098] - b
    Hit a key!
    You have hit: [067] - C
    Hit a key!
    C:\ScriptBASIC\examples\test>
    Last edited by John Spikowski; 10-07-2018 at 07:36.
    ScriptBasic Project Manager
    Project Site
    support@scriptbasic.org

  9. #29
    Thanks John for the code. evidently we can know what it is doing since it is natural and readable, i have tested it after adding IMPORT "cio.bas" for the windows version.
    this is one possibility for Thinbasic
    Uses "Console"
    String a
    PrintL "Press ESC key to end program"
    While a<>"[ESC]"
    a = WaitKey
    PrintL a
    Wend
    
    it will return the pressed character until we press ESC.
    i just don't know why Eros have added "[]" to the captured character, but it is not a problem at all.
    i think the programming language should not waste the Human Brain limited resources (100 billion neurons damaged by the Pollution, wars, Politics... ) especially in this noisy world with all the flood of information processed by the Mind so the designers of programming language should take care of this fact.

  10. #30
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    51
    Posts
    8,338
    Blog Entries
    2
    Rep Power
    10
    Quote Originally Posted by primo View Post
    i just don't know why Eros have added "[]" to the captured character, but it is not a problem at all.
    Reason is because WaitKey is able to get special multiple key press combination like in the following example:
    Press ESC key to end program
    [CTRL][PGUP]
    [SHIFT][CTRL][PGDOWN]
    [SHIFT][CTRL][END]
    [SHIFT][CTRL][DOWN]
    [SHIFT][CTRL][RIGHT]
    [CTRL][UP]
    [CTRL][DOWN]
    [CTRL][LEFT]
    [CTRL][RIGHT]
    [ALT][LEFT]
    [ALT][RIGHT]
    [ALT][DOWN]
    [ALT][UP]
    [ALT][q]
    [ALT][Q]
    [ALT][e]
    [ALT][c]
    [ALT][d]
    
    Using [] seemed to me a convenient way to get all possibilities.
    www.thinbasic.com | www.thinbasic.com/community/ | psch.thinbasic.com
    Win10Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

Page 3 of 4 FirstFirst 1234 LastLast

Posting Permissions

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