mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Feb 2003
Posts: 79
A
Ancyker Offline OP
Babel fish
OP Offline
Babel fish
A
Joined: Feb 2003
Posts: 79
ok well i was write this, and couldnt get it to work...i need it for a project im doing because the thing that reads the text reads it this way, and i need to encode it first, and i figure this would be the easyest way to process a large amount of text quickly, though im having problems

alphainvert {
return $replace($1-,a,z,b,y,c,x,d,w,e,v,f,u,g,t,h,s,i,r,j,q,k,p,l,o,m,n) \\ $replace($1,n,m,o,l,p,k,q,j,r,i,s,h,t,g,u,f,v,e,w,d,x,c,y,b,z,a) \\ $replace($1,a,z,b,y,c,x,d,w,e,v,f,u,g,t,h,s,i,r,j,q,k,p,l,o,m,n,n,m,o,l,p,k,q,j,r,i,s,h,t,g,u,f,v,e,w,d,x,c,y,b,z,a)
}

useing //echo $alphainvert(z y x w v u t s r q p o n m l k j i h g f e d c b a)

returns:
z y x w v u t s r q p o n n o p q r s t u v w x y z \\ a b c d e f g h i j k l m m l k j i h g f e d c b a \\ a b c d e f g h i j k l m m l k j i h g f e d c b a

which is incorrect.

as you can see it only processes a little bit of it. I don't know why...

Joined: Mar 2003
Posts: 1,271
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Mar 2003
Posts: 1,271
The reason is simple - once the first line is screwed, it works with the screwed line. Best thing I can come up now is a tempreplace:

replace all a's with @
replace all z's with a
replace all @ with z

replace all b with @
replace all y with b
replace all @ with y

Code:
alias alphainvert {
  [color:green]; save into a variable for easy editing[/color]
  set %templine $1-
  var %i = 1
  [color:green]; we're gonna do this 13 times (13 couples)[/color]
  while (%i <= 13) {
    [color:green]; define first letter[/color]
    var %first = $calc(96 + %i)
    [color:green]; define second letter[/color]
    var %last = $calc(123 - %i)
    [color:green]; replace letter 1 with a dummy character[/color]
    %templine = $replace(%templine,$chr(%first),@)
    [color:green]; replace letter 2 with letter 1[/color]
    %templine = $replace(%templine,$chr(%last),$chr(%first))
    [color:green]; replace dummy character with letter 1[/color]
    %templine = $replace(%templine,@,$chr(%last))
    inc %i
  }
  [color:green]; this echoes the inputted text[/color]
  echo -a $1-
  [color:green]; this returns the changed text to the script[/color]
  return %templine
}


input:
a b c d e f g h i j k l m n o p q r s t u v w x y z
output:
z y x w v u t s r q p o n m l k j i h g f e d c b a

Note that this piece is specific only to lowercase a - z, but so was your original code


DALnet #Helpdesk
I hear and I forget. I see and I remember. I do and I understand. -Confucius
Joined: Feb 2003
Posts: 79
A
Ancyker Offline OP
Babel fish
OP Offline
Babel fish
A
Joined: Feb 2003
Posts: 79
You misunder stood, i dont want to flip it around, i want A to be Z, not flip the string.

so... hello would be svool

######## EDIT ########

actully i misunderstood, that seems to work, ty, if you could make it case sensitive somehow thatd be cool...

Last edited by Ancyker; 13/02/04 02:25 PM.
Joined: Dec 2002
Posts: 2,985
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 2,985
It isn't flipped. Type a sentence with LoB's alias and you'll see a jumble of letters, not a flipped sentence.

EG: rg rhm'g uorkkvw. gbkv z hvxmgvmxv drgs oly'h zorzh zmw blf'oo hvv z qfnyov lu ovggvih, mlg z uorkkvw hvmgvmxv.

The letters have been changed to what you asked for yet the structure of the sentence is the same.

Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
try this...

alphainvert {
var %~ = 1 | while ((%~ < 255) && ($poscs($1-,$chr(%~),0) > 0)) inc %~ | %~ = $chr(%~)
return $replacecs($1- ,A,%~,Z,A,%~,Z, B,%~,Y,B,%~,Y, C,%~,X,C,%~,X, D,%~,W,D,%~,W, E,%~,V,E,%~,V, F,%~,U,F,%~,U, G,%~,T,G,%~,T, H,%~,S,H,%~,S, I,%~,R,I,%~,R, J,%~,Q,J,%~,Q, K,%~,P,K,%~,P, L,%~,O,L,%~,O, M,%~,N,M,%~,N ,a,%~,z,a,%~,z, b,%~,y,b,%~,y, c,%~,x,c,%~,x, d,%~,w,d,%~,w, e,%~,v,e,%~,v, f,%~,u,f,%~,u, g,%~,t,g,%~,t, h,%~,s,h,%~,s, i,%~,r,i,%~,r, j,%~,q,j,%~,q, k,%~,p,k,%~,p, l,%~,o,l,%~,o, m,%~,n,m,%~,n)
}

I used LocutusofBorg example of A,@, Z,A, @,Z but also protecting incase @ is in the string also, i replaced it with a value in %~ which most isnt going to be in the string (hopefully).

The reason your replace didnt work is becuase of how $repalce works. its like this.
"abz" replace a with z to get "zbz"
"zbz" replace b with y to get "zyz"
"zyz" replace c with x to get "zyz"
"
"
"zyz" replace y with b to get "zbz"
"zbz" replace z with a to get "aba"

Joined: Feb 2004
Posts: 8
B
Nutrimatic drinks dispenser
Offline
Nutrimatic drinks dispenser
B
Joined: Feb 2004
Posts: 8
If you don't care about uppercase letters (capitals), you might want to consider this simple solution which bypasses the problem:

/alphainvert {
/var %ainv.temp $upper($1-)
/var %ainv $replacecs(%ainv.temp,A,z,B,y,C,x,D,w,E,v,F,u,G,t,H,s,I,r,J,q,K,p,L,o,M,n,N,m,O,l,P,k,Q,j,R,i,S,h,T,g,U,f,V,e,W,d,X,c,Y,b,Z,a)
}

Since $replacecs is case sensitive, I turned all pre-code letters into uppercase.
The conversion turns them into lowercase letters, and because the script leaves lowercase letters alone, the system won't try to convert the same letter twice.

Hope this helps

Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
he specificly asked for a casesensitive version.

Joined: Feb 2003
Posts: 2,812
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,812
This is the fastest and most accurate alias you will find to perform the task you desire.

flip26 { bset -t &s 1 $$1- | breplace &s 65 90 66 89 67 88 68 87 69 86 70 85 71 84 72 83 73 82 74 81 75 80 76 79 77 78 78 77 79 76 80 75 81 74 82 73 83 72 84 71 85 70 86 69 87 68 88 67 89 66 90 65 97 122 98 121 99 120 100 119 101 118 102 117 103 116 104 115 105 114 106 113 107 112 108 111 109 110 110 109 111 108 112 107 113 106 114 105 115 104 116 103 117 102 118 101 119 100 120 99 121 98 122 97 | if ($isid) return $bvar(&s,1-).text | editbox -a $bvar(&s,1-).text }

This is based off a beautiful (that only a mother could love) technique by starbucks_mafia.

Usage: /flip26 <Your Text> [or] /echo -a $flip26(Your Text)

I aquired the number set with the following...

//var %a = $asc(A), %z = $asc(Z), %n = 26, %s | WHILE %n { var %s = %s %a %z | dec %n | inc %a | dec %z } | echo -a %s
//var %a = $asc(a), %z = $asc(z), %n = 26, %s | WHILE %n { var %s = %s %a %z | dec %n | inc %a | dec %z } | echo -a %s

- Raccoon

Last edited by Raccoon; 17/02/04 04:15 AM.

Well. At least I won lunch.
Good philosophy, see good in bad, I like!

Link Copied to Clipboard