LoginLogin
Nintendo shutting down 3DS + Wii U online services, see our post

Ways To Use Lowerdash

Root / Submissions / [.]

kldck_hulCreated:

This guide exists to showcase the different ways you can use Lowerdash to build a project. It won't show you how to code Lowerdash or any features; see the manual for reference

1 Running Lowerdash code directly 2 Compile your Lowerdash and distribute SmileBasic code 3 Build a library for use with someone else's code 4 Split your code into smaller files to get around limitations

Running Lowerdash code directly

<> This is the most obvious use case. You write your modules in Lowerdash, saving them to separate files, and run your game from a main entry point. Your files might look like:
* MAIN.PRG
* _MyMod1
* _MyMod2
* aLibrary.lib
(here .PRG is just a convenience name to show it is the PROGRAM to run) Your MAIN.PRG would then contain the code:
LOAD "PRG2:LOWERDASH_C",0: USE 2

head
━━━━
import "_MyMod1"
import "_MyMod2"
import "aLibrary.lib"
━━━━
hend

main
━━━━
... CODE USING YOUR MODULES ...
This loads LOWERDASH_C (the compiler) into PRG2. When hend is reached, it will automatically load LOWERDASH (the runtime) into PRG3, and append your program data to the end. In main, your Lowerdash code is running from PRG3. You would distribute all your files.

Compile your Lowerdash and distribute SmileBasic code

<> This is the way you'll probably want to distribute your code. It creates hard to read SmileBasic code that probably should never be edited manually. All your modules are contained in one file, and can't quickly be reused by anyone else. The recommended way of doing this is a BUILD.PRG, and an entry-point MAIN.PRG Your files might look like:
* BUILD.PRG
* MAIN.PRG
* _MyMod1
* _MyMod2
* aLibrary.lib
(here .PRG is just a convenience name to show it is the PROGRAM to run) Your BUILD.PRG might contain the code:
LOAD "PRG2:LOWERDASH_C",0: USE 2

head
━━━━
import "_MyMod1"
import "_MyMod2"
import "aLibrary.lib"
━━━━
compile "MyGameModule"
Your MAIN.PRG might contain the code:
LOAD "PRG3:MyGameModule",0: USE 3

main
━━━━
... CODE USING YOUR MODULES ...
This works like the previous example, automatically loading LOWERDASH and appending your program data to it; however, that file is then saved to "MyGameModule" instead of continuing on to run your game. In MAIN.PRG, you then load this compiled file and have your main code after MAIN. In MAIN, Your compiled Lowerdash code is running from PRG3. You would distribute:
* MAIN.PRG
* MyGameModule

Build a library for use with someone else's code

<> Using this method lets you create files that can be imported into another Lowerdash program and used there. Some features are usable without the Lowerdash runtime as well. This includes STATIC DEFs and VARs. The recommended way of doing this is a BUILD.PRG Your files might look like:
* BUILD.PRG
* _MyMod1
* _MyMod2
(here .PRG is just a convenience name to show it is the PROGRAM to run) Your BUILD.PRG might contain the code:
LOAD "PRG2:LOWERDASH_C",0: USE 2

head
━━━━
import "_MyMod1"
import "_MyMod2"
━━━━
compile_lib "MyGameLibrary.lib"
As in previous examples your code is compiled, however instead of including the Lowerdash runtime, just the code that is in _MyMod1 and _MyMod2 will be saved to MyGameLibrary.lib. Lowerdash will not re-compile a file ending in .LIB when you import it. If your library requires the Lowerdash runtime, the runtime will need to be present in any projects using your library. You would distribute:
* MyGameLibrary.lib
PROTIP: Create a MAIN.PRG using method 1 to test your code!

Split your code into smaller files to get around limitations

<> This is a bit of an oddball use-case. If your ordinary SmileBasic code is becoming too large to upload in a single file, you can break it apart into pieces and reassemble them when your game is run. You should save the pieces of your code as .LIB files to indicate to Lowerdash that they should not be compiled. Your files might look like:
* BUILD.PRG
* MAIN.PRG
* MyCodePt1.lib
* MyCodePt2.lib
(here .PRG is just a convenience name to show it is the PROGRAM to run) Your BUILD.PRG might contain the code:
LOAD "PRG2:LOWERDASH_C",0: USE 2

head
━━━━
import "MyCodePt1.lib"
import "MyCodePt2.lib"
━━━━
compile_lib "MyGameLibrary.lib"
And your MAIN.PRG:
EXEC "PRG1:BUILD.PRG"
LOAD "PRG1:MyGameLibrary.lib"
... YOUR CODE DOING WHAT IT DOES ...
You would distribute all your files

No posts yet (will you be the first?)