Strange Error on Swap()

New to FreeBASIC? Post your questions here.
Post Reply
Iczer
Posts: 99
Joined: Jul 04, 2017 18:09

Strange Error on Swap()

Post by Iczer »

I'm getting strange error at Swap():

Code: Select all

Type tagParentUDT
	iCount		as long
	iCountMAX	as long
	ptMyUDT		as tagMyUDT Ptr
	
	Declare sub SomeSubName()
End Type 


Dim As tagParentUDT Ptr ptParentUDT = New tagParentUDT

ptParentUDT->iCount = 10
ptParentUDT->iCountMAX = 10

ptParentUDT->ptMyUDT = New tagMyUDT[ptParentUDT->iCountMAX + 1]

Dim As tagMyUDT Ptr ptMyUDTNEW = New tagMyUDT
...

ptParentUDT->SomeSubName()

ptParentUDT->iCount += 1
(ptParentUDT->ptMyUDT[ptParentUDT->iCount]) = *(ptMyUDTNEW)


sub tagParentUDT.SomeSubName()

	If (This.iCount + 1) > This.iCountMAX Then
		
		This.iCountMAX += 10
		
		Dim As tagMyUDT Ptr ptMyUDTUPD = New tagMyUDT[This.iCountMAX + 1]
		
		For i As UInteger = 1 To This.iCount
			(ptMyUDTUPD[i]) = (This.ptMyUDT[i])
		Next
		
		Swap((This.ptMyUDT), ptMyUDTUPD) --->  error 7: Expected ')', found ',' in 'Swap((This.ptMyUDT), ptMyUDTUPD) ???
		
		Delete[] ptMyUDTUPD
	End If

end sub
But why? Syntax is not wrong as I understand...
fxm
Moderator
Posts: 12081
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: Strange Error on Swap()

Post by fxm »

Looking only at the SWAP usage syntax:
Call SWAP without parentheses:
Swap(a, b)
Swap a, b


I propose to add the paragraph "Usage" (missing) in the documentation.
[edit]
Done.
Iczer
Posts: 99
Joined: Jul 04, 2017 18:09

Re: Strange Error on Swap()

Post by Iczer »

Thanks!
Post Reply