Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ General ➜ Database/file, seeking suggestion

Database/file, seeking suggestion

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Prattler   Lithuania  (15 posts)  Bio
Date Sat 08 Jan 2005 12:37 PM (UTC)
Message
I would like to create a spell list easily editable with some outside program, for example MS excel. Is it possible to open and read the file with a MUSHclient script? If it is not, what would be the best solution for me? Thank you
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #1 on Sat 08 Jan 2005 05:53 PM (UTC)
Message
If you saved the file in comma-separated-value (CSV) format in Excel, you could fairly easily read that with a script, especially Lua. The problem with saving an Excel spreadsheet is that you wouldn't know the format to read from it.

You could probably also use an Excel COM object to open the sheet, but I don't know if that'll let you make row/column queries and the like without actually displaying the sheet.

It depends on what you're going to store in the spell list, really.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #2 on Sat 08 Jan 2005 07:44 PM (UTC)
Message
One approach is to use Excel and then convert the resulting file (with find-and-replace) to resemble ordinary variable definitions in XML, like this:


<variables>
  <variable name="fireball">20</variable>
  <variable name="iceblast">42</variable>
</variables>


Then simply import or paste them into MUSHclient.

The name is in the name="xxx" part, and the contents is after the > sign.

Another approach is to use Lua to read the CSV file, see this page for example code:

http://www.lua.org/pil/20.4.html

However more simply, since I presume each line would simply contain variable=contents, you could write a simple script to read in your file (there are lots of examples of reading files here), and simply search for the delimiter (eg. the comma or tab) and put the first part as the name, and the second part as the contents.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Scypio   Poland  (50 posts)  Bio
Date Reply #3 on Sat 08 Jan 2005 08:08 PM (UTC)

Amended on Sat 08 Jan 2005 08:09 PM (UTC) by Scypio

Message
Just a sample of using Excel COM object in VBS:

dim xlapp, xlbook,xlsheet

sub Test
dim i,j

set xlapp=CreateObject("Excel.Application")
xlapp.visible=false 'so it runs in background and is not visible
set xlbook=xlapp.workbooks.open ("G:\test.xls")
set xlsheet=xlbook.sheets("Arkusz1")
for i=1 to 5 'rows
for j=1 to 5 'columns
note i & "," & j & xlsheet.cells(i,j)
next
next

end sub

sub Test2

set xlsheet=nothing
set xlbook=nothing
xlapp.quit
set xlapp=nothing

end sub

Test1 opens the file and reads from it first 5 rows and 5 columns and displays to the screen.
Test 2 closes the Excel Application - you must remember to do it;)

It works fine although not very fast and doesn't display the application.
Top

Posted by Prattler   Lithuania  (15 posts)  Bio
Date Reply #4 on Sun 09 Jan 2005 07:03 PM (UTC)
Message
Thank you all for the help, that was what I needed. I'll try to move on on my own now :)
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


15,459 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.