It is currently Sat Sep 22, 2018 12:30 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: [Win] PBx86 FormatNumber() with procedure calls
PostPosted: Mon Sep 10, 2018 6:55 pm 
Offline
New User
New User

Joined: Sun Nov 26, 2017 3:13 pm
Posts: 7
PureBasic 5.62/70b1 32-Bit
Windows 7 64-Bit

You cannot use procedure calls in FormatNumber() with PB 32-bit.
With the 64-bit version it works without errors.

Code:
EnableExplicit

Procedure.s Thousend()
   ProcedureReturn ","
EndProcedure

Procedure.s Decimal()
   ProcedureReturn "."
EndProcedure

Define c.i
For c = 998 To 1002
   Debug FormatNumber(c, 0, Decimal(), Thousend())
Next

;PureBasic v5.62/70 Beta 1 - 32-Bit
; Executable type: Windows - x86  (32bit, Unicode, Thread, Purifier)
; Executable started.
; [Debug] 998,000000000000000000000000000000...
; [Debug] 999,000000000000000000000000000000...
; [ERROR] Line: 13
; [ERROR] Invalid memory access. (Read error at address 0)

;PureBasic v5.62/70 Beta 1 - 64-Bit
; Executable type: Windows - x64  (64bit, Unicode, Thread, Purifier)
; Executable started.
; [Debug] 998
; [Debug] 999
; [Debug] 1.000
; [Debug] 1.001
; [Debug] 1.002
; The Program execution has finished.


Top
 Profile  
Reply with quote  
 Post subject: Re: [Win] PBx86 FormatNumber() with procedure calls
PostPosted: Wed Sep 12, 2018 1:10 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Tue Sep 22, 2009 10:41 pm
Posts: 307
Hello PeDe,

FormatNumber() requires 64 bits type-double value on the first argument.

Please test
Code:
Define c.Q


Top
 Profile  
Reply with quote  
 Post subject: Re: [Win] PBx86 FormatNumber() with procedure calls
PostPosted: Wed Sep 12, 2018 7:11 am 
Offline
New User
New User

Joined: Sun Nov 26, 2017 3:13 pm
Posts: 7
Same error, and 'For' doesn't support quad variables.

Code:
Define c.i, q.q
For c = 998 To 1002
   q = c
   Debug FormatNumber(q, 0, Decimal(), Thousend())
Next

; PureBasic 5.70 Beta 1
; Waiting for executable to start...
; Executable type: Windows - x86  (32bit, Unicode, Thread, Purifier)
; Executable started.
; [Debug] 998.000000000000000...
; [Debug] 999.000000000000000...
; [ERROR] Line: 14
; [ERROR] Invalid memory access. (read error at address 0)


Top
 Profile  
Reply with quote  
 Post subject: Re: [Win] PBx86 FormatNumber() with procedure calls
PostPosted: Wed Sep 12, 2018 9:32 am 
Offline
Enthusiast
Enthusiast

Joined: Sat Feb 08, 2014 3:26 pm
Posts: 464
You're right, some functions don't support the procedure call as a parameter.
It is amazing that it works in 64 bits
That being said, it's easy to get around and it doesn't make more instructions to process.

This works (PB 5.70b1 32 bits). (No need quad)
Code:
EnableExplicit

Procedure.s Thousend()
   ProcedureReturn ","
EndProcedure

Procedure.s Decimal()
   ProcedureReturn "."
EndProcedure

Define Decimal$  = Decimal()
Define Thousend$ = Thousend()

Define c.i
For c = 998 To 1002
   Debug FormatNumber(c, 0, Decimal$, Thousend$)
Next

Code:
Waiting for executable to start...
Executable type: Windows - x86  (32bit, Unicode, Thread, Purifier)
Executable started.
The Program execution has finished.

Code:
998
999
1,000
1,001
1,002

Embedding functions allows you to save lines and ram but it sometimes gives strange results and especially it does not facilitate debugging
And then the ram, you can always release it after use.

:wink:

_________________
(English is not my native language, I used an online translator)
Windows 10 x64 - CPU intel i3 - RAM 16Go - NVidia GT 620 - 1920x1080 - Linux Slackware, Debian - xfce - (VirtualBox 5) - raspberry pi


Top
 Profile  
Reply with quote  
 Post subject: Re: [Win] PBx86 FormatNumber() with procedure calls
PostPosted: Wed Sep 12, 2018 11:54 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Tue Sep 22, 2009 10:41 pm
Posts: 307
Hello PeDe,

FormatNumber() requires 64 bits type-double value on the first argument.

You tested
Code:
Define c.Q
and it fails. And you add a type error for For statement.

Please test (keeping c as integer) :
Code:
tDouble.D = c
Debug FormatDate(tDouble, 0, Decimal(), Thousand() )


Top
 Profile  
Reply with quote  
 Post subject: Re: [Win] PBx86 FormatNumber() with procedure calls
PostPosted: Wed Sep 12, 2018 2:16 pm 
Offline
New User
New User

Joined: Sun Nov 26, 2017 3:13 pm
Posts: 7
I'm done.

Code:
EnableExplicit

Procedure.s Thousend()
   ProcedureReturn "."
EndProcedure

Procedure.s Decimal()
   ProcedureReturn ","
EndProcedure

Define  d.d
d = 999.0
Debug FormatNumber(d, 0, Decimal(), Thousend())
d = 1000.0
Debug FormatNumber(d, 0, Decimal(), Thousend())

;PureBasic v5.62/70 Beta 1 - 32-Bit
; Waiting For executable To start...
; Executable type: Windows - x86  (32bit, Unicode, Thread, Purifier)
; Executable started.
; [Debug] 999,000000000000000000000000000000000000000000...
; [ERROR] Temp.pb (Line: 15)
; [ERROR] Invalid memory access. (Read error at address 0)

;PureBasic v5.62/70 Beta 1 - 64-Bit
; Waiting For executable To start...
; Executable type: Windows - x64  (64bit, Unicode, Thread, Purifier)
; Executable started.
; [Debug] 999
; [Debug] 1.000
; The Program execution has finished.


Top
 Profile  
Reply with quote  
 Post subject: Re: [Win] PBx86 FormatNumber() with procedure calls
PostPosted: Wed Sep 12, 2018 3:41 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Tue Sep 22, 2009 10:41 pm
Posts: 307
Thank you PeDe, it's a bug on x86 version.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye