|
mid$()
Mar 14, 2023 8:17:05 GMT
Post by honky on Mar 14, 2023 8:17:05 GMT
Hello everyone, I have a string which can be: "3>a" or "13>a"; "4<c" or "14<c" or "e>5" or "e>15" or "6=g"; "16=g" or "h=7" or "h=17"
And I would like to put a space before and after: "<"; ">"; "="
The goal: "3 < a" or "13 > a" or "4 < c" or "14 < c" or "e > 5" or "e > 15" or "6 = g" or "16 = g" or "h = 7" or "h = 17"
How to do ? Thank you for.
|
|
|
mid$()
Mar 14, 2023 8:56:12 GMT
Post by honky on Mar 14, 2023 8:56:12 GMT
Follow: I'am here:
a$="15<ed" for x=1 to len(a$) if mid$(a$,x,1)="<" then k$=mid$(a$,x,1): exit for end if next x print k$ h$="" for x=1 to len(a$) if mid$(a$,x,1)=k$ then h$=h$+" ": tt=x+1 end if h$=h$+mid$(a$,x,1) next x print h$ print tt 'after no work for x=tt+1 to len(a$) h$=h$+" "+mid$(a$,x,1) next x print h$
|
|
|
mid$()
Mar 14, 2023 9:05:53 GMT
Post by honky on Mar 14, 2023 9:05:53 GMT
Where does the superfluous final "d" come from ?
|
|
|
mid$()
Mar 14, 2023 9:06:30 GMT
Post by tsh73 on Mar 14, 2023 9:06:30 GMT
3>a 3 > a 13>a 13 > a 4<c 4 < c 14<c 14 < c e>5 e > 5 e>15 e > 15 6=g 6 = g 16=g 16 = g h=7 h = 7 h=17 h = 17
data "3>a" , "13>a" , "4<c" , "14<c" , "e>5" , "e>15" , "6=g", "16=g" , "h=7" , "h=17", "XYZZY"
read a$ do print a$, res$="" for i = 1 to len(a$) c$=mid$(a$,i,1) if instr("<>=", c$) then res$=res$+" "+c$+" " else res$=res$+c$ end if next print res$ read a$ loop until a$="XYZZY"
|
|
|
mid$()
Mar 14, 2023 9:57:29 GMT
Post by honky on Mar 14, 2023 9:57:29 GMT
Wow wow wow !! Alien procedure, but it works. Cheer !!! And thank you.
|
|
|
mid$()
Mar 14, 2023 10:01:11 GMT
Post by honky on Mar 14, 2023 10:01:11 GMT
Follow: But my strings are in an array; I will try to do this on a loop. If I don't make it, I'll come back.
|
|
|
mid$()
Mar 14, 2023 10:27:20 GMT
Post by honky on Mar 14, 2023 10:27:20 GMT
Follow: Misery ! I'm trapped by: "loop until a$="XYZZY". Help aliens!!
ad$="3>a 13>a 4<c 14<c e>5 e>15 6=g 16=g h=7 h=17" dim a$(20) for x= 1 to 10 a$(x)=word$(ad$,x) next x
|
|
|
mid$()
Mar 14, 2023 10:32:50 GMT
Post by honky on Mar 14, 2023 10:32:50 GMT
Follow: Nailed it ! Thanks again ad$="3>a 13>a 4<c 14<c e>5 e>15 6=g 16=g h=7 h=17" dim a$(20) for x= 1 to 10 a$(x)=word$(ad$,x) next x for x=1 to 10 res$="" for i = 1 to len(a$(x)) c$=mid$(a$(x),i,1) if instr("<>=", c$) then res$=res$+" "+c$+" " else res$=res$+c$ end if next i a$(x)=res$ print a$(x) next x
|
|