|
Virus Wanderer
Joined: 29 Jun 2002 Posts: 69 Location: USA
|
Posted: Wed Feb 12, 2003 1:28 pm
Auto Carrige Return |
Ok, Im not totally sure how to explain this. I have created a nice help systems from within zmud so that my scripts I write can be easily used. I am finding it rather difficult to reparse all teh information, carrige returns, color and such. I created a universal Header and Footer, as well as a few other things, but this I cant seem to get working.
What I am trying to do is make a function that will take any ammount of words, and after the last words of each line, before col 78, I want it to do a %{crlf} so that it stays within 78 chars across.
Think of it like writeing inside a box. Once you reach the end it goes to the next line and you start over, well thats what I want to do here.
Richard Powell
Mux Alias: Virus
2796 Wizard Staff
64.89.10.1 port 2796
Rich@gigdev.com |
|
|
|
Killfile Novice
Joined: 30 Sep 2002 Posts: 32 Location: USA
|
Posted: Wed Feb 12, 2003 1:45 pm |
To rephrase, I think
You want Zmud to take a string and count off 78 characters.
You then want it to return to the begining of whatever word
its in and insert a hard return.
Right?
--Killfile |
|
|
|
Virus Wanderer
Joined: 29 Jun 2002 Posts: 69 Location: USA
|
Posted: Wed Feb 12, 2003 1:46 pm |
Er after reading what I wrote it seems pretty....um unreadable. Basically I want a wordwrap function.
Richard Powell
Mux Alias: Virus
2796 Wizard Staff
64.89.10.1 port 2796
Rich@gigdev.com |
|
|
|
Virus Wanderer
Joined: 29 Jun 2002 Posts: 69 Location: USA
|
Posted: Wed Feb 12, 2003 1:54 pm |
Ok, here, I can draw it out I think here rather well. Heres what I want to do.
/--------------------|.......Hello........|
+--------------------+
|.Ok, I am wanting...|
|.Some code that.....|
|.will Auto wrap all.|
|.my words written...|
+--------------------+
|......Thanks........|
--------------------/
Ok, dont worry about the header and the footer. What I want is some type of code so i can do whats shown uptop without having to reparse it all. Something like %fun_wordwrap(<all my words here>,<lenght of wrapping>)
I hope that helps a little bit. (The dots are supposed to be spaces). |
|
|
|
Emit Magician
Joined: 24 Feb 2001 Posts: 342 Location: USA
|
Posted: Wed Feb 12, 2003 3:07 pm |
i'm going to try this as an alias rather than a #func so we can use #loop
#alias word_wrap {
length = %1
msg = %-2
i = 0
#loop %len( @msg),@length {
#add i 1
#if (@i >= @length AND %copy( @msg, %i, 1) = %char( 32)) {
msg = %delete( @msg, %i, 1)
msg = %insert( %crlf, @msg, %i)
i = 0
}
}
}
it tested ok for me
call it like this:
word_wrap 78 this is the very long string...
--------
moon.icebound.net:9000 |
|
|
|
Virus Wanderer
Joined: 29 Jun 2002 Posts: 69 Location: USA
|
Posted: Wed Feb 12, 2003 3:48 pm |
Hmm....doesnt really work for what I am trying to do. Ill try and get something out of it, but I need a function, not an alias for hte simple fact I will be calling on this function inside some code I will be writing.
Richard Powell
Mux Alias: Virus
2796 Wizard Staff
64.89.10.1 port 2796
Rich@gigdev.com |
|
|
|
Emit Magician
Joined: 24 Feb 2001 Posts: 342 Location: USA
|
Posted: Wed Feb 12, 2003 4:53 pm |
problem with writing it as a #function is that there are no functions for looping but it should still work ok, i think:
#alias dothestuff {
#var mystring {scripting to get the string}
word_wrap 78 @mystring
#var mystring @msg
commands after wordwrap
}
only thing you really can't do is call it inside of an expression.
--------
moon.icebound.net:9000 |
|
|
|
|
|