_TITLE "POET ASSISTENT V-3-1" 'b+ mod fix get more substitutions for same or different keywords altering as go
' Globals seen inside SUBs and FUNCTIONs because SHARED
'VVVV REDIM means dynamic arrays, so can change at setup
setup '<<< sets a Global topKeyIndex so have to run this to DIM local variables that use topKeyindex
' list local variables under global so bplus doesn't have to look all over for them
' Locals for main code only, can only be seen in main code section
DIM lastReply
(1 TO topKeyIndex
) AS INTEGER ' NEW save the lastReply place we made\
'start main code except "setup" already called
INPUT "(q quits) enter text: ", text$
'<<< B+ added q note because user doesn't know this PRINT "output text:-----"
split replys(i), myList$()
IF lastReply
(i
) = 0 THEN lastReply
(i
) = 1 ELSE lastReply
(i
) = lastReply
(i
) + 1 IF lastReply
(i
) > replyCount
(i
) THEN lastReply
(i
) = 1 Replace text$, keywords(i), myList$(lastReply(i)) '<<<<changed this 'myList$(INT(RND * UBOUND(mylist$) + 1)) B+ changed it some more
'B+ get out of here after we replace one keyword !!!!!! otherwise things get too complicted
'EXIT FOR ' <<<<<<<<<<<<< B+
WEND ' AND IT DOSEN'T WORK AS EXPECTED :( B+ NOW IT DOES :D
DIM d
(1 TO 10) AS STRING 'this is local to sub, not sharing anywhere else d(1) = "sun =at high noon ,happy like the fish ,sadness falls on me ,when we were young ,summer promissed us eternity "
d(2) = "mom =i love you mother ,my happiness is to see you smile ,the woman that gave me life "
d(3) = "sea =the place of eternal bliss ,to cross you like a ship over the ocean ,swim in the sun "
d(4) = "family =i still think of you ,you are in my heart forever ,i shell always be greatful "
d(5) = "cat =i called you mine but you were free ,winter's nights we used to cuttle "
d(6) = "moon =you are magic to me ,king of the night ,our closest planet "
d(7) = "love =that whitch is divine in us ,god's flower ,the most inportent thing "
d(8) = "hate =do not waste your time on resentments ,let it pass... let go of it "
d(9) = "sorrow =do not cry for yesterday ,we all suffer but love always return in new forms "
d(10) = "life =the gift of love ,cherished and sacrat ,everyday's anigma "
'local variables to sub
topKeyIndex = 10
REDIM keywords
(1 TO topKeyIndex
), replys
(1 TO topKeyIndex
), replyCount
(1 TO topKeyIndex
) FOR i
= 1 TO topKeyIndex
'load keywords and replies keywords(i) = leftOf$(d(i), "=")
replys(i) = rightOf$(d(i), "=")
'B+ count commas and add 1
count = 0
IF MID$(replys
(i
), j
, 1) = "," THEN count
= count
+ 1 replyCount(i) = count + 1 'number of replies = number of commas + 1
'design a tool box sub routine for splitting comma delimited strings
SUB split
(myCommaLoadedString$
, myListArray$
()) REDIM myListArray$
(LBOUND(mylistarray$
) TO LBOUND(mylistarray$
)) ' replyCouter(1 TO topKeyIndex)
first$ = leftOf$(myCommaLoadedString$, ",")
myListArray$
(LBOUND(mylistarray$
)) = first$
tail$ = rightOf$(myCommaLoadedString$, ",")
first$ = leftOf$(tail$, ",")
sAppend myListArray$(), first$
tail$ = rightOf$(tail$, ",")
sAppend myListArray$(), tail$
'find sAppend toolbox code and paste below, need it to add a string to and array
'append to the string array the string item
' B+ BIG CHANGE HERE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
'just do replace once!! To avoid unexpected results B+ edited all the extra finding
SUB Replace
(text$
, old$
, new$
) 'can also be used as a SUB without the count assignment find
= INSTR(text$
, old$
) 'find location of a word in text first$
= LEFT$(text$
, find
- 1) 'text before word including spaces last$
= RIGHT$(text$
, LEN(text$
) - (find
+ LEN(old$
) - 1)) 'text after word text$ = first$ + new$ + last$
'SUB Replace (text$, old$, new$) 'can also be used as a SUB without the count assignment
' DIM find, start, count, last$, first$
' DO
' find = INSTR(start + 1, text$, old$) 'find location of a word in text
' IF find THEN
' count = count + 1
' first$ = LEFT$(text$, find - 1) 'text before word including spaces
' last$ = RIGHT$(text$, LEN(text$) - (find + LEN(old$) - 1)) 'text after word
' text$ = first$ + new$ + last$
' END IF
' start = find
' LOOP WHILE find
' 'Replace = count 'function returns the number of replaced words. Comment out in SUB
'END SUB