Author Topic: its me again cut script  (Read 11874 times)

Morio

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 256
Re: its me again cut script
« Reply #15 on: July 27, 2013, 02:46:05 AM »
The reason it repeats is that the Mid() function does not work the way you think it does. It can be used to return a string with specific length from within another string, but unless you you specify the length of the message, it will just return everything after the starting position

Code: [Select]
Mid(String, Start, Length)
Code: [Select]
Mid("Hello World", 3, 5)

Would return "llo W"


Mid("Hello World", 3)

Would return "llo World"


Also, the Right() function returns a number of characters from the end of the string, so it won't work properly in this script, unless you would calculate the cut position from the right side for the last part of the script (which I think would be a bit pointless).

I would suggest that for longer messages you could make a loop that cuts the first ~400 characters from a string and posts it and then makes a new string from the remaining characters and repeats the process until the whole message is posted.


Something like:

Code: [Select]
Do While Length(SomeString) > 400
    MessageString = Left(SomeString, 400)
    SendCommand "/say " & MessageString
    SomeString = Mid(SomeString, 401)
Loop

You could of course add the same kind of code to make the script cut the message at a space, like in the script you have already
« Last Edit: July 27, 2013, 03:00:18 AM by Morio »
"I don't know what World War 3 will be fought with, but I know World War 4 with be fought with sticks and stones." - Albert Einstein

Loralai

  • Newbie
  • *
  • Posts: 4
Re: its me again cut script
« Reply #16 on: July 27, 2013, 11:31:09 PM »
Just as a foreword, forgive me because I'm bound to sound dense here while not knowing the language.

So What you are saying is that I could utilize the existing script as first posted here without the section 3 and then add the loop at the end as you have posted it? So essentially I would need to find the point where it cuts off then put the number in that loop script and it would use the first script regularly and then cut from the end to repost it?

Morio

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 256
Re: its me again cut script
« Reply #17 on: July 28, 2013, 05:01:20 AM »
Just as a foreword, forgive me because I'm bound to sound dense here while not knowing the language.

So What you are saying is that I could utilize the existing script as first posted here without the section 3 and then add the loop at the end as you have posted it? So essentially I would need to find the point where it cuts off then put the number in that loop script and it would use the first script regularly and then cut from the end to repost it?

Almost the whole script could be replaced by that loop. The script you have already looks for a space after the 390th character, and cuts the message at that point rather than cutting in the middle of a word. Just add the part that decides where to cut the text inside the loop
"I don't know what World War 3 will be fought with, but I know World War 4 with be fought with sticks and stones." - Albert Einstein