Some features i (will) need

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
TazNormand
User
User
Posts: 27
Joined: Tue May 26, 2009 3:17 pm
Location: France

Some features i (will) need

Post by TazNormand »

Hi,

1st of all, thanks PB Team for this great language.

2nd : Excuse my very bad english : i'm a french guy with school english level.

3rd : the requests

1° few days ago, i needed a function to format number/string. can you add a VB Like "Format" function : str$=Format(string/Number,Format)
Formats same as VB : #,@,0,-,+ like this :
str$=Format("123456","##_##_##)
display str$ gives 12_34_56

2° GrabSprite on a sprite, not only on a screen
GrabSpritetoSprite(SpriteSource,SpriteDestination,X,Y,Width,Height,[Mode]) mode same as createsprite() ones.

3° ClipSprite3D, i know there is a code in the forum to do that, but an integrated fuction would be great

4° Iif function ; Iif(test>100;"Great !!!";"Loser !!!")
No Else/endif in the code to test only one condition

5° a Boolean type, instead of using integer types

6° A stop command when we are in debugger on, to stop program at the moment where we have put the stop (ability to use F8 for step by step after the stop

nothing else for the moment, i'll add posts after this one if i have other ideas

thanks for reading, and giving positive critics
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post by Kaeru Gaman »

1° easy to solve, why not programming it yourself?

2° UseBuffer(#SpriteNr)

3° obsolete

4° not BASIC

5° Booleans are always full-register integers, in every language.

6° you can use breakpoints...?
oh... and have a nice day.
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: Some features i (will) need

Post by PB »

#1 and #4 have examples in these forums (search for them), and #6 is just
the CallDebugger command. Welcome to PureBasic.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Post by rsts »

Hi,

Welcome to the PureBasic forums.

There have been fairly recent discussions of IIF, you can probaby search and find some very nice suggested alternatives.

There is an xmask by xombie.

You might take a look at these.

http://www.purebasic.fr/english/viewtop ... hlight=iif

http://www.purebasic.fr/english/viewtop ... ight=xmask

cheers,
User avatar
TazNormand
User
User
Posts: 27
Joined: Tue May 26, 2009 3:17 pm
Location: France

Post by TazNormand »

Thanks for your answers m8

for the grabsprite on a sprite, i can confirm that use buffer doesn't work.

i've tried this code with no success, look at this thread is french forum :
http://www.purebasic.fr/french/viewtopi ... 482#101482

I know that Iif is not Basic, and there are many examples in the forum, but why not make PB evolve a little bit ???

I just suggest to add natively these features, i know all is possible when you want it. correct me if i'm wrong but is there a english proverb which say "Impossible is not English" ? french people have translated it too ;-)

@rsts : thanks for links, i'll see

EDIT : UseBuffer works very well, it was a wrong usage from me. i've just tested now, thanks Kaeru Gaman

code i used :

Code: Select all

Procedure BMFont()  ; Définit la police Bitmap (sprites 1 à 42)
	  ; charger la police bitmap, et en extraire les caractères	  
	    font=CatchImage(0,?font)	    
	    If font
  		  p=CreateSprite(70,728*2,46*2,#PB_Sprite_Memory)  ; Créer un sprite "géant" pour en extraire les sprites caractères  		  
		    StartDrawing(SpriteOutput(70))
    			DrawImage(font,0,0) ; Dessiner image sur le sprite 1
		    StopDrawing()	
		    TransparentSpriteColor(70,RGB(0,240,0))	  
		      
		    ; Extraction des caractères (1 seule ligne de 43 caractères )
		    ; On lit la datasection FontWidths pour les tailles variables de caractères		    
		    Restore FontWidths
		    Repeat
		      Read wdth
		      If wdth>0
		        ; Créer le sprite correspondant au caractère de la police
		          pp=CreateSprite(Car,wdth*2,46*2,#PB_Sprite_Memory)
		          
		        ; Sélectionner le caractère qui nous intéresse sur le Sprite global de la police
		          res=ClipSprite(70,X_Depart,0,wdth*2,46*2)		          
		          
		      	; Le buffer n'est plus l'écran mais le sprite que l'on va créer
		          UseBuffer(70)
	          
		         ; Grabber le sprite Caractère
		           res2=GrabSprite(Car,X_Depart,0,wdth*2,43*2,#PB_Sprite_Memory)
		           
		         ; Transparence du sprite caractère
		           TransparentSpriteColor(car,RGB(0,240,0))
		           
				    Car+1 ; Caractère suivant
				    X_Depart+(Wdth*2) ; Décaler position dans image BitMap de la largeur précédemment lue
				  EndIf
		    Until wdth=0   ; Tant qu'il y a des données à "lire" en datas
		    UseBuffer(#PB_Default)
		  EndIf
	EndProcedure
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post by Kaeru Gaman »

you can also do it the other way round:
create a new sprite, do UseBuffer on this one and display the bigger sprite over it.
same you can do with images and drawing.
oh... and have a nice day.
Post Reply