It is currently Thu Jul 09, 2020 3:48 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Procedure - Integer arguments stored in a local array
PostPosted: Mon Jun 08, 2020 3:01 pm 
Offline
Enthusiast
Enthusiast

Joined: Wed May 27, 2020 12:26 pm
Posts: 104
From the idea of FlatEarth :

; '____' 4 characters code to store the arguments of a procedure in a local array.

; array name is Arg()
; be careful to ArgCount which has been defined as a local integer

; -9223372036854775808 for X64
; 2147483648 for X86
; this is a reserved argument value

; only for integers and pointors
; 16 arguments maximum : you can expand this availability. Please request if needed.

; Good luck !

Code:
;*************************************************************************************
; from the idea of FlatEarth
;
CompilerIf #PB_Compiler_Processor = #PB_Processor_x86
   #None = 1 << 31
CompilerElse
   #None = 1 << 63
CompilerEndIf

Macro Ar_
 Argument# MacroExpandedCount = #None
EndMacro

Macro ____
 Ar_, Ar_, Ar_, Ar_, Ar_, Ar_, Ar_, Ar_, Ar_, Ar_, Ar_, Ar_, Ar_, Ar_, Ar_, Ar_)
 Protected ArgCount.I
 For ArgCount = 0 To 15
  If PeekI(@Argument1 + ArgCount * SizeOf(Integer) ) = #None
   Break
  EndIf
 Next
 Dim Arg.I(ArgCount)
 Arg(0) = ArgCount
 For ArgCount = 1 To Arg(0)
  Arg(ArgCount) = PeekI(@Argument1 + (ArgCount - 1) * SizeOf(Integer) )
 Next
 ArgCount ! (0
EndMacro


;- Syntax example



Procedure Test(____)
 For I = 1 To Arg(0)
  Debug Arg(I)
 Next
EndProcedure

Test(1,2,5,10,20) ; <--- add up to 16 arguments


Last edited by Olli on Tue Jun 09, 2020 1:27 pm, edited 3 times in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: Procedure - Integer arguments stored in a local array
PostPosted: Mon Jun 08, 2020 6:24 pm 
Offline
User
User
User avatar

Joined: Tue Jan 28, 2020 10:17 am
Posts: 60
Hi, I'm very happy :D thank you for your efforts.

Why does this error appear when running?

[21:50:08] [COMPILER] Line 30: A ')' is expected to close the procedure.

Thanks again :wink:

_________________
FlatEarth addresses in PB :
Engine3D --> SkyDome
Mesh --> CreatePlane


Top
 Profile  
Reply with quote  
 Post subject: Re: Procedure - Integer arguments stored in a local array
PostPosted: Tue Jun 09, 2020 8:42 am 
Offline
Enthusiast
Enthusiast

Joined: Wed May 27, 2020 12:26 pm
Posts: 104
:D I copied the code manually, doing this little mistake !

Normally, it should be better, now. I will add a little comment for X86s owners...

Thank you for having tested ! And I hope it will be useful. If you have any questions, I will try to answer rightly !


Regards


Top
 Profile  
Reply with quote  
 Post subject: Re: Procedure - Integer arguments stored in a local array
PostPosted: Tue Jun 09, 2020 9:59 am 
Offline
Enthusiast
Enthusiast

Joined: Fri Feb 24, 2012 10:19 am
Posts: 172
Multi processor...

Code:
CompilerIf #PB_Compiler_Processor = #PB_Processor_x86
  #None = 1 << 31
CompilerElse
  #None = 1 << 63 
CompilerEndIf


M.


Top
 Profile  
Reply with quote  
 Post subject: Re: Procedure - Integer arguments stored in a local array
PostPosted: Tue Jun 09, 2020 1:24 pm 
Offline
Enthusiast
Enthusiast

Joined: Wed May 27, 2020 12:26 pm
Posts: 104
Hello mesa, thanks for you read and your suggest. I had 3 choices for this hardware difference :
Code:
[ ] #Pb_Compiler_Processor
[ ] SizeOf(Integer)
[ ] Stay lazy
Naturally, I stayed lazy ! The coder must already add manually argument maximum, if its program passed over. If I add toomany complex lines, it can cause some troubles (in the brain, but not in the hardware ! )

Here is the SizeOf(Integer) version :
Code:
#None = 1 << (SizeOf(Integer) - 1)
But your advise is more explicit : I insert yours.


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

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 14 guests


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