Ooops
November 28, 2020, 11:35:30 AM

Author Topic: [bb] reverse a type list by b32 [ 1+ years ago ]  (Read 409 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bb] reverse a type list by b32 [ 1+ years ago ]
« on: June 29, 2017, 12:28:42 AM »
Title : reverse a type list
Author : b32
Posted : 1+ years ago

Description : how to reverse a custom type

Code :
Code: BlitzBasic
  1. ;HOW TO REVERSE A SERIES OF A CUSTOM TYPE
  2.  
  3. ;example custom type
  4. Type pt
  5.         Field i
  6. End Type
  7.  
  8. ;create 10 instances
  9. For i = 0 To 9
  10.  
  11.         p.pt = New pt
  12.         pi = i
  13.  
  14. Next
  15.  
  16. ;reverse instance order
  17. For p.pt = Each pt
  18.         If p <> Last pt Then
  19.                 q.pt = After p
  20.                 Insert p Before First pt               
  21.                 p = Before q
  22.         Else
  23.                 Insert p Before First pt
  24.                 Exit
  25.         End If
  26. Next
  27.  
  28. ;show result
  29. For p.pt = Each pt
  30.         Print pi
  31. Next
  32.  
  33. WaitKey()
  34. End


Comments : none...

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal