Overview
This is the beginning of a series on learning how to program with the MivaScript language, starting from the beginning and then going through the tags and functions. The documentation is thorough and well written resource with it's own tutorials and tons of examples and the first page pretty much sums up the major points of MivaScript.
Install MivaMia and the MivaScript Compiler
Download and install the following items before continuing. If you're a Linux super guru, you could look into Miva Empressa, but it's completely unnecessary to make MivaScript apps and notoriously difficult to set up right.
Miva Mia which is a back end server for compiled MivaScript apps. This is free and runs on Windows.
MivaScript Compiler which is also free and runs on windows.
Text Editor
A good text editor is beyond important. It makes text editing life easier and even enjoyable. I've been using Notetab Pro for years and highly recommend it. If you get into MivaScripting, contact me and I'll send you my NoteTab Pro Miva Clip library which saves some serious programming time.
Hello World: First MivaScript App
Create a new text file called helloworld.mv in your C:\MivaMia\HTML folder.
The file extension .mv designates a MivaScript file. Enter the following line and save the file.
<MvEVAL EXPR = "{ 'Hello World!' }">
Compile Your MivaScript
One of the great things about MivaScript is that it's pre-compiled on the server so it runs faster and has lower overhead than languages that need to be pre-processed on the server.
Open up a command prompt, or type into the run/search box:
c:\msc\bin\mvc.exe helloworld.mv
This compiles the MivaScript app and if there were no errors, it's ready to run (see below if you had problems.)
Running A MivaScript
Start up MivaMia if you haven't already. A little gold MivaMia icon will appear in your system tray when it's running. Open a browser window and go to the following URL (see below for problems.)
127.0.0.1/helloworld.mvc
If all went well, you should see Hello World appear at the top of the browser window.
Possible Compiling Issues
Path problem: if you get some sort of path error when compiling a MivaScript, it probably means the installer didn't set the path or you didn't restart Windows. If restarting Windows doesn't work, then you'll have to set the path manually.
This happened to me and what I made to get around it is a little batch file called mv.bat:
@ECHO OFF
PATH=c:\Msc\Bin;
SET MVC_LIB=c:\msc\Builtins
c:\msc\bin\mvc %1
For helloworld.mv, I would run the batch file like this:
mv.bat helloworld.mv
If you are using NoteTab Pro, put the mv.bat file in the C:\MSC directory, then create a new clip called MivaCompile in NoteTab Pro (left click in Clip library at the position you want to put the Clip) and put this code in it:
^!Save
^!Set %filename%=^$GetDocName$
^!ChDir c:\MSC\BIN
^!Info [L] ^$GetOutput("c:\msc\bin\mv.bat ^%filename%")$
This saves the file, runs mv.bat that compiles the MivaScript, then outputs any errors to the NoteTab Pro screen. This little trick has saved me tons of time.
Possible Errors Running a MivaScript
It's possible you might get a server error of some kind when running the MivaScript. If so, think about any other servers running. Are you a PHP scripter? Maybe Apache is running and using the 127.0.0.1 "domain", or maybe there's something in your Window's hosts file that isn't letting you use that IP. It could even be your virus software.
Ask me if you can't get it working, it can be tricky the first time around.
Related Posts and Information