Page 1 of 1
					
				C++ to PB
				Posted: Sun Mar 13, 2005 10:24 am
				by chippy73
				Anybody help with this ?
I need to convert this:-    ***Array[] to PB. This is a pointer to a pointer to a pointer to an array.
Also this:-     something->that  This is something to do with objects.
Any help welcomed.
Alan
			 
			
					
				
				Posted: Sun Mar 13, 2005 12:04 pm
				by blueznl
				the first one would be something like PeekL(PeekL(PeekL(...)))
the second one... ain't got a clue
			 
			
					
				Re: C++ to PB
				Posted: Sun Mar 13, 2005 3:08 pm
				by LarsG
				chippy73 wrote:Anybody help with this ?
I need to convert this:-    ***Array[] to PB. This is a pointer to a pointer to a pointer to an array.
No.. that's just nasty!! 
 
chippy73 wrote:
Also this:-     something->that  This is something to do with objects.
That's a way of accessing a field or procedure in a class (structure)...  OO stuff..
PB is not able to do this stuff easily (yet), without mocking around like crazy with interfaces and stuff...
I guess you'll have to look up Interface in the help file..
Basically what you have to do is to make an interface with integer fields,
which in turn have to be used as pointers to a procedure, then to be used in a structure..
(I hope I got it right)
 
			 
			
					
				Re: C++ to PB
				Posted: Sun Mar 13, 2005 3:37 pm
				by traumatic
				It's pretty much impossible to translate this without any further code.
something->that can be used as a reference to a pointer to a structure or to a class.
If it's not a pointer to a class it may simply be *something\that in PB.
			 
			
					
				
				Posted: Sun Mar 13, 2005 3:43 pm
				by chippy73
				This is typical of the code that I am trying to convert to PB.....
Code: Select all
 Idx=0
    While Idx<SymbolsPerLine
      Idx=Idx+1
      Symbol[Idx]->ClearCorrection()
      Symbol[Idx]->Scan_Init()
    Wend
    For(Idx=0: Idx<SymbolsPerLine: Idx++)
        CorrectSymbol(Idx)
        Idx=0
        While Idx<SymbolsPerLine
          Idx=Idx+1
          Symbol[Idx]->AddCorrection(Weight);
          Symbol[Idx]->Decode()
        Wend
Hope that helps
Alan
 
			 
			
					
				
				Posted: Sun Mar 13, 2005 3:48 pm
				by traumatic
				Ok, then it's like LarsG said => OOP 

 
			 
			
					
				
				Posted: Sun Mar 13, 2005 4:30 pm
				by GedB
				For ***Array use somthing like this:
Code: Select all
Structure StaticArray
  Values.l[5]
EndStructure
DefType.StaticArray SA
SA\Values[0] = 1
SA\Values[1] = 2
SA\Values[2] = 4
SA\Values[3] = 8
SA\Values[4] = 16
*ThirdPointer = @SA
*SecondPointer = @*ThirdPointer
*FirstPointer = @*SecondPointer
;Note that we are using a pointer (begins with *) so only two peeks are needed to go 3 pointers deep.
*ReferencingSA.StaticArray =  PeekL(PeekL(*FirstPointer)) 
Debug *ReferencingSA\Values[0]
Debug *ReferencingSA\Values[1]
Debug *ReferencingSA\Values[2]
Debug *ReferencingSA\Values[3]
Debug *ReferencingSA\Values[4]
Debug *ReferencingSA\Values[5]
Structure ThreePointersDeep
For something->that you'll want to use an Interface.
If you have the class declaration then converting this to an Interface isn't too difficult.  Take a look at the following posts:
An example using interfaces.
viewtopic.php?t=9553&highlight=ipbfriendly
An example of converting some complex C++ classes to PB:
viewtopic.php?t=11827&highlight=winnie 
			 
			
					
				
				Posted: Mon Mar 14, 2005 7:14 pm
				by chippy73
				Thanks everyone for your comments.
It's getting very complex for my poor ol' "grey cells". I need to sleep on it and take another look tomorrow.
Thanks again.
Alan