RFindString()
RFindString()
search from the end of the string backwards...
equivalents in gfa: instr() and rinstr()
equivalents in gfa: instr() and rinstr()
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
( The path to enlightenment and the PureBasic Survival Guide right here... )
oh well, let's simply code it for now... 

Code: Select all
Procedure.l x_countchar(string.s,char.s)
Protected n.l , p.l , l.l
;
; *** counts occurances of character in string
;
n.l = 0
p.l = 0
l.l = Len(string)
While p < l
INC p
If Mid(string,p,1) = char
INC n
EndIf
Wend
ProcedureReturn n
EndProcedure
Procedure.l x_rfindstring(string.s,find.s)
Protected l.l , p.l
;
; *** find a string in another string, starting from the right
;
l.l = Len(find.s)
p.l = Len(string.s)
If l > 0 And p > 0
p = p+l
Repeat
DEC p
Until p.l = 0 Or Mid(string,p,l) = find
EndIf
ProcedureReturn p
EndProcedure
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
( The path to enlightenment and the PureBasic Survival Guide right here... )
- Psychophanta
- Always Here
- Posts: 5153
- Joined: Wed Jun 11, 2003 9:33 pm
- Location: Anare
- Contact:

Just you have bring to my mind a new idea.
I'll make a function in assembler for to perform equivalents in gfa: rinstr().
I will name it: RFindString(). LFindString() already exists, its name is FindString()
And by the way you can find CountChars() and CountStrings() functions made by me in assembler in www.purearea.net.
You know, you could take it and make a PB userlibrary with all those 3 functions, will you be able to do?

- Psychophanta
- Always Here
- Posts: 5153
- Joined: Wed Jun 11, 2003 9:33 pm
- Location: Anare
- Contact:
fred, that's an old habit of using gfabasic, it had the following basic commands:
inc a
a += 1
add a , 1
old habits are difficult to kill... will it affect code, as compared to a = a + 1?
psycho, are you sure your countstrings asm function works correctly? i tried it here and got the wrong answer...
currently i'm just dumping my functions in a file, and add x_ to every function name, so fred can update what he wants, and it won't cause me troubles
i always peek into the libraries to see what i can use, but often end up coding something myself... good excercise
but ehm... fred, will rfindstring also show up? or?
inc a
a += 1
add a , 1
old habits are difficult to kill... will it affect code, as compared to a = a + 1?
psycho, are you sure your countstrings asm function works correctly? i tried it here and got the wrong answer...
currently i'm just dumping my functions in a file, and add x_ to every function name, so fred can update what he wants, and it won't cause me troubles

i always peek into the libraries to see what i can use, but often end up coding something myself... good excercise

( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
( The path to enlightenment and the PureBasic Survival Guide right here... )
readability, my dear man, readability... for some strange reason my mind can *see* basic code, yet perceives c(++) as something foggy, in other words: i have to look at basic to understand it, i have to puzzle to understand c... i have a similar thing with object oriented programming...
and inc c just *looks* better to me than c+=1 or c = c + 1
ah, forgot a variation, gfa also allowed c++

and inc c just *looks* better to me than c+=1 or c = c + 1
ah, forgot a variation, gfa also allowed c++

Last edited by blueznl on Mon Jan 16, 2006 8:39 am, edited 1 time in total.
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
( The path to enlightenment and the PureBasic Survival Guide right here... )
Fred wanted to say that it is not necesary write
you can write simply
Code: Select all
p = p+1
Code: Select all
p+1
p+5
p+100
[:: PB Registered ::]
Win10 Intel core i5-3330 8GB RAM Nvidia GTX 1050Ti
Win10 Intel core i5-3330 8GB RAM Nvidia GTX 1050Ti
ooops 

( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
( The path to enlightenment and the PureBasic Survival Guide right here... )
- Psychophanta
- Always Here
- Posts: 5153
- Joined: Wed Jun 11, 2003 9:33 pm
- Location: Anare
- Contact:
Fred wrote:

Don't worry, if i make a PB userlib, then i'll rename functions with a prefix, for example "al", but for normal Procedure names, user can name it as is wanted.Psychophanta: may be you could use name less 'common' for your addon functions because some of them (especially CountString()) will be in a next version and it will invalidate your lib.. Just a tough.


-
- Enthusiast
- Posts: 613
- Joined: Tue May 06, 2003 2:50 pm
- Location: Germany
- Contact:
try dutch for a change
si tu veux, mon ami fred, c'est possible de continuer en francais, mais je te dit, ma connaisance de la langue francais... c'est... le mot propre c'est 'corrode' je pense?
damn, forgot most of my french, i've been working for one and a half year in paris, almost a decade back, and at that time it wasn't a problem at all... hell, i even started swearing at all those bloody foreigners behaving like tourists when using the peripherique
si tu veux, mon ami fred, c'est possible de continuer en francais, mais je te dit, ma connaisance de la langue francais... c'est... le mot propre c'est 'corrode' je pense?
damn, forgot most of my french, i've been working for one and a half year in paris, almost a decade back, and at that time it wasn't a problem at all... hell, i even started swearing at all those bloody foreigners behaving like tourists when using the peripherique

( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
( The path to enlightenment and the PureBasic Survival Guide right here... )