[Implemented] Unlimited Separator$ length @ StringField()

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

> you forgot to protect the variable

Where, in my code, is string$ already declared as a global? :twisted:
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

PB wrote:> you forgot to protect the variable

Where, in my code, is string$ already declared as a global? :twisted:
Do I have to remind you of my signature? :twisted: :twisted: :twisted:
AND51
Addict
Addict
Posts: 1040
Joined: Sun Oct 15, 2006 8:56 pm
Location: Germany
Contact:

Post by AND51 »

I'm sorry and you're right. 'string$' is already protected, but when I postet my post, I didn't think about this. Sorry again! :?
PB 4.30

Code: Select all

onErrorGoto(?Fred)
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

AND51 wrote:I'm sorry and you're right. 'string$' is already protected, but when I postet my post, I didn't think about this. Sorry again! :?
Neither did I....
AND51
Addict
Addict
Posts: 1040
Joined: Sun Oct 15, 2006 8:56 pm
Location: Germany
Contact:

Post by AND51 »

However, my solution is fasteer, cause I don't save the returning value from ReplaceString() into 'string$#, but I put it directly into StringField().

:idea: This makes the whole procedure a 'one-liner'. With one line of code, you can also make a MACRO of it to increase performance!!!! :wink:
PB 4.30

Code: Select all

onErrorGoto(?Fred)
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

Whatever code I post is standalone and works. There is no need to protect
the variable at all if no global variable of the same name exists in the code.

And quite frankly, I never protect my variables at all because I know which
variables my apps use and which are global and which are not, because I
am in 100% control of my coding and don't need compiler "protection". :twisted:

(Side-note: I just noticed my example was almost exactly the same as
something netmaestro posted on 9 May 2006 -- it was NOT stolen code,
I assure you).
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

Image

Come. Ve haff VAYS uff makink you talk.. Vere did you gotted dat code? VERE?
BERESHEIT
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

I got the code here:

Image

:)
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
AND51
Addict
Addict
Posts: 1040
Joined: Sun Oct 15, 2006 8:56 pm
Location: Germany
Contact:

Post by AND51 »

Please, don't let this forum thread turn into an off-topic thread! I really want this feature in the next version as many other people want this, too!
PB 4.30

Code: Select all

onErrorGoto(?Fred)
Dr. Dri
Enthusiast
Enthusiast
Posts: 243
Joined: Sat Aug 23, 2003 6:45 pm

Post by Dr. Dri »

maybe something like this :

StringField(String$, Index, Separator.l)

if you don't send a value within the character range (depending on ascii or unicode) then it will be interpreted as a string address.

Code: Select all

Debug StringField("Pure Basic", 1, ' ')
Debug StringField("PureStringBasic", 2, @"String")

output:
Pure
Basic
That's how windows resource functions work, if you want the resource #12 you can send 12 or "12"

Dri
DarkDragon
Addict
Addict
Posts: 2344
Joined: Mon Jun 02, 2003 9:16 am
Location: Germany
Contact:

Post by DarkDragon »

Dr. Dri wrote:maybe something like this :

StringField(String$, Index, Separator.l)

if you don't send a value within the character range (depending on ascii or unicode) then it will be interpreted as a string address.

Code: Select all

Debug StringField("Pure Basic", 1, ' ')
Debug StringField("PureStringBasic", 2, @"String")

output:
Pure
Basic
That's how windows resource functions work, if you want the resource #12 you can send 12 or "12"

Dri
You can't detect the size ;-) .
bye,
Daniel
Dr. Dri
Enthusiast
Enthusiast
Posts: 243
Joined: Sat Aug 23, 2003 6:45 pm

Post by Dr. Dri »

you don't understand what i mean...

make a resource file with this code :

Code: Select all

12 bitmap your_image.bmp
make a pb file with this code :

Code: Select all

If OpenWindow(0, 0, 0, 245, 105, "ImageGadget")
  CreateGadgetList(WindowID(0))
  
  ImageGadget(0,  10, 10, 100, 83, LoadBitmap_(GetModuleHandle_(#Null), 12))
  ImageGadget(1, 130, 10, 100, 83, LoadBitmap_(GetModuleHandle_(#Null), "#12"))
  
  Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
if you run this code you'll get twice the same image!

LoadBitmap_ is called once with an INTEGER and then with a STRING
as string are addresses, they are sent like integers
so if the resource number is too high then it will be interpreted as a string address

so if it works for resources it should be possible to do this for StringField

Dri
Post Reply