当前位置:网站首页>Yamaha robot splits visual strings

Yamaha robot splits visual strings

2022-06-26 05:47:00 self85

'----------------------  Visual data analysis  ----------------------------
SUB *SplitStrToPos(Source$, xTag!, yTag!, rTag!)
    pos% = 0       ' The array subscript 
    DIM sysPos!(3) ' Define array elements  sysPos!(0) ? sysPos!(3)
    FOR Index% = 1 TO LEN(Source$)
        IF MID$(Source$,Index%,1) = "," THEN
            sysPos!(pos%) = VAL(MID$(Source$,1,Index%-1))
            pos% = pos% + 1
            Source$ = MID$(Source$,Index% + 1,LEN(Source$)-Index%)
            Index% = 0
        ENDIF
    NEXT Index%
    xTag! = sysPos!(0)
    yTag! = sysPos!(1)
    rTag! = sysPos!(2)
END SUB


A simple translation

'----------------------  Visual data analysis  ----------------------------
SUB *SplitStrToPos(Source$, xTag!, yTag!, rTag!)
    ' Split the string to get the dot ( The string passed in , Got X coordinate ,Y coordinate ,RZ angle )
    pos% = 0       ' The array subscript 
    DIM sysPos!(3) ' Define array elements  sysPos!(0) ? sysPos!(3)
	' Defines a one-dimensional array , There are three elements in total ,0-2
    FOR Index% = 1 TO LEN(Source$)
	'for Cycle from 1 Start to " The total length of the string passed in "
        IF MID$(Source$,Index%,1) = "," THEN
		'MID$(Source$,Index%,1) It means in Source$ in , from Index% Start looking for , look for 1 position 
		' find "," After entering if The cycle of 
            sysPos!(pos%) = VAL(MID$(Source$,1,Index%-1))
			'sysPos Array assignment ,
			'MID$(Source$,1,Index%-1) stay Source$ In the string , Start from the first , The termination bit is found "," Count forward one digit 
            pos% = pos% + 1
			'sysPos Array subscript auto increment , Assign a value to the next loop , Corresponding to the back sysPos!(0)/sysPos!(1)/sysPos!(2)
            Source$ = MID$(Source$,Index% + 1,LEN(Source$)-Index%)
			'MID$(Source$,Index% + 1,LEN(Source$)-Index%)
			' stay Source$ In the string , From the last time I found "," The location starts to look for , Then I'll intercept all the remaining strings .
			' For example , The string passed is "25,28,36,", The first cycle will remove X Coordinates of 25,
			' then Source$ The string is now "28,36,"
			' The third time is "36,"
            Index% = 0
        ENDIF
    NEXT Index%
    xTag! = sysPos!(0)
    yTag! = sysPos!(1)
    rTag! = sysPos!(2)
END SUB
原网站

版权声明
本文为[self85]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202180505047932.html