Subroutine with variables
Anonymous
Not applicable
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2013-06-20
01:30 AM
- last edited on
2023-05-24
10:12 AM
by
Rubia Torres
2013-06-20
01:30 AM
I am trying to work out if I can use the same subroutine (I hope Im using the right terminology) with different variables within an object.
I am using this for a reasonably complex custom door for my office, but I will give a basic example below what I mean
!block1
xx1 = 1
yy1 = 1
zz1 = 1
gosub 200:
!block2
xx1 = 2
yy1 = 2
zz1 = 2
gosub 200:
200:
block xx1,yy1,zz1
add xx1,0,0
I understand this is a nasty script as an example, but is there a way I can get this concept to work?
Thanks
Tom
3 REPLIES 3

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2013-06-20 02:52 AM
2013-06-20
02:52 AM
Yes, that's how you would do it... assuming there was a way of getting to block2 (block1 and block2 might be the branches of an if-then-else, for example) and that there is a return after the 200: sub code.
You can do a similar thing calling macros, which are separate GDL objects rather than in-line code as in a gosub. With macros, you give the parameter values in the call statement.
You can do a similar thing calling macros, which are separate GDL objects rather than in-line code as in a gosub. With macros, you give the parameter values in the call statement.
AC 28 USA and earlier • macOS Sequoia 15.4, MacBook Pro M2 Max 12CPU/30GPU cores, 32GB
Anonymous
Not applicable
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2013-06-20 03:36 AM
2013-06-20
03:36 AM
Thanks Karl,
Im a bit new to this subroutine idea.
My current door script is huge and I need to simplify it.
Macros seem pretty useful
Currently trying to investigate macros and struggling trying to find simple examples.
Does anyone have a basic example I could use?
Im a bit new to this subroutine idea.
My current door script is huge and I need to simplify it.
Macros seem pretty useful
Currently trying to investigate macros and struggling trying to find simple examples.
Does anyone have a basic example I could use?
Anonymous
Not applicable
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2013-06-20 03:54 AM
2013-06-20
03:54 AM
OK, didn't realise a macro is a separate GDL part
I have created a test
!TestMacro 3D GDL Script
block xx1,yy1,zz1
add xx1,0,0
!Main Object 3D GDL Script
call "testMacro" parameters xx1=1, yy1=1, zz1=1
addx 1
call "testMacro" parameters xx1=2, yy1=2, zz1=2
Works a treat. Now I just need to use this concept in reality.
Thanks Karl
I have created a test
!TestMacro 3D GDL Script
block xx1,yy1,zz1
add xx1,0,0
!Main Object 3D GDL Script
call "testMacro" parameters xx1=1, yy1=1, zz1=1
addx 1
call "testMacro" parameters xx1=2, yy1=2, zz1=2
Works a treat. Now I just need to use this concept in reality.
Thanks Karl