Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
convert into list
#1
hello

i need your help again, so thank you in advance

i have a string, say for example

str s="r1bqk2r/pppp1ppp/2n2n2/2b1p3/2P1P3/2NP4/PP3PPP/R1BQKBNR w KQkq -"

In my mind, it means I have 8 strings of 8 characters, because in my example a number like 2 mean 2 zeros (00), 3 mean 3 zeros (000) and so on, and i need to take care of MAJ and min characters; so i would like , with my example, define 8 strings and have:

s1="r0bqk00r"
s2="pppp0ppp"
s3="00n00n00"
s4="00b0p000"
s5="00P0P000"
s6="00NP0000"
s7="PP000PPP"
s8="R0BQKBNR"


ps: my string s will ALWAYS be like this : 8 parts separated with "/" , each part meaning 8 characters (letters MAJ and min and zeros 0)

Then, having these 8 strings s1,...,s8, i want to replace every MAJ characters with 1 and every min characters with 2, so with my example i need to have 8 new strings

t1="20222002"
t2="22220222"
t3="00200200"
t4="00202000"
t5="00101000"
t6="00110000"
t7="11000111"
t8="10111111"

Lot of thanks!
#2
Code:
Copy      Help
dll msvcrt #isdigit char
dll msvcrt #isupper char
dll msvcrt #isalpha char

str s="r1bqk2r/pppp1ppp/2n2n2/2b1p3/2P1P3/2NP4/PP3PPP/R1BQKBNR w KQkq -"
str ss
int i c
for i 0 s.len
,c=s[i]
,if(isdigit(c)) ss.set('0' ss.len c-'0')
,else if(isupper(c)) ss+"1"
,else if(isalpha(c)) ss+"2"
,else ss.geta(s i 1)

ARRAY(str) a
tok(ss a -1 "/")
for i 0 a.len
,out a[i]
#3
very nice, you did it in less than 5 minutes while I will do that in 1 hour or more....

its incredible!

i ask you something easy now:

i would like to change

str s="r1bqk2r/pppp1ppp/2n2n2/2b1p3/2P1P3/2NP4/PP3PPP/R1BQKBNR w KQkq -"


into s=""r1bqk2r/pppp1ppp/2n2n2/2b1p3/2P1P3/2NP4/PP3PPP/R1BQKBNR"

I mean i want to delete all after the "8 parts" if you see what i mean!



the problem (for me) is that s.len is not constant: for example with another example,
if s="r1bqk2r/pppp1ppp/2n2n2/2b1p3/2P1P3/2NP4/PP3PPP/7R w KQkq -" , i want to stop after 7R (7 means 7 zeros : so 7R is 0000000R) so i need to get s="r1bqk2r/pppp1ppp/2n2n2/2b1p3/2P1P3/2NP4/PP3PPP/7R" in this case


ps: it s so nice to have an incredible programmer like you that explain to me (and other people) . thank you very much
#4
a[7].fix(8)

(after tok(...))
#5
rep() if(pixel(100 100)=0x800000) break; else 0.1

what is 0.1 ? time to wait before repeat?

can the rep command make my computer slow? (i mean if repeat at high frequency, it could slow other applications...) what is a good number instead of 0.1?! is 0.1 correct?
#6
i mean i want to wait until some pixel become 0x800000, what is the best command?

rep or wait?

and same question for waiting a mouse click, what is the best? rep or wait ML ?
#7
In both cases best is wait.

Checking pixel color every 0.1 s does not slow down computer. For fastest response that does not slow down computer can be used 0.01. Of course, CPU usage depends on what the macro does between waiting. You can see CPU usage in Windows Task Manager.
#8
the macro will do nothing else that waiting a pixel to change color, but i run another program that use cpu usage... so i have the macro just waiting pixel change, and another program running this time... i hope this doesnt slow the prog or the comp.... but it s ok!


Forum Jump:


Users browsing this thread: 1 Guest(s)