The following warnings occurred:
Warning [2] Use of undefined constant SAPI_NAME - assumed 'SAPI_NAME' (this will throw an Error in a future version of PHP) - Line: 3388 - File: inc/functions.php PHP 7.4.33-nmm7 (Linux)
File Line Function
/inc/functions.php 3388 errorHandler->error
/showthread.php 116 build_archive_link
Warning [2] Use of undefined constant IN_ARCHIVE - assumed 'IN_ARCHIVE' (this will throw an Error in a future version of PHP) - Line: 3331 - File: inc/functions.php PHP 7.4.33-nmm7 (Linux)
File Line Function
/inc/functions.php 3331 errorHandler->error
/inc/functions.php 3324 build_forum_breadcrumb
/showthread.php 195 build_forum_breadcrumb
Warning [2] Use of undefined constant IN_ARCHIVE - assumed 'IN_ARCHIVE' (this will throw an Error in a future version of PHP) - Line: 3331 - File: inc/functions.php PHP 7.4.33-nmm7 (Linux)
File Line Function
/inc/functions.php 3331 errorHandler->error
/showthread.php 195 build_forum_breadcrumb






Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A Question on File-Options
Author Message
RanXerox
Master
**

Posts: 550
Likes Given: 1
Likes Received: 12 in 9 posts
Joined: Dec 2010
Reputation: 19



Post: #7
RE: A Question on File-Options
Here is a excerpt from my Poker game scripts to sort an array of cards in a list object... I call out to another function called f_Poker_RankCards to decide which is higher or lower... in your case a simple less than or greater than test is probably sufficient:

Code:
[FUNCTION f_Poker_SortCards]
//"
// Usage: f_Poker_SortCards CardArray
//
// Sorts an existing LIST object named CardArray, which is assumed to contain
// CardSymbols.  The sort order has highest ranked cards (Ace) first (suit is
// ignored.)
//"
IF (<ARGV>==0)
   f_pokerlog 1,"Poker_SortCards: needs a CardArray"
   RETURN 1
ENDIF
LOCAL.Input=<ARGS>
LOCAL.InputSize=<LIST.<LOCAL.Input>.COUNT>
IF (<LOCAL.InputSize> < 2)
   f_pokerlog 1,"Poker_SortCards: CardArray <LOCAL.Input> is too small to sort"
   RETURN 1
ENDIF
//f_pokerlog 1,"Poker_SortCards: Start sorting <LOCAL.Input> (size=<LOCAL.InputSize>)"
LOCAL.Swapped=1
WHILE (<dLOCAL.Swapped>==1)
   LOCAL.Swapped=0
   FOR LoopNumber 1 <EVAL <LOCAL.InputSize>-1>
      IF (<LOCAL.LoopNumber>)
         LOCAL.CardA="<STRSUB 1 2 <LIST.<LOCAL.Input>.<EVAL <LOCAL.LoopNumber>-1>>>"
         LOCAL.CardB="<STRSUB 1 2 <LIST.<LOCAL.Input>.<dLOCAL.LoopNumber>>>"
//         f_pokerlog 2,"Poker_SortCards: ..Loop=<dLOCAL.LoopNumber>: Is <LOCAL.CardA> ranked higher than <LOCAL.CardB>?"
         IF (<f_Poker_RankCards <LOCAL.CardA>,<LOCAL.CardB>>==-1) //CardA ranks lower than CardB
//            f_pokerlog 3,"Poker_SortCards: ....swap them"
            LIST.<LOCAL.Input>.<EVAL <LOCAL.LoopNumber>-1>=<LOCAL.CardB>
            LIST.<LOCAL.Input>.<dLOCAL.LoopNumber>=<LOCAL.CardA>
            LOCAL.Swapped=1
//         ELSE
//            f_pokerlog 3,"Poker_SortCards: ....skipping"
         ENDIF
      ENDIF
   ENDFOR
   LOCAL.InputSize=<EVAL <LOCAL.InputSize>-1>
ENDWHILE
//f_pokerlog 1,"Poker_SortCards: Sorting Completed"
02-15-2013 05:00 AM
Find all posts by this user Like Post Quote this message in a reply
Post Reply 


Messages In This Thread
A Question on File-Options - Shidhun - 02-12-2013, 01:16 AM
RE: A Question on File-Options - Mordaunt - 02-12-2013, 01:34 AM
RE: A Question on File-Options - Shidhun - 02-12-2013, 01:57 AM
RE: A Question on File-Options - Mordaunt - 02-12-2013, 02:04 AM
RE: A Question on File-Options - Shidhun - 02-12-2013, 08:20 PM
RE: A Question on File-Options - RanXerox - 02-15-2013 05:00 AM
RE: A Question on File-Options - Mordaunt - 02-15-2013, 11:47 PM
RE: A Question on File-Options - darksun84 - 02-15-2013, 11:51 PM
RE: A Question on File-Options - Shidhun - 03-04-2013, 06:12 PM
RE: A Question on File-Options - Ben - 03-05-2013, 08:55 AM

Forum Jump:


User(s) browsing this thread: 8 Guest(s)