Syntax Issue

Windows specific forum
dna
User
User
Posts: 83
Joined: Wed Aug 30, 2006 12:07 am

Syntax Issue

Post by dna »

hello.

This may be a stuppid question but why does the syntax

PrintN("#: "+TR) shows on the screen, or console; #: N where N is a designated value or zero if uninitialized

but the syntax

PrintN(TR) gives a syntax error
User avatar
STARGÅTE
Addict
Addict
Posts: 2226
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: Syntax Issue

Post by STARGÅTE »

PrintN("#: "+TR) is a short version of: PrintN("#: "+Str(TR))

PrintN() needs a string, so you have to use a string
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
User avatar
Tenaja
Addict
Addict
Posts: 1959
Joined: Tue Nov 09, 2010 10:15 pm

Re: Syntax Issue

Post by Tenaja »

To expound on what Stargate said, once you start using a string, if you "add" a number to it, the Str() is implied...or the number type is converted to a string type, or any other variety of ways you can say "done for you".

If you are really worried about keystroke efficiency, you can even type this:
Print(""+TR)
instead of
Print(str(TR))
...saves you two whole keystrokes!
Post Reply