|
Post by tenochtitlanuk on Feb 21, 2019 20:10:52 GMT
|
|
|
Post by danuthorincas on Feb 21, 2019 20:19:20 GMT
Thank but firt code are not complete
|
|
|
Post by tenochtitlanuk on Feb 21, 2019 20:56:56 GMT
Sorry. Forgot to replace '<' symbols in the html code with html equivalent.. Should be OK now..
|
|
|
Post by tenochtitlanuk on Feb 22, 2019 21:44:36 GMT
A simpler version of the shuffle.. a function to generate a 'pack' of stated numbers of required 'cards' and one to deal them all randomly, ie shuffled.
myString$ =definedString$( "3 10 A 20 B 70 C")
print myString$ print ""
for i =1 to 20 myString$ =shuffle$( myString$) print myString$ next i
wait
function definedString$( i$) ' tekes number of terms, numOfFirstChars, firstChar, etc... terms =val( word$( i$, 1, " ")) for j =2 to 1 +2 *terms step 2 num =val( word$( i$, j, " ")) ch$ =word$( i$, j +1, " ") for k =1 to num definedString$ =definedString$ +ch$ next k next j end function
function shuffle$( i$) ' takes a string and shuffles it for m =1 to len( i$) r =1 +int( len( i$) *rnd( 1)) shuffle$ =shuffle$ +mid$( i$, r, 1) i$ =left$( i$, r -1) +mid$( i$, r +1) next m end function
|
|
|
Post by B+ on Feb 23, 2019 16:28:16 GMT
Hey John, I like your definedString$ function. It's like overloading a function by putting all the parameter arguments into a string, a clever way to add any amount needed.
|
|
|
Post by tsh73 on Feb 23, 2019 18:59:33 GMT
especially since JB does not allow variable number of function arguments.
and one could circumvent "arrays could not be passed in a function" restriction, if speed is enough.
|
|
|
Post by tenochtitlanuk on Feb 24, 2019 10:05:01 GMT
I've used this technique quite often for exactly these reasons. For example a single string parameter can hold the x,y vertices of a polygon with any chosen number of sides. See link
|
|