QB64.org Forum

Active Forums => QB64 Discussion => Topic started by: xra7en on June 05, 2019, 09:56:31 pm

Title: print using type mismatch error
Post by: xra7en on June 05, 2019, 09:56:31 pm
Code: QB64: [Select]
  1.    
  2.     dim zz as double
  3.     ZZ = 9999 * RND
  4.    
  5.     PRINT USING "####.##"; ZZ; "."
  6.  

this produces a mismatch error for me.
amd I missing something, or using the "PRINT USING" incorrectly?
Title: Re: print using type mismatch error
Post by: bplus on June 05, 2019, 10:29:55 pm
It's the "." that PRINT USING isn't liking, this works if you really want the dot at the end:
Code: QB64: [Select]
  1. zz = 9999 * RND
  2.  
  3. PRINT USING "####.##"; zz;
  4. PRINT "."
  5.  
  6.  
Title: Re: print using type mismatch error
Post by: xra7en on June 05, 2019, 10:36:24 pm
WEIRD
But ya. works!

I supposed when I get down the to "how-to's" it make sense. however on the surface, with the ";" at the end, you would think the "." would show up. :-)

thanks for the quick response!!!!
Title: Re: print using type mismatch error
Post by: bplus on June 05, 2019, 10:53:58 pm
And this works!
Code: QB64: [Select]
  1.  
  2. zz = 9999 * RND
  3.  
  4. PRINT USING "####.##."; zz
  5.  
  6.  

Title: Re: print using type mismatch error
Post by: bplus on June 05, 2019, 10:55:59 pm
Hey where is the % sign coming from?
Code: QB64: [Select]
  1.  
  2. zz = 9999 * RND
  3.  
  4. PRINT USING "####.##, "; zz, RND * zz, 100 * RND * zz, .001 * zz
  5.  
  6.  
Title: Re: print using type mismatch error
Post by: Ashish on June 06, 2019, 12:59:17 am
I don't know why but this removes % sign
Code: QB64: [Select]
  1.  
  2. zz = 9999 * RND
  3.  
  4. PRINT USING "######.##, "; zz, RND * zz, 100 * RND * zz, .001 * zz
  5.  
Title: Re: print using type mismatch error
Post by: RhoSigma on June 06, 2019, 01:53:03 am
The % appears, if the number doesn't fit into the given format: 100 * RND * zz can become 999900 in your example, which doesn't fit into "####.##", but in "######.##" as Ashish did.
Title: Re: print using type mismatch error
Post by: bplus on June 06, 2019, 09:13:00 am
The % appears, if the number doesn't fit into the given format: 100 * RND * zz can become 999900 in your example, which doesn't fit into "####.##", but in "######.##" as Ashish did.

Ah yes, now I remember something like that, thanks guys.

Interesting how it prints the whole number breaking format length over, say starting or filling with %'s.