Page 1 of 6

text?

Posted: Tue Nov 07, 2006 9:29 am
by spioner
del

Posted: Tue Nov 07, 2006 9:47 am
by Dare
Hi spioner,

Not knowing English well is going to make reading the help file difficult, but you will need read it if you want to understand how PureBasic is used.

Maybe you can find a good online translator, or maybe French or German is easier for you?

Anyhow, I will try to help, others will as well.

The 0 is an identifier. PureBasic uses these to know which file you are dealing with. So, example:

Code: Select all

OpenFile(0, "C:\Text.txt")
OpenFile(1, "C:\Text1.txt")
WriteStringN(0, "abc")
WriteStringN(1, ReplaceString("abc","a","W"))
CloseFile(0)
CloseFile(1)
This tells PureBasic to open two files identified as 0 and as 1.

It then tells PureBasic to write "abc" to file identified as 0 (text.txt) and "Wbc" to the file identified as 1 (text1.txt). So you can see that PureBasic needs the identifying number to know which file it is using when doing a file operation.

ReplaceString is a function. That means it returns a value, the result of the information (parameters) you sent it.

You can store the result in a variable:

Code: Select all

OpenFile(0, "C:\Text.txt")
result$ = ReplaceString("abc","a","W")
WriteStringN(0, result$)
CloseFile(0)
or you can use the result directly:

Code: Select all

OpenFile(0, "C:\Text.txt")
WriteStringN(0, ReplaceString("abc","a","W"))
CloseFile(0)
Not being rude, just asking so we know your level and how to answer things:

Do you understand variables and literals?
Do you understand procedures (functions)?

Hope this is useful to you.

Again too most...

Posted: Tue Nov 07, 2006 11:01 am
by spioner
del

Re: Again too most...

Posted: Tue Nov 07, 2006 11:21 am
by traumatic
You forgot to actually read-in the data...

Code: Select all

; create a file and write some random text to it
OpenFile(0, "c:\test.txt")
  For i=0 To 4200
    WriteString(0, Chr(65+Random(55)))
  Next
CloseFile(0)



; now, replace all occurences of 'x' with 'y' (case-insensitve)
OpenFile(0, "c:\test.txt")
  tmp$ = ReplaceString(ReadString(0), "x", "y", 1)
  FileSeek(0,0)
  WriteString(0,tmp$)
CloseFile(0)
This only works if everything is in one line, else you have to go through
each line in order to make the changes. Just meant to give you an idea.

Posted: Tue Nov 07, 2006 12:15 pm
by spioner
del

Re: Again too most...

Posted: Tue Nov 07, 2006 12:24 pm
by traumatic
You're welcome

Posted: Tue Nov 07, 2006 1:15 pm
by Dare

11

Posted: Tue Nov 07, 2006 2:52 pm
by spioner
del

Re: Thank you all. Now all work. Is it Much thanked all. Par

Posted: Tue Nov 07, 2006 5:24 pm
by traumatic
spioner wrote:Particularly note "traumatic".
:lol:

didn't mean to be rude, never mind! :)

del

Posted: Tue Nov 07, 2006 5:41 pm
by spioner
del

Re: Again too most...

Posted: Tue Nov 07, 2006 7:11 pm
by ricardo
spioner wrote:PureBasic the best, but very laconic Help Files. Where I can find more references ? As well as where I can find much examples ?
Here in the forum and a very good set of examples here:

http://www.purearea.net/pb/CodeArchiv/CodeArchiv.html

You need to download the archive of codes, its divided by categories. I recommend it to you.

Re: Maybe i false?

Posted: Tue Nov 07, 2006 8:40 pm
by traumatic
spioner, you didn't offend anyone, everything's ok, really!

Posted: Wed Nov 08, 2006 12:39 am
by Dare
:D

Re: Maybe i false?

Posted: Wed Nov 08, 2006 2:46 am
by lexvictory
spioner wrote: I am not very well English.
вы поймете нас более лучше если мы пытаемся поговорить русского?

del

Posted: Wed Nov 08, 2006 5:41 am
by spioner
del