hello charles..
its possible with ocygen to define more than one command with another syntax?
for example
def funbox mbox ' thats ok
but how about that with second definition
here 'control'
def funbox control mbox
thanks, frank
You can use a def to represent any number of words. It will also accept up to 9 parameters for substitution %1..%9.
One of my favorites illustrating several features:
def show print "%1 --> " %1
show(10+1/4) '10+1/4 --> 0.25
A single liner def is the same as a '%' or '$' equate.
Thank you Charles
Perhaps I didnt make IT clear sorry.. or I cannot understand your explanation..
I wanted more that in this Case 'control'
Def Control funbox mbox
Has Same mbox Features Like above in my First post
Def funbox mbox
Thx
Perhaps you could provide a use-case showing the result you want it to produce.
Yes.. Here my Idea :(
' ok first three definitions
'
def funbox mbox
funbox = "Hello Oxygen"
def control funbox
control = "Hello Oxygen2"
def control2 control
control2 = "Hello Oxygen3"
'------------------------------------------------------------ //
' this was my idea if that's working too with three parameters
def control funbox mbox 'default params not available
control = "Hello Oxygen4"
mbox is a low-level call based on MessageBox. So the expression mbox="hello" is treated as a pseudo-assignment with "hello" as its parameter.
so these definitions will work because they resolve to mbox(string) calls, though it might confuse someone trying to understand the code.
mbox "hello0"
mbox="hello1"
def funbox mbox
funbox="hello2"
def control funbox
control="hello3"
Thanks again Charles,
I only want to know If a construct with three Parameters to define is possible?
Def Abc Print
Abc="hello Diana"
Def xyz Abc Print ' three Parameters
Xyz="hello Julia"
So If thats possible that xyz has Same Definition Like Print in one Line?
Regards, frank
With def statements, parameters are not declared like functions and procedures. Instead parameters are referenced within the body of the macro as %1 %2 %3 etc. For instance
def listitem print "%1" + chr(9) + "%2" + chr(13,10)
'
listitem 1 shoes
listitem 2 socks
listitem 3 hat
When invoking listitem the 2 words following listitem are treated as parameters. This is similar to DOS macros.
Thanks Charles..
I have done three little examples with macros..
And Last one with listitem2 Shoes legs 1 etcpp
In freebasic its possible to #define print_three_Params(P1,p2,p3) Print P1,p2,p3
Oxygen
uses console
' it's possible to create a macro with three params in one line?
' macro PRINT_THREE_PARAMS(p1, p2, p3) Print p1, p2, p3
'
macro Print3( a,b,c )
Print a
Print " "
Print b
Print " "
Print c
print "!"
end macro
Print3( "Hello", "Dianas ", "World " )
wait
printl "press key to continue"
macro PRINT_THREE_PARAMS(p1, p2, p3)
Print p1
print p2
print p3
end macro
PRINT_THREE_PARAMS( " Hello2 ", " Dianas2 ", " World2 " )
wait
printl "press key to continue"
'' CodeSelect
def listitem print "%1" + chr(9) + "%2" + chr(13,10)
'
listitem shoes 1
listitem socks 2
listitem hat 3
wait
printl "press key to continue"
def listitem2 print "%1" + chr(9) + "%2" + chr(13,10) + "%3" +chr(13,10) 'print "%3" '+chr(13,10)
'
listitem2 shoes legs 1
listitem2 socks feet 2
listitem2 hat head 3
wait
printl "press key to continue"
'-------------------------------- //
'
' ---> freebasic: this example works well below
'' #define PRINT_THREE_PARAMS(p1, p2, p3) Print p1, p2, p3
' test program
'' PRINT_THREE_PARAMS("hello ", "Dianas ", " world")
'' Wait for user to press a key
'' Print "Press any key to continue..."
'' Sleep
In classic BASIC, print is a statement with its own syntax. comma means tab and semicolon means concatenate.
Additionally the print statement automatically ends with crlf unless it ends with comma or semicolon.
In OxygenBasic, print is a normal procedure taking one string expression, and it does not have a predefined lprint for direct printer output. print normally outputs to MessageBox but the console library redefines it for console line output.
Hello Charles I have Got it ;)
uses console
#Def abc Printl
abc "Hello myWorld" ' ok
#Def defg Printl
defg "Hello yourWorld" ' ok
#Def zorro abc
zorro "Hello ZorrosWorld" ' ok
#Def batman zorro
batman "Hello Batman+ZorrosWorld" ' ok
'batman "1" zorro "2"
batman "Batman without zorro" ' ok
batman "1" zorro "1" ' ok ' 1 11
wait
printl "print key to continue"