text?

Just starting out? Need help? Post your questions and find answers here.
spioner
User
User
Posts: 25
Joined: Tue Nov 07, 2006 8:02 am
Location: russia

text?

Post by spioner »

del
Last edited by spioner on Wed Dec 21, 2011 5:26 pm, edited 1 time in total.
Dare
Addict
Addict
Posts: 1965
Joined: Mon May 29, 2006 1:01 am
Location: Outback

Post 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.
Dare2 cut down to size
spioner
User
User
Posts: 25
Joined: Tue Nov 07, 2006 8:02 am
Location: russia

Again too most...

Post by spioner »

del
Last edited by spioner on Wed Dec 21, 2011 5:26 pm, edited 1 time in total.
traumatic
PureBasic Expert
PureBasic Expert
Posts: 1661
Joined: Sun Apr 27, 2003 4:41 pm
Location: Germany
Contact:

Re: Again too most...

Post 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.
Good programmers don't comment their code. It was hard to write, should be hard to read.
spioner
User
User
Posts: 25
Joined: Tue Nov 07, 2006 8:02 am
Location: russia

Post by spioner »

del
Last edited by spioner on Wed Dec 21, 2011 5:27 pm, edited 1 time in total.
traumatic
PureBasic Expert
PureBasic Expert
Posts: 1661
Joined: Sun Apr 27, 2003 4:41 pm
Location: Germany
Contact:

Re: Again too most...

Post by traumatic »

You're welcome
Good programmers don't comment their code. It was hard to write, should be hard to read.
Dare
Addict
Addict
Posts: 1965
Joined: Mon May 29, 2006 1:01 am
Location: Outback

Post by Dare »

Dare2 cut down to size
spioner
User
User
Posts: 25
Joined: Tue Nov 07, 2006 8:02 am
Location: russia

11

Post by spioner »

del
Last edited by spioner on Wed Dec 21, 2011 5:28 pm, edited 1 time in total.
traumatic
PureBasic Expert
PureBasic Expert
Posts: 1661
Joined: Sun Apr 27, 2003 4:41 pm
Location: Germany
Contact:

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

Post by traumatic »

spioner wrote:Particularly note "traumatic".
:lol:

didn't mean to be rude, never mind! :)
Good programmers don't comment their code. It was hard to write, should be hard to read.
spioner
User
User
Posts: 25
Joined: Tue Nov 07, 2006 8:02 am
Location: russia

del

Post by spioner »

del
Last edited by spioner on Wed Dec 21, 2011 5:28 pm, edited 1 time in total.
ricardo
Addict
Addict
Posts: 2438
Joined: Fri Apr 25, 2003 7:06 pm
Location: Argentina

Re: Again too most...

Post 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.
traumatic
PureBasic Expert
PureBasic Expert
Posts: 1661
Joined: Sun Apr 27, 2003 4:41 pm
Location: Germany
Contact:

Re: Maybe i false?

Post by traumatic »

spioner, you didn't offend anyone, everything's ok, really!
Good programmers don't comment their code. It was hard to write, should be hard to read.
Dare
Addict
Addict
Posts: 1965
Joined: Mon May 29, 2006 1:01 am
Location: Outback

Post by Dare »

:D
Dare2 cut down to size
lexvictory
Addict
Addict
Posts: 1027
Joined: Sun May 15, 2005 5:15 am
Location: Australia
Contact:

Re: Maybe i false?

Post by lexvictory »

spioner wrote: I am not very well English.
вы поймете нас более лучше если мы пытаемся поговорить русского?
Demonio Ardente

Currently managing Linux & OS X Tailbite
OS X TailBite now up to date with Windows!
spioner
User
User
Posts: 25
Joined: Tue Nov 07, 2006 8:02 am
Location: russia

del

Post by spioner »

del
Last edited by spioner on Wed Dec 21, 2011 5:29 pm, edited 1 time in total.
Post Reply