Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
iosman
Beginner


Joined: 06 May 2019
Posts: 10

PostPosted: Mon Jun 24, 2019 2:33 am   

Need an alias to break apart long strings
 
Ok I am in need of an alias to break apart a long string at the closest .?! char to 230 characters without going over 230. It also needs to break on a space as a last resort if there is no punctuation.

Anyone think they can help me with my quest to break apart long strings?
I just need a rough working example of doing this I should be able to tidy it up to do exactly what I want from there . .
.


Last edited by iosman on Tue Jul 23, 2019 4:36 am; edited 1 time in total
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4691
Location: Pensacola, FL, USA

PostPosted: Mon Jun 24, 2019 4:16 am   
 
I have something similar already coded:
It is currently set to a 79 char limit, but that should be easily edited.
Code:

#PRINT Text to be edited:
#PRINT %clip
#PRINT Reformatting too:
$that=%replace( %clip, %cr, " ")
#PRINT $that
#LOCAL $this $maybe $leftover $pos
#LOOP ((%len($that)/80)+2) {
  #IF (%len( $that)<80) {
    #ADDITEM $this %trim( $that)
    $that=""
    } {
    $pos=0
    #WHILE ($pos<80) {
      $maybe=%left( $that, $pos)
      $leftover=%right( $that, $pos)
      $pos=($pos+%pos( " ", $leftover))
      }
    #ADDITEM $this %trim( %left( $that, %len( $maybe)))
    $that=%right( $that, %len( $maybe))
    }
  }
#PRINT And here is the finished result:
#CALL %clip( %expandlist( $this, %cr))
#PRINT %clip
_________________
Discord: Shalimarwildcat
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net