Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Author
Message
Qeshmjaa
10
Years of Service
User Offline
Joined: 15th Mar 2014
Location:
Posted: 17th Aug 2017 18:10
Hello guys I have some files, for example "Screen.agc"
I've included the file in Main.agc.

But how to use the functions from file "Screen.agc" to Main.agc.
For example.

Screen.agc
platform$ = getDeviceName()


main.agc
print (platform$)
...

thanks in advance.
lol albanians in da house <3
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 18th Aug 2017 08:50 Edited at: 18th Aug 2017 09:03
#include append the main file, so you can just call your functions by name.
#insert is better and insert the source code at this place

i guess your example with line platform$=GetDeviceName() was not run through because include put it at the end of main file.

very useful is this once in main
#option_explicit
https://www.appgamekit.com/documentation/language/35_option_explicit.htm

if you are using global variables i suggest to use a type for it as collection
TYPE ScreenInfoType
a AS integer
b AS float
c AS string
ENDTYPE
Global ScreenInfo as ScreenInfoType
SetScreenInfo(ScreenInfo )

Screen.agc
Function SetScreenInfo(s ref as ScreenInfoType)
s.a= ...
s.b= ...
s.c= ...
EndFunction platform$

Function MyGetDeviceName()
platform$=GetDeviceName()
EndFunction platform$


main.agc
print (MyGetDeviceName())
print (GetDeviceName())
print(ScreenInfo.c)
AGK (Steam) V2017.08.16 : Windows 10 Pro 64 Bit : AMD (17.7.2) Radeon R7 265 : Mac mini OS Sierra (10.12.2)
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 18th Aug 2017 08:59
Screen.agc
global platform$
platform$ = getDeviceName()

main.agc
print (platform$)

Make sure that the code in screen.agk is called before you try and use it in main.agc.
Click here for VR Legend of Zelda stuff
Qeshmjaa
10
Years of Service
User Offline
Joined: 15th Mar 2014
Location:
Posted: 18th Aug 2017 14:13
thank you guys
lol albanians in da house <3

Login to post a reply

Server time is: 2024-04-26 21:29:47
Your offset time is: 2024-04-26 21:29:47