Got an idea for enhancing PureBasic? New command(s) you'd like to see?
bembulak
Enthusiast
Posts: 575 Joined: Mon Mar 06, 2006 3:53 pm
Location: Austria
Post
by bembulak » Tue Dec 18, 2007 8:31 am
Sometimes I think something like this would come very handy:
Code: Select all
For i.s = "a" To "z"
; do anything
Next
For j.s = "A" To "Z"
; do something other
Next
This would enhance some string operations, I think. Seen it sometimes in other languages (ObjectPascal and Python, eg) and it's neat.
cheers,
bembulak
remi_meier
Enthusiast
Posts: 468 Joined: Sat Dec 20, 2003 6:19 pm
Location: Switzerland
Post
by remi_meier » Tue Dec 18, 2007 8:41 am
I don't understand what you're doing.
Do you want something like that:
Code: Select all
Structure chars
c.c[0]
EndStructure
s.s = "hallo"
len.l = Len(s)
*p.chars = @s
For z = 0 To len - 1
Debug Chr(*p\c[z])
Next
Your syntax proposal isn't clear to me..
Or do you want something like this:
Code: Select all
For z = 'a' To 'z'
Debug Chr(z)
Next
Athlon64 3700+, 1024MB Ram, Radeon X1600
bembulak
Enthusiast
Posts: 575 Joined: Mon Mar 06, 2006 3:53 pm
Location: Austria
Post
by bembulak » Tue Dec 18, 2007 10:30 am
Or do you want something like this:
Code:
For z = 'a' To 'z'
Debug Chr(z)
Next
Yeah, that one.
Just the way ObjectPascal and Python do it.
cheers,
bembulak
Trond
Always Here
Posts: 7446 Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway
Post
by Trond » Tue Dec 18, 2007 2:58 pm
bembulak wrote: Or do you want something like this:
Code:
Code: Select all
For z = 'a' To 'z'
Debug Chr(z)
Next
Yeah, that one.
Just the way ObjectPascal and Python do it.
Did you try to run that code?
Dare
Addict
Posts: 1965 Joined: Mon May 29, 2006 1:01 am
Location: Outback
Post
by Dare » Tue Dec 18, 2007 3:07 pm
Trond wrote: Did you try to run that code?
Okay, you got me curious. It looks okay and it works here. Produces "a" through to "z".
What have you spotted?
Dare2 cut down to size
Trond
Always Here
Posts: 7446 Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway
Post
by Trond » Tue Dec 18, 2007 3:10 pm
Just that he requests something that is implemented, and probably didn't notice.
traumatic
PureBasic Expert
Posts: 1661 Joined: Sun Apr 27, 2003 4:41 pm
Location: Germany
Contact:
Post
by traumatic » Tue Dec 18, 2007 3:20 pm
just like christmas...
Good programmers don't comment their code. It was hard to write, should be hard to read.
Dare
Addict
Posts: 1965 Joined: Mon May 29, 2006 1:01 am
Location: Outback
Post
by Dare » Tue Dec 18, 2007 3:27 pm
traumatic wrote: just like christmas...
Trond wrote: Just that he requests something that is implemented, and probably didn't notice.
Ah, I see. I just thought maybe you had unearthed something unexpected.
Mind you the requested looping option was all strings: For i.s = "A" to "Z" so I guess there was a difference.
I'm not sweating on whether this one is implemented.
Dare2 cut down to size
Trond
Always Here
Posts: 7446 Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway
Post
by Trond » Tue Dec 18, 2007 4:44 pm
The topic title said characters.
Mistrel
Addict
Posts: 3415 Joined: Sat Jun 30, 2007 8:04 pm
Post
by Mistrel » Tue Dec 18, 2007 7:28 pm
I didn't know you could do that!
In the past I've done something like this:
Code: Select all
#LCase=abcdefghijklmnopqrstuvwxyz
#UCase=ABCDEFGHIJKLMNOPQRSTUVWXYZ
For i=1 To Len(#LCase)
If somevar.s=Mid(#LCase,i,1)
; do something
Break
EndIf
Next i
bembulak
Enthusiast
Posts: 575 Joined: Mon Mar 06, 2006 3:53 pm
Location: Austria
Post
by bembulak » Tue Jan 15, 2008 10:57 pm
I didn't know you could do that!
I didn't too!
I really did not now, that
will work, since you're passing 'a', .. on to the variable z, which is an integer value.
The code I tried to do, was for
i.s = 'a'...
What a bad mistake.
Shame on me...
cheers,
bembulak