Results 1 to 3 of 3

Thread: Console_WriteLine don't accept negative numbers?

  1. #1
    Junior Member
    Join Date
    Oct 2017
    Posts
    7
    Rep Power
    8

    Console_WriteLine don't accept negative numbers?

    Why Console_WriteLine don't accept negative values?


    4th line is OK but 5th line says: "Error 262 - Invalid delimiter".

  2. #2
    my opinion:
    the 1 considered by Console_WriteLine as string and not a number, the proof is
    Console_WriteLine 1+1 will output 11 and not 2. while in the case of -1 the "-" is a mathematical operation forcing the 1 to be a number (negative number) which is not allowed by Console_WriteLine
    but interestingly
    '---Load Console Module
    Uses "Console"
    Long A,B
    A=-1 
    B= 2
    '---Print the magic words
    Console_WriteLine A+2
    PrintL "Press a key to end program"
    
    '---Wait for a key press
    WaitKey
    
    will output -12 so it seems Console_WriteLine converts the contents of A to string so string -1 & string 2 = -12

  3. #3
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,817
    Rep Power
    10
    Ciao,

    Console_WriteLn or PrintL (are the same function) before printing they go ahead in parsing trying to understand if next token is a start of a numeric or string expression. Based on that result, it evaluates string expression or numeric expression.

    Evidently it does a poor determination.

    To be always in the right track, use STR$() or TSTR$() or FORMAT$() or any function reading a numeric expression returning its value as a string to print out numeric expressions.

    Thanks for letting me know. I will see if I can improve kind determination.

    Ciao
    Eros
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

Similar Threads

  1. Tuned Dir_ListArray to accept multiple masks
    By Petr Schreiber in forum Sources, Templates, Code Snippets, Tips and Tricks, Do you know ...
    Replies: 0
    Last Post: 02-04-2013, 16:23
  2. Accept-Encoding: gzip
    By martin in forum Shout Box Area
    Replies: 6
    Last Post: 30-03-2009, 13:08
  3. UDT.and.numbers
    By Michael Clease in forum thinBasic General
    Replies: 2
    Last Post: 07-03-2009, 00:56

Members who have read this thread: 1

Posting Permissions

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