Posted: 8th Feb 2003 1:21
oops, i forgot the code

+ Code Snippet
wordmax = 200
dim wordlist$(wordmax)

do
c=0
print "Welcome to the learning AI program!"
print "Please choose one:"
print "1.Teach"
print "2.Learn"
input ">>",choose
if choose=1
print "Ok, teach me!"
print "Please put your sentence in this format:"
print "The [noun] is [adjective]."
input ">>",str$

lastword = ReadWords(str$,"")
lastword = ReadWords(str$,".")

open to write 1,"data.txt"

sync
for t=0 to wordmax
if c=1 then write string 1,wordlist$(t) : c=0
if c=2 then write string 1,wordlist$(t) : c=0
if wordlist$(t)="The" then c=1
if wordlist$(t)="is" then c=2
next t
close file 1
cls
endif
if choose=2
cls
print "Ok, I will teach you!"
print "Reading data..."
m=0

do
inc m
open to read 1,"data.txt"
read string 1,noun$
dim noun$(f)
read string 1,adjective$
dim adjective$(f)
if noun$(f)="" or adjective$(f)="" then exit
loop
for a=1 to m/2
print "The ",noun$(a)," is ",adjective$(m),", and the",noun$(a+1)," is ",adjective$(a+1),"."
next a

endif
loop
end


function ReadWords(s$, filter$)
  rem --- s$ = string to be processed
  rem --- filter$ = characters to be removed

  for i = 0 to wordmax : wordlist$(i)="" : next i

  ln = len(s$) : if ln = 0 then exitfunction 0
  lf = len(filter$)
  wrd$ = "" : pos = 0

  index = -1
  repeat
    inc pos,1
    lett$ = mid$(s$,pos)

    if lett$ = " " or pos > ln
      if wrd$<>""
        index = index + 1
        wordlist$(index) = wrd$
        wrd$=""
      endif
    else
      filt = 0
      for f = 1 to lf
        if mid$(filter$,f) = lett$ then filt = 1
      next f
      if filt = 0 then wrd$ = wrd$ + lett$
    endif

  until pos > ln

endfunction index
Posted: 22nd Jun 2003 21:53
Unfortunetly this piece of code only works when you disable

`Sync On
`Sync Rate 30
`backdrop on
`color backdrop rgb(0, 0, 20)

any one know the reason why? any work arounds?

I am going to start disabling and enabligh this settings before i write the text but i dont think it will work...
Posted: 22nd Jun 2003 22:03
Nope it is not as simple as that!

if you do:

Function wordwrap(s$)
sync off
backdrop off

backdrop on
sync on
endFunction

will go in once and it will get stuck there... It is a tricky one this...
Posted: 23rd Jun 2003 20:24
Hey, easily confused, don't write it 1000, just infinitie, this way you can leave it.

DO
Print "I will not interfere with other people's posts"
LOOP

K?
Posted: 23rd Jun 2003 20:46
or, for 1000 u could do

for A# = 1 to 1000
do
print "I will not interfere with other people's posts"
next A#
if A# = 1000 then exit
loop

lol!!!
Posted: 24th Jun 2003 20:37
did you try running that code mattman???you get an error
try
for a=1 to 1000
print "i will not not interfere with other people's posts"
next a
Posted: 3rd Jul 2003 9:55
Hey,

Could someone post a word wrap which would be suitable for text boxes in RPG's or chats etc.

I have tried myself and almost got it working but when i tried to implement it in my program its driving me crazy beacause of a number of reasons. So if anyone would post an effiant way of doing this it would be much appreciated.

THanx
Nick
Posted: 4th Jul 2003 19:00
Here's my old word wrap solution, but for some reason it only works in DB classic.
Posted: 4th Jul 2003 20:12
Okay, this source box has the same thing only for DB Pro. Apparently they handle variable values in functions differently. Also, it seems the default text height was 16 in DBC and is only 15 in DBP.
Posted: 11th Jul 2003 9:22
cool, im sure that will help alot of people inthe future,.

Drum
nick
Posted: 12th Jul 2003 1:08
Man two of my old posts are back from the dead. Yikes! Ya my code was pretty crappy - took only a few minutes lol Asheron has done some pretty good RPG word wraps over at RGT.

RPGamer