Got an idea for enhancing PureBasic? New command(s) you'd like to see?
-
Leonhard
- User

- Posts: 55
- Joined: Fri Jun 16, 2006 7:43 am
Post
by Leonhard »
Wouldn't it be nice to convert types in a line with .type (.i, .c, .q, ...)?
Example:
Code: Select all
Declare var1.i
Declare var2.i
Declare result.i
result = ( (var1).f / (var2).f ).i
; --------------------------------------
Declare str1.s{12} = "Hallo, Welt!"
Declare char.c
char = (str1).c + SizeOf(Character) * 7
Debug (char).s{1}
-
Psychophanta
- Always Here

- Posts: 5153
- Joined: Wed Jun 11, 2003 9:33 pm
- Location: Anare
-
Contact:
Post
by Psychophanta »
I use simple procedures. Following your code it would be:
Code: Select all
Procedure.f iTof(a.i)
ProcedureReturn a
EndProcedure
var1.i
var2.i
result.i=(iTof(var1)/iTof(var2))
; --------------------
Procedure.c sToc(a$)
ProcedureReturn PeekC(@a$)
EndProcedure
Procedure$ cTos(a.c,l.l=0)
If l:ProcedureReturn PeekS(@a,l)
Else:ProcedureReturn PeekS(@a)
EndIf
EndProcedure
str1.s{12}="Hallo, Welt!"
char.c=sToc(str1)+SizeOf(Character)*7
Debug cTos(char,1)
-
blueznl
- PureBasic Expert

- Posts: 6172
- Joined: Sat May 17, 2003 11:31 am
-
Contact:
Post
by blueznl »
Same here, using a procedure...
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB - upgrade incoming...)
( The path to enlightenment and the PureBasic Survival Guide
right here... )