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
FOR LOOP List adjustment
Author Message
Mordaunt
Super Moderator
****

Posts: 1,237
Likes Given: 26
Likes Received: 55 in 43 posts
Joined: Mar 2012
Reputation: 35



Post: #1
FOR LOOP List adjustment
Some please look at this and tell me why it isn't working, I have been looking at it for so long I have more or less gone blind to it.

Code:
[FUNCTION f_list_cleanup]
obj=<src.region.tag.sign>
ref1=<args>
if <ref1.is_coowner>
    local.list=coowner
elif <ref1.is_friend>
    local.list=friend
elif <ref1.can_access>
    local.list=access
endif

if !(strcmpi("<local.list>","coowner")) ||!(strcmpi("<local.list>","friend"))
    for 1 <obj.tag0.max_<local.list>s>
        if (<obj.link.tag0.<local.lists>_<local._for>>==<ref1>) //find the # in the list of the person
            ref2=<local._for> // store it for use later
        endif
    endfor
    for <obj.link.tag0.<local.list>_<ref2> <obj.tag0.max_<local.list>s> // run a 2nd loop from the list number found earlier
        local.next=<eval <local._for>+1>
            if !(<obj.link.tag0.<local.list>_<local.next>>) // if there is an entry higher
                obj.try link.tag0.<local.list>_<local._for>=<obj.link.tag0.<local.list>_<local.next>> // overwrite current entry with that one
                    else
                obj.try link.tag0.<local.list>_<local._for>= //else wipe the entry
                    endif

        endfor
obj.tag0.<local.list> -=1 // remove 1 from the list to account for the person removed
endif

As per the comments that I added specifically for this post.
This function is designed to clean up the list when the house is transferred to a person on one of the house lists after it removes them from said list (because they are now the house owner)
It should find them in the list and then shuffle everyone in the list up one spot overwriting the person who received the house in the process.

It has been doing numerous things, depending on modifiations I have made, from diaplaying a name on the list twice to just not removing the names at all.

[Image: 2nis46r.jpg]
10-21-2012 03:47 AM
Visit this user's website Find all posts by this user Like Post Quote this message in a reply
RanXerox
Master
**

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



Post: #2
RE: FOR LOOP List adjustment
In the first IF block, if none of the conditions is true, local.list is undefined... maybe add an "else return 0"?

In the first FOR loop, will TAG.max_coowners TAG.max_friends or TAG.max_accesss (yes your script does add an extra "s") ever be zero? If so, your FOR loop goes from 1 to zero with possibly strange side effects... Maybe test whether those TAGs are zero and return 0 before the FOR loop starts? Also, your "inner IF statement" inside the first FOR loop references a LOCAL.lists varibale that doesn't exist.

If I were you I would abandon this TAG based data structure and use an actual LIST structure:

//- Added: Basic LIST support.
// LIST.xxx to show elements in list. Also, can be used like LIST.xxx=value to clear list and add a value
// LIST.xxx.ADD to add new element to list, can be number or string
// LIST.xxx.CLEAR to clear list
// LIST.xxx.index to read/write value on element in list
// LIST.xxx.COUNT to get count of elements in list
// LIST.xxx.index.REMOVE to remove element at specified index in list
// LIST.xxx.index.INSERT to insert element at specified index in list
// LIST.xxx.FINDELEM search_value returns index of first found element in list. Search starting from begin
// LIST.xxx.index.FINDELEM search_value returns index of first found element in list. Search starting from index
// SERV.PRINTLISTS to print all lists and their elements
// SERV.CLEARLISTS to clear all lists. If used with mask parameter, then clear all lists, which name countains specified mask
(This post was last modified: 10-21-2012 04:13 AM by RanXerox.)
10-21-2012 04:01 AM
Find all posts by this user Like Post Quote this message in a reply
Skul
Master
**

Posts: 413
Likes Given: 0
Likes Received: 19 in 15 posts
Joined: Jun 2012
Reputation: 9



Post: #3
RE: FOR LOOP List adjustment
Ran - Mordaunt, add an 'if' at the very top of your first 'if' statement:
Code:
if (<ref1.is_coowner>) || (<ref1.is_friend>) || (<ref1.can_access)
then toss the following code underneath it all and close it up with endif.

"I ask a question to the answer I already know."

Marchadium :: http://www.marchadium.ca/ :: Join us!
10-21-2012 04:14 AM
Visit this user's website Find all posts by this user Like Post Quote this message in a reply
Post Reply 


Forum Jump:


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