View Full Version : markup language
jettlarue2003
01-06-2005, 11:51 PM
i would like too create a scripting language. which is extremely easy. but i want something that can interpret it. does anyone know the code to make a browser that only will browse my scriptin language and display them on the screen?
P.S.:i am extremely new to xml or sgml so bear with me :eek:
JamieR
01-07-2005, 12:00 AM
wooh I don't know of any tools that could be used to write a "easy" scripting language and interpreter. It depends on how advanced the things you want to do with it. I.e. If you want a secure login system that interacts with a MySQL database (if your language was supported by it) then you would have to write a lot of code just to make it secure.
If you want to do really simple things with it, then it *might* be possible to create something like java I should think but writing a interpreter to run and display the output code correctly as html would be a bit hard to do. I know PHP is one of the fastest-developed scripting languages but it does have some really powerful, hectic features that allow coders to create powerful programs.
However, I haven't done any research into this before, so I might have a look into the posibility.
As for a browser, then you would have to write it in a language that Windows could read, execute and interpret such as C/C++. You would then have to write a interpreter within the browser after coding the UI, features, functions and such like....The interpreter would interpret the output code from the server and would display it in the browser window...However it would mean a lot of work..
-Jamie
jettlarue2003
01-07-2005, 12:40 AM
thanks but im thinking of java to send the data and read it out then display it on a frame, i am not thinking of making it a common scripting language but one that would be easy to change and modify. i hope i am not sounding like a n00b though. i am a noob to this not a n00b :thumbsup: plus does anyone know the snippet for java to use 1.fileinputstream2.scan the file for known script or code3.organize the rest of the data inside of the code4.display on jframe...i know this is a lot to ask so any help is appreciated:)
jettlarue2003
01-07-2005, 12:42 AM
and for the first post i meant that thinkin up the code items would be easy...not the browser+interpretor :)
Alex Vincent
01-09-2005, 06:47 PM
Can you give us some samples of what you want to do?
jettlarue2003
01-11-2005, 10:22 PM
here is my current java code for a html browser(not what i want)import javax.swing.text.html.*;
import javax.swing.text.*;
import javax.swing.event.*;
import javax.swing.*;
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
public class xmlbrowser {
/** Set the page.
@param jep the pane on which to display the url
@param url the url to display */
protected static void setPage(JEditorPane jep, String url){
try {
jep.setPage(url);
}
catch (IOException e) {
System.err.println(e);
System.exit(-1);
}
}
/** An inner class which listens for keypresses on the Back button. */
class backButtonListener implements ActionListener {
protected JEditorPane jep;
protected JLabel label;
protected JButton backButton;
protected Vector history;
public backButtonListener(JEditorPane jep, JButton backButton, Vector history, JLabel label){
this.jep = jep;
this.backButton = backButton;
this.history = history;
this.label = label;
}
/** The action is to show the last url in the history.
@param e the event*/
public void actionPerformed(ActionEvent e){
try{
//the current page is the last, remove it
String curl = (String)history.lastElement();
history.removeElement(curl);
curl = (String)history.lastElement();
System.out.println("Back to " + curl);
setPage(jep,curl);
label.setText("<html><b>URL:</b> "+ curl);
if (history.size() == 1)
backButton.setEnabled(false);
}
catch (Exception ex){
System.out.println("Exception " + ex);
}
}
}
/** An inner class that listens for hyperlinkEvent.*/
class LinkFollower implements HyperlinkListener {
protected JEditorPane jep;
protected JLabel label;
protected JButton backButton;
protected Vector history;
public LinkFollower(JEditorPane jep, JButton backButton, Vector history, JLabel label){
this.jep = jep;
this.backButton = backButton;
this.history = history;
this.label = label;
}
/** The action is to show the page of the URL the user clicked on.
@param evt the event. We only care when its type is ACTIVATED. */
public void hyperlinkUpdate(HyperlinkEvent evt){
if (evt.getEventType() == HyperlinkEvent.EventType.ACTIVATED){
try {
String currentURL = evt.getURL().toString();
history.add(currentURL);
backButton.setEnabled(true);
System.out.println("Going to " + currentURL);
setPage(jep,currentURL);
label.setText("<html><b>URL:</b> "+ currentURL);
}
catch (Exception e) {
System.out.println("ERROR: Trouble fetching url");
}
}
}
}
/** The contructor runs the browser. It displays the main frame with the
fetched initialPage
@param initialPage the first page to show */
public whackashoethegame(String initialPage){
/** A vector of String containing the past urls */
Vector history = new Vector();
history.add(initialPage);
// set up the editor pane
JEditorPane jep = new JEditorPane();
jep.setEditable(false);
setPage(jep, initialPage);
// set up the window
JScrollPane scrollPane = new JScrollPane(jep);
JFrame f = new JFrame("XML Browser");
f.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
//Exit the program when user closes window.
f.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e){
System.exit(0);
}
});
//Label where we show the url
JLabel label = new JLabel("<html><b>URL:</b> "+ initialPage);
JButton backButton = new JButton ("Back");
backButton.setActionCommand("back");
backButton.setToolTipText("Go to previous page");
backButton.setEnabled(false);
backButton.addActionListener(new backButtonListener(jep, backButton, history, label));
JButton exitButton = new JButton ("Exit");
exitButton.setActionCommand("exit");
exitButton.setToolTipText("Quit this application");
exitButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
});
//A toolbar to hold all our buttons
JToolBar toolBar = new JToolBar();
toolBar.add(backButton);
toolBar.add(exitButton);
jep.addHyperlinkListener(new LinkFollower(jep, backButton, history, label));
//Set up the toolbar and scrollbar in the contentpane of the frame
JPanel contentPane = (JPanel)f.getContentPane();
contentPane.setLayout(new BorderLayout());
contentPane.setPreferredSize(new Dimension(400, 100));
contentPane.add(toolBar, BorderLayout.NORTH);
contentPane.add(scrollPane, BorderLayout.CENTER);
contentPane.add(label, BorderLayout.SOUTH);
f.pack();
f.setSize(640, 360);
f.setVisible(true);
}
/** Create a Browser object. Use the command-line url if given */
public static void main(String[] args) {
String initialPage = new String("http://www.codingforums.com");
if (args.length > 0) initialPage = args[0];
xmlbrowser b = new xmlbrowser(initialPage);
}
}
this has enough browsing functionality for me to work with. but i want to be able to configure theoutput on the page when a specific command such as "<bold>hi</bold>"would result in hi as you can see what i mean. i am trying to make a language for my own use that would resemble html but with features such as connecting to a port and writing files and so such. but my problem is i need to find a way to do these commands. all the best. PS:Jose M. Vidal made the layout of this so thanks if youre reading this:)
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.