Results 1 to 3 of 3

Thread: Console_WriteLine don't accept negative numbers?

  1. #1

    Console_WriteLine don't accept negative numbers?

    Why Console_WriteLine don't accept negative values?

    Click image for larger version. 

Name:	program.png 
Views:	26 
Size:	7.1 KB 
ID:	9764 Click image for larger version. 

Name:	error.png 
Views:	23 
Size:	10.0 KB 
ID:	9765

    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
    50
    Posts
    8,198
    Blog Entries
    2
    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/ | psch.thinbasic.com
    Win10Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

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

Posting Permissions

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