I have made the script for both CMUD 2.37 (.mdb files - MSAccess database) and CMUD 3.xx (.dbm files - SQLite database).
Since CMUD 3.xx is still BETA, for the time being I will not post the script for CMUD 3.xx since the structure of .dbm files might sustain changes.

Here's the VBScript code for CMUD 2.37 (for .mdb files - MSAccess database):
I have used it numerous times and didn't notice any undesirable side effects.
Anyway, BACKUP your map file before using this script!!!

Code:

'==========================================================================
'
' VBScript Source File
'
' NAME : Recycle_room_&_exit_numbers.vbs
' AUTHOR : Marian Cascaval (aka Bothkill)
' E-MAIL : MarianCascaval@yahoo.com
' DATE : <February 5, 2009>
' COMMENT : In the process of creating maps with CMUD 2.xx, every room you create
' is assigned a number (you can check the number of every room by
' hovering the mouse over the room).
'
' The problem appears when you delete a room (or more rooms).
' The numbers of deleted rooms are not used for creating new rooms,
' but are skipped.
'
' To understand the problem, let's see an example:
' 1. create a new map
' 2. create a room (this is #1)
' 3. delete room #1
' 4. create a new room (this #2); although there is only one room
' on the map, this room is #2.
'
' As you can see, numbers of deleted rooms are not recycled.
' Not such a great issue, but is annoying when you delete
' a great number of rooms and later when creating new ones you reach
' unrealistic room numbers.
'
' You can check your Mud .mdb map file to see it for yourself.
' The "your-Mud".mdb file is a Microsoft Accesss database file
' CMUD uses for storing your Mud map.
'
' Open the table "ObjectTbl" and compare the last record in the
' "ObjId" column (this is where the room numbers are) with the
' total number of records in that table.
' If you have deleted a lot of rooms while creating that map
' you will notice a considerable difference between the two values.
'
' The problem goes worse as regards Exit numbers.
' You cannot see Exit numbers on the map, but you can see them
' in the .mdb map file:
' "ExitId" column in "ExitTbl" table.
'
' Here, the difference between the last record and the total number
' of records is even greater than in the case of room numbers.
'
' This script (VBScript) recycles the numbers of deleted rooms and exits.
'
' This script is useful if you have ever deleted rooms in your map.
' If you don't know if you have ever deleted rooms in your room, you can
' still run this script, since it will inform you if recycling was done.
'
'
' !!! IMPORTANT !!!
' =================
' Although I have tested this script in all possible scenarios I could
' think of, I urge you to BACKUP your .mdb file BEFORE running the script.
'
' IF you have scripts that depend on room numbers (i.e. #TELEPORT #23)
' then almost certainly your script will not work as before (i.e. you will
' be TELEPORTed to another room than previously intended).
' A recommendation on this:
' Always use within scripts SHORT NAMES of rooms and not ROOM NUMBERS
' (i.e. #TELEPORT "room-name" "zone-name").
' The short-names of rooms can be set by setting the map in create mode,
' right-click on room, click on properties, click on "Other" tab
' and setting the name in the "Short Name of room" field.
'
' After running the script, TEST your .mdb map file to see IF everything is OK.
'
'
' TECHNICAL INFO:
' ===============
' There are the following important tables and columns in your .mdb file
' that deal with these numbers:
'
' Table "ObjectTbl"
' Columns
'
' ...this is not complete...
'
'
'
'==========================================================================

' =======================================================================
' Script for selecting a file by using a Windows Common Dialog box
'
' Thanks go to Jerry Lees for this script
' The script can be found at http://itknowledgeexchange.techtarget.com
' =======================================================================

If recycle_flag Then
MsgBox "Room numbers recycled.",,"Message no.1"
recycle_flag = False ' Set the flag as False for the next recycling message
Else
MsgBox "Room numbers need not recycling.",,"Message no.1"
End If

' Recycle the next-to-create room number in ObjID column from VersTbl table

Ugh. The file structure for the .dbm files will probably NOT change. :P I don't have/use the .mdb database anymore, and pretty sure the guy who requested it uses the beta as well. I've been wanting a script like this for a while. :\ Any chance you could at least pm the beta version?

Also, since you seem to be good at this, think you're able to write up a script to recycle database numbers? (I'm referring to when you delete a row in the internal database, it just increments the number instead of recycling the number. Gets annoying when your database is up to 17402 with only 132 records...)

I use the Beta version 3.08, but I'd be willing to give it a trial run on my database (after I back it up of course...) :)

One dumb question for you. How do I run this? Do I just copy and paste it into an alias in Cmud and then set the script type to Visual Basic? Do I need to have Visual Basic installed on the computer like you need Python installed to use the Python language?

I gave it my best shot to read through the code to figure out what was going on. Unfortunately I don't think I understood what you were doing, despite your excellent comments in the code. If I have a DB that is like this:

Rec#: In use:
1 Yes
2 No
3 No
4 No
5 Yes
6 Next Number to use when mapping

Would it recycle it so that it was like this:

Rec#: In use:
1 Yes
2 Yes
3 Next Number to use when mapping

Or would it only recycle when the non-used number occur at the end and there are no used numbers at the end, such as this:

Rec#: In use:
1 Yes
2 No
3 No
4 No
5 Next Number to use when mapping

One other additional thing I was thinking about was to be able to group the record numbers by zone. Sometimes I map out a zone then it gets modified and I go back and update the map. So it turns out I have something like this:

Sorry, to disappoint you but I'm not a programmer. Programming is only a hobby which I practiced only a few times in my life.
For dealing with this recycling issue, I had to search the Internet for VBScript and database tutorials.
Real programmers could do this kind of stuff much faster and much better.
I was forced to learn the basics of VBScript and database because no real programmer was interested in solving this recycling issue.

charneus wrote:

a script to recycle database numbers? (I'm referring to when you delete a row in the internal database

It would be helpful to indicate the table you're referring to.
Then I'll see if I will be able to do something about it.
Then again, real programmers could do this kind of stuff in no time. Anyway, if no one tries I will try it for myself.

Tech wrote:

Ideally you should be putting these in the package library.

I use CMUD at a very basic level, so I don't know what this "package library" thing is about.

charneus wrote:

Any chance you could at least pm the beta version?

ReedN wrote:

I use the Beta version 3.08

OK, I will also post here the script for the CMUD 3.xx but I need some time to clean the code a little bit and do some more testing.

ReedN wrote:

How do I run this? Do I just copy and paste it into an alias in Cmud and then set the script type to Visual Basic? Do I need to have Visual Basic installed on the computer like you need Python installed to use the Python language?

Probably there are many ways, but I use it like this:
Make a new .txt file. Copy and Paste the code into the .txt file. Change the file extension from .txt to .vbs.
Double click the .vbs file.
I use Win XP which has VBScript pre-installed.

ReedN wrote:

I gave it my best shot to read through the code to figure out what was going on.

The script recycles all the unused room numbers no matter how they are distributed relative to the used numbers.
This process is a little bit complicated since there is necessary to re-number all the used numbers and all their "dependencies".
The only down-side is the one mentioned in the section "!!! IMPORTANT !!!" in the code.

ReedN wrote:

One other additional thing I was thinking about was to be able to group the record numbers by zone.

For understanding this issue I have to look again into the tables' structure of the database.
Anyway this issue has more to do with regrouping and nice-looking than recycling . When all recycling is done, the next step is beautification!

The Shared Package Library is potentially one of the most powerful features of CMUD. It's a single repository available to registered CMUD users to be able to access scripts and modules that other CMUD users have put together. There are already quite a few packages in the library, and is one of the reasons you don't see too many 'Finished CMUD Scripts' as they are usually put in the library.

With features like a rating system, version control and CMUD version required it's quite a powerful feature.

I've having a hard time with getting this working. I installed it from the package library and I see it in my packages directory, but it's a pkg file. How do open it? I tried opening it with the package editor (File->View Package), but that didn't work. I must be doing something wrong here.

I've never been able to figure out how to use the scripts I've downloaded from the package library. The Cmud help files tell how to install or uninstall items, but there's nothing in there on how you access it and use it once it has been downloaded.

I was looking in more detail at your code above and I believe you've omitted the NoteTbl when you do the renumbering. Perhaps this is because you don't populate the Notes field in your map. If I don't include the notes in the renumbering it will break my whole map.

I'm also curious about this:

Code:

' Exit numbers in ExitIdTo column in ExitTbl table
' greater than max number in ExitId column in ExitTbl table
' become -1

If max_ExitIdTo > max_ExitId Then
For a_counter = max_ExitId + 1 To max_ExitIdTo
objConn.Execute ("UPDATE ExitTbl SET ExitIdTo=-1 WHERE ExitIdTo="& a_counter &"")
Next
MsgBox "Exit connections have been cleaned.",,"Message no.5"
Else
MsgBox "Exit connections need not cleaning.",,"Message no.5"
End If

Why did you find this necessary to do? From what I understand this means you essentially found an invalid link. Was the invalid link from your script or from Cmud?

You're right.
The package was supposed to have a function which contained the script.
For some reason, the package didn't upload the function too.
I've tried to fix this and now the package contains the function.
Now, opening the package with Package Editor should allow you to see the function containing the script.

ReedN wrote:

...I believe you've omitted the NoteTbl when you do the renumbering...

Right again.
I use Notes, but forgot about them. And yes, they are a mess now.
I'll try to fix this.

ReedN wrote:

Why did you find this necessary to do? From what I understand this means you essentially found an invalid link. Was the invalid link from your script or from Cmud?

From what I remember, the links to rooms having a value larger than the maximum post-recycling room number, get invalid due to renumbering and this issue got to get addressed.
It went like this:
The script also recycles Exit links.
Let's say we have this scenario:
Before renumbering:at the end of the room table there is a deleted room (no. 100). You made this room before, made some links to it (from 98 to 100, from 99 to 100 etc), but eventually you deleted it. But the links remain to that room number in the ExitTbl (from 98 to 100, from 99 to 100, it's just the fact that room 100 is deleted that makes you not see those links).
After renumbering: That deleted room number (no.100) will be used in the future (is recycled). Let's say you create a new room elsewhere (i.e. in other place than the original room no.100 was). This new room gets number 100 and then the links (from 98 to 100, from 99 to 100 etc) get validated again since room no.100 is alive again. But the new room no.100 is not where the old room no.100 was, so you will have some links you surely don't want .

From what I remember, the links to rooms having a value larger than the maximum post-recycling room number, get invalid due to renumbering and this issue got to get addressed.
It went like this:
The script also recycles Exit links.
Let's say we have this scenario:
Before renumbering:at the end of the room table there is a deleted room (no. 100). You made this room before, made some links to it (from 98 to 100, from 99 to 100 etc), but eventually you deleted it. But the links remain to that room number in the ExitTbl (from 98 to 100, from 99 to 100, it's just the fact that room 100 is deleted that makes you not see those links).
After renumbering: That deleted room number (no.100) will be used in the future (is recycled). Let's say you create a new room elsewhere (i.e. in other place than the original room no.100 was). This new room gets number 100 and then the links (from 98 to 100, from 99 to 100 etc) get validated again since room no.100 is alive again. But the new room no.100 is not where the old room no.100 was, so you will have some links you surely don't want .

Wow, something I hadn't even considered. This is interesting diving into this. I'm determined to get it sorted/recycled... hopefully I eventually get there.

It didn't upload correctly the updated version.
It also doesn't remember the CMUD Version required, that's why I had to write it in the description.
It also doesn't show what I write in the "What's new" section.

I ran it verbatim and I didn't get that error. It has been running for 100 minutes at this point and I just got the first progress boxes saying it has finished recycling the first set of items. It is now doing exits. I have well over 20k rooms.

That particular item: 'UserAccounts.CommonDialog' is used to open a dialog box. I'm not sure why it's giving you an error. All I did was ctrl-a to select everything, then I copied it into a text editor.

Edit: I'll also note that my disk is very active during this script. I'm not sure why it should be so heavily utilized since this should all be able to fit in memory for execution.

According to this site "UserAccounts.CommonDialog" is working only under Windows XP.
So, I'll presume you're not using Win XP.

I'm thinking of the following work-around:
Comment the lines dealing with the database selection window (i.e. from line no.95 "Dim objFSO, initFSO" until line no. 126 "End If", right before "End of Script for selecting a file").
Modify the line no.139 so it contains the path to your database file:
I.e. change the line:

It has been running for 100 minutes at this point...
...my disk is very active during this script

It takes so much time only the first time recycling is done.
For example, if you have 20k-room map and you need to recycle only the room no.1, boy, sure it will take some time, since all the room and exit numbers have to be re-written.
But after recycling is done for the first time, then it will take no time to recycle your, let's say, next new 100 rooms (presuming you will not delete room no.1 ).

The hard disk usage is due to the fact that for every change in the database, the script accesses the file.
Maybe it will be best if the file loads into RAM and the script operates on it from there, but I don't know how to do this .

But overall, I think this script really needs to be transformed into an executable.
If no one try this, I'll try to make it (but it will take some time).

According to this site "UserAccounts.CommonDialog" is working only under Windows XP.
So, I'll presume you're not using Win XP.

I'm thinking of the following work-around:
Comment the lines dealing with the database selection window (i.e. from line no.95 "Dim objFSO, initFSO" until line no. 126 "End If", right before "End of Script for selecting a file").
Modify the line no.139 so it contains the path to your database file:
I.e. change the line:

First, I'm assuming PATH_TO_YOUR_FILE is to be replaced with the path to my file (i.e. C:\Users\Documents\ etc.). Either way, I tried it verbatim and with the path, and both came back with the error of 'Line: 139. Char: 54: Error: Expected end of statement.'

So it did fail once again.

And yeah, you're right - I work with Windows 7 (which has the same structure as Windows Vista. I suppose I need to find the replacement for Vista and hope that it works. *sigh* I look forward to this working, though!

Charneus

PS. By the way, not sure which table it is in the internal database. I just don't like using #NEW MyEQ {Name=blahblahblah|Stats=blahblahblah} and having it be record number 4002421. :P