Glue (text $+ &bvar)

By Spoofing on Nov 14, 2010

//bset -t &i 1 hello | var %test = $+(test,$chr(32),$chr(32),&i,$lf,ok) | echo -a $bvar($glue(%test),1-)

Returns: 116 101 115 116 32 32 104 101 108 108 111 32 111 107 32

  • multispaces
  • $lf as delimiter
alias glue {
  var %string = $+($replace($1,$chr(32),$lf),$lf)
  while ($pos(%string,$lf)) {
    var %length = $v1, %variable = $mid($mid(%string,1,$v1),1,-1), %string = $mid(%string,$calc($v1 + 1))
    if ($bvar(%variable,0)) {
      bcopy -c &glue $calc($bvar(&glue,0) + 1) %variable 1 -1
    }
    elseif (%length > 1) {
      bset -t &glue $calc($bvar(&glue,0) + 1) %variable
    }
    bset &glue $calc($bvar(&glue,0) + 1) 32
  }
  return &glue
}

Comments

Sign in to comment.
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.