Function Calling Problem- Please HELP

Übersicht BlitzBasic Beginners-Corner

Neue Antwort erstellen

 

tharshan

Betreff: Function Calling Problem- Please HELP

BeitragMo, Jun 11, 2007 15:40
Antworten mit Zitat
Benutzer-Profile anzeigen
sorry for the bad language...
------------------------------------------------------
i want to create entities / load images from a included function..
but it not works becasue its not a Global Variable..

i could call the function manytime as needed.. so its hard to declare each objects as Global Var.

is there any ways to do this ? maybe Types ?

Please Reply..
================================================
ich möchte Wesen/Last Bilder von einer enthaltenen Funktion verursachen. aber es nicht funktioniert das becasue, das nicht eine globale Variable. sein ist. gibt es irgendwelche Weisen, dies zu tun? möglicherweise Arten? Bitte
Antwort.

ich könnte das Funktion manytime benennen, wie gebraucht. so wendet sein hartes, jedes zu erklären als globale Sorten ein.
================================================

====================================
MAIN.BB
====================================
Include "func.bb"

Graphics 640,480,32,2

a("c:\texture.png","a")
a2("a",15,15)




WaitKey
End

====================================
FUNC.BB
====================================

Function a(file$,name$)

name$ = LoadImage(file$)
If name$= 0 Then RuntimeError "Couldn't load image: "+file$
End Function


Function a2(name$,x#,y#)

DrawImage(name$,x#,y#)

End Function
Venkadesan V Tharshan
 

Dreamora

BeitragMo, Jun 11, 2007 15:59
Antworten mit Zitat
Benutzer-Profile anzeigen
If german is not your native language, please visit www.blitzbasic.com to ask your questions in english.
This is a german community board.


And you do several elemental errors:

1. Load functions return integers, not strings, so assigning them to string is the wrong step

2. You could return the value from the function and assign it to something like someImage = a(path$) for example.


Der Code hat einige grundlegen Fehler:

1. Ladefunktionen geben Integer zurück, nicht Strings, von daher ist die Zuweisung zu einem String (name$) falsch

2. Anstatt globaler Variablen kann man das geladene Bild auch zurück geben und danach einer variable zuweisen


moved da im falschen board
Ihr findet die aktuellen Projekte unter Gayasoft und könnt mich unter @gayasoft auf Twitter erreichen.
 

tharshan

Betreff: Thanks

BeitragMo, Jun 11, 2007 16:03
Antworten mit Zitat
Benutzer-Profile anzeigen
ok,
i will go and Ask In BlitzBasic.com

anyways Really Thank You For Your Help.
Venkadesan V Tharshan
 

tharshan

Betreff: if you..

BeitragMo, Jun 11, 2007 16:07
Antworten mit Zitat
Benutzer-Profile anzeigen
2. You could return the value from the function and assign it to something like someImage = a(path$) for example. ......

if you dont mind.. can you show me a simple example of.. that please ?
its important for me Crying or Very sad

all i need to do is load , draw images from another include file.. not in main.bb file..
i need to handle the entity pointer from include function.

really sorry if i am annonying you.

Thanks.
Venkadesan V Tharshan
 

Dreamora

BeitragMo, Jun 11, 2007 16:42
Antworten mit Zitat
Benutzer-Profile anzeigen
Blitz3D / BlitzPlus has no entity pointers, it only has integer handles.
They do as well not support by Reference , so you can not give the function the variable or its and fill the variable within the function!h
what you tried with a2 will never work at all. realtime variable generation like this only works in scripting languages, not in compiled languages.

For further questions please use german or the english boards at http://www.blitzbasic.com .
Most users do not understand english and thus this thread is of no use to them.

Code: [AUSKLAPPEN]


====================================
MAIN.BB
====================================
Include "func.bb"

Graphics 640,480,32,2

image % a("c:\texture.png","a")
a2(image,15,15)




WaitKey
End

====================================
FUNC.BB
====================================
Function a%(file$)

  result% = LoadImage(file$)
  If result= 0 Then RuntimeError "Couldn't load image: "+file$
  return result
End Function

function a2(img%, x#, y#)
  drawimage img, x, y
end function
Ihr findet die aktuellen Projekte unter Gayasoft und könnt mich unter @gayasoft auf Twitter erreichen.
 

tharshan

Betreff: thaNKS

BeitragMo, Jun 11, 2007 16:59
Antworten mit Zitat
Benutzer-Profile anzeigen
Thank you..
i will ask in german / ask the future questions in www.blitzbasic.com

Thanks for your help.
Venkadesan V Tharshan

Neue Antwort erstellen


Übersicht BlitzBasic Beginners-Corner

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group