tag:blogger.com,1999:blog-72325561478931804752024-02-02T12:33:56.397-08:00A programming guideRandom howto's that works always, every time, and all the timeRey Dacocohttp://www.blogger.com/profile/16795901672669072701noreply@blogger.comBlogger96125tag:blogger.com,1999:blog-7232556147893180475.post-65282851954160613342019-01-06T22:46:00.000-08:002019-01-07T19:19:07.019-08:00Simple GUI Calculator in Java <div dir="ltr" style="text-align: left;" trbidi="on">
Hello world! I'm back. It’s been four years since my last post. I’d been very busy with work in these past few years that I haven’t had time to blog. I missed blogging somehow and this year I figure I’ll get back to blogging again.
<br />
<br />
We are going to be making simple programming projects starting from now and for our first project, let’s make a simplest calculator using Java. In this project we’ll be using BlueJ as our Java Development Tool.
<br />
<br />
1. Download BlueJ installer from https://www.bluej.org/ then install it.
<br />
<br />
2. Click Start>Click BlueJ.
<br />
<br />
3. Click Project>New Project>For the sake of example, let’s use Java as a project name.
<br />
<br />
<img height="262" src="https://2jzfbq.dm.files.1drv.com/y4mQeFDtLKGHMz_e-uA21nKV6IR8Na8MkKXIoX6jJZsJ0NZSvsvH7XD8BE_C3RLsMFCZ0E1rdZP-Ci9B3hRUCEN4PJ-KHHUUCt6Qu3IVt5lIF8tEvroEVNGzwNzMuDeRDnRsdFIk7whHTOHeV0uPxdIy-qARrMOrmxGhYgQlXhVnedOmhkBkjnJLsdVBvAjCSND?width=484&height=262&cropmode=none" width="484" />
<br />
<br />
4. Click New Class>Select Class in the class type radio buttons then enter Calc in the Class Name textbox.
<br />
<br />
<img height="311" src="https://psjfsq.dm.files.1drv.com/y4mEQ-3mop8f4MyNZs36sUcHHNgb2yvWtKBBSiaYEERj-OvW_TF3pDnJhNFfe1wNvmzsu2MGVeK47GuvJ8m6BNUaJ_Nxo3BaDeSJr7BHXNiH2mAmvPzOVqI-B-9ncYUbG7Uv_ctkn5bPuse1cYO0S1-kYnzIVcE4mKbAgLnLkkOwuTFC4OZERd9vv6PXCK_9Jvw?width=518&height=291&cropmode=none" width="518" />
<br />
<br />
5. Double-click the Calc object.
<br />
<br />
<img height="311" src="https://2jypha.dm.files.1drv.com/y4mvC4R4wSsduKW5YepId9PBTKVgwTkYRl2ui_aZ_hgsVkEemY3VT1kIFcU54-hHtq-FvzllBucyFt5WBcdUuAqvxHJok7K4QMTkAwrMraVZ2cHnTiY9dRsR7ekKXcQQkmAp11J-4WMhfWof7fqi1a-scklxp6E9G2qDvQBctRBxGD8Sb3m3JNyfjgNtUPhEiK9?width=513&height=311&cropmode=none" width="513" />
<br />
<br />
6. A Window containing default BlueJ source code will then appear. Press Ctrl + A to select all the codes, then Press Delete.
<br />
<br />
<img height="311" src="https://2jbepa.dm.files.1drv.com/y4mXaiWjLq6f2760D9j3Rn4M1AErq12bg2FAbe3p4_UXZAXHgX7Q1Nl84iRNxcNDxSe7btEWr6W9a76PoriMIw9kuYjrV55HEUgNv7zRGztH_WXMVT7inTZ1bpSVABG-oDOzS6nxwSdl46ICO9Jo_x8D3Cs6O132lcX8c9T-GV2X5cFlaXrENMUwJypVPkTZF56?width=1119&height=376&cropmode=none" width="513" />
<br />
<br />
7. Enter the following code:
<br />
<br />
<pre class="java" name="code">//imports the necessary packages.
//swing for frame, awt for controls, and event for button events
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
//creates a class named Calc and prepares it to accept an event
public class Calc extends JFrame implements ActionListener
{
//creates our controls
JTextField ansTextField=new JTextField("",18);
JButton oneButton=new JButton("1");
JButton twoButton=new JButton("2");
JButton plusButton=new JButton("+");
JButton minusButton=new JButton("-");
JButton equalsButton=new JButton("=");
//declares three variables
int intNum1,intNum2;
String strOperator;
public Calc()
{
//creates two panels
JPanel topPanel=new JPanel();
JPanel bottomPanel=new JPanel();
//create two layouts
BorderLayout border=new BorderLayout(5,5);
FlowLayout flow=new FlowLayout(FlowLayout.RIGHT,10,10);
//apply the borderLayout to frame
setLayout(border);
//prepare our buttons to accept an event
oneButton.addActionListener(this);
twoButton.addActionListener(this);
plusButton.addActionListener(this);
minusButton.addActionListener(this);
equalsButton.addActionListener(this);
//adds the textbox to the top panel
topPanel.add(ansTextField);
//applies flow layout to bottom panel
bottomPanel.setLayout(flow);
//add the buttons to the bottom panel
bottomPanel.add(oneButton);
bottomPanel.add(twoButton);
bottomPanel.add(plusButton);
bottomPanel.add(minusButton);
bottomPanel.add(equalsButton);
add(topPanel,BorderLayout.NORTH);
add(bottomPanel);
//setup our frame
setSize(200,200);
setLocation(0,0);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setTitle("Calculator");
setVisible(true);
}
public void actionPerformed(ActionEvent e)
{
//getSource determines the name of the control that recieves an event
Object source=e.getSource();
//if the name of the control that recieves an event is oneButton, display 1 in the textfield
if(source==oneButton)
{
ansTextField.setText(ansTextField.getText() + oneButton.getText());
}
//if the name of the control is twoButton, display 2 in the textfield
//you can add else ifs for numbers 3 to 9. I just leave that to you to figure out
else if(source==twoButton)
{
ansTextField.setText(ansTextField.getText() + twoButton.getText());
}
//if it is plusButton, get the value displayed in the textfield and place it
//in a variable named intNum1
//Store "+" in the strOperator variable then clear the text field
else if(source==plusButton)
{
intNum1=Integer.parseInt(ansTextField.getText());
strOperator="+";
ansTextField.setText("");
}
//if it is minusButton, get the value displayed in the textfield and place it
//in a variable named intNum1
//store "-" in the strOperator variable then clear the text field
else if(source==minusButton)
{
intNum1=Integer.parseInt(ansTextField.getText());
strOperator="-";
ansTextField.setText("");
}
//if the name of the control that recieves an event is equals button
//get the current value of the text field and assign it as a value of intNum2
//if the current value of strOperator is + add the two numbers, if it's value is -
//subtract the two numbers
else if(source==equalsButton)
{
intNum2=Integer.parseInt(ansTextField.getText());
if(strOperator=="+")
{
ansTextField.setText(Integer.toString(intNum1 + intNum2));
}
if(strOperator=="-")
{
ansTextField.setText(Integer.toString(intNum1 - intNum2));
}
}
}
//Creates an instance of our class so that we can run it
public static void main(String[] args)
{
Calc c=new Calc();
}
}
</pre>
<br />
<br />
8. Click the compile button.
<br />
<br />
9. Close the code window.
<br />
<br />
10. Right-click the class object>Select void main(String[] args) to run your application.
<br />
<br />
<img height="311" src="https://2ja9sq.dm.files.1drv.com/y4mfE4tUNpKROwz6EvbsA6WwCLugNpHnMAtptzBAVzPi9nuklJskHtSFVT8nhs707ChDNs_oEMY_WmtDjfWNzkzLUuOAJIwDN2NbQY2_xW03VoILZU1I2Q1LOe4Qhn2FqG7kStbxmeLuhU4NWSsQ_fbd4wQ2suIo-6LQZ6TpXs4CqpvgKwbBJeJ7VoxO4Lh0mYg?width=604&height=331&cropmode=none" width="513" />
<br />
<br />
11. You should then see the following output:
<br />
<br />
<img height="311" src="https://2jb64q.dm.files.1drv.com/y4mfoAUa5JrMtu3fC7cqi-hTTWwz6PL9fMs59l6uj_JGTwDZ5_OoINVVCEHPDixp0TQWTFOVbcYxJ2kuTJh4feq15sFssdEetmdmTTIo2jPv_BwR2QMOb3LcqAy4dXllB8yIUkM6z88bHvS0hbCm2dMDkCnEvR7nlkl5wezfvrqpPFVq4qlkScKR70iUzkLJmcm?width=608&height=441&cropmode=none" width="513" />
<br />
<br />
You can use this and make a complete basic calculator. Of course I leave that to you to figure out. If you are having a hard time, you can download the
<a href="https://onedrive.live.com/embed?cid=F1435D1E6B5FAB32&resid=F1435D1E6B5FAB32%21115&authkey=AKE4QsiZ7Zmhnww">source code here</a> Good luck!
</div>
Rey Dacocohttp://www.blogger.com/profile/16795901672669072701noreply@blogger.com0tag:blogger.com,1999:blog-7232556147893180475.post-41589243941656150172014-05-29T11:49:00.000-07:002019-01-07T18:47:33.288-08:00Enabling Broadband Internet Connection on Kali LinuxHey there. Am sure you probably know that Kali Linux is a very powerful pen testing and computer forensics tool available for free download at <i>http://www.kali.org/</i>. But you might not know how to enable broadband Internet connections in it. Trust me, I had the same problems before as well. I’ve search the net to no avail so I decided to do something about it. Anyways, here’s how:
<BR>
1. Insert your broadband stick on your USB port. <i>In this case I’m using Smart Bro so its icon should then appear on the Kali Linux desktop.</i>
<BR>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqFO9p0UZmP2-xlb9p7XbAO-xtJSbr-xYDDcDOVXguniAiGakepQYADYfcIj60y29yaOdMrAACBeUWP7JftD8GNi0buPFGFPAD9DcXQsuNjVltPvEsCzFFSKdYn84fdJzqT2Xvlse1jKuT/s1600/oie_291957135KFXuTWL(1).jpg" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqFO9p0UZmP2-xlb9p7XbAO-xtJSbr-xYDDcDOVXguniAiGakepQYADYfcIj60y29yaOdMrAACBeUWP7JftD8GNi0buPFGFPAD9DcXQsuNjVltPvEsCzFFSKdYn84fdJzqT2Xvlse1jKuT/s320/oie_291957135KFXuTWL(1).jpg"></a>
<BR>
2.In the top right side area of the kali desktop, Right-click the networking icon then select Edit Connections.
<BR>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEix36m8BsKfJf9_smjNPsJ2sxLQFIjN5k1JFfwMcPE7y_37zCl7-cdrkETPeEmZSO_WPb7MnkTcuhCgOSSyYcchNRx8MM45OMuwIuIiJvpkOisWZMY5xAUyHv76bNBujuyhmPcYqFDeRrc5/s1600/oie_2920622QUXTpfOz.jpg" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEix36m8BsKfJf9_smjNPsJ2sxLQFIjN5k1JFfwMcPE7y_37zCl7-cdrkETPeEmZSO_WPb7MnkTcuhCgOSSyYcchNRx8MM45OMuwIuIiJvpkOisWZMY5xAUyHv76bNBujuyhmPcYqFDeRrc5/s320/oie_2920622QUXTpfOz.jpg"></a>
<BR>
3. The Network Connections window should then appear.Select the mobile broadband tab then click Add.
<BR>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqMI0WvctvRB91xYFzFUBKdUFNgbb-Hy-QpqTgW9jITFZZ-GofN_Zck8IiUkKwCX8qFAQDe32NiEaM0tYjZUpIWZ19LALZfM82XjV5Qqb5z5n2DcOJwct-e-FA1mza3Hp92xCNmMK6P8wj/s1600/oie_29202017IDy7sMPs.jpg" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqMI0WvctvRB91xYFzFUBKdUFNgbb-Hy-QpqTgW9jITFZZ-GofN_Zck8IiUkKwCX8qFAQDe32NiEaM0tYjZUpIWZ19LALZfM82XjV5Qqb5z5n2DcOJwct-e-FA1mza3Hp92xCNmMK6P8wj/s320/oie_29202017IDy7sMPs.jpg"></a>
<BR>
4.On the next window select you provider’s country or region. <i>In this case since iv’e selected Philippines[since Smart Bro is in the Philippines...depends on your service provider’s location]>Continue.</i>
<BR>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgD0_3o6eHgtTo-5gXkG5oc2RynBzF1Y32fo45VfpMlDHtd1ds8A9j9Q0m5mTdv6i_lsiZmfLILdYmzmFvaluF26W3XVWTfWvzfErfqlrAyWjb2uyOWik3VwdThn6t-j1xskEVy6mJ0ItYr/s1600/oie_29201658z515hYan.jpg" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgD0_3o6eHgtTo-5gXkG5oc2RynBzF1Y32fo45VfpMlDHtd1ds8A9j9Q0m5mTdv6i_lsiZmfLILdYmzmFvaluF26W3XVWTfWvzfErfqlrAyWjb2uyOWik3VwdThn6t-j1xskEVy6mJ0ItYr/s320/oie_29201658z515hYan.jpg"></a>
<BR>
5. 5. Select your Mobile Broadband Provider. <i>In this case ive’d selected Smart [since Smart Bro’s provider is Smart...again the value in here depends on your provider]>Continue.</i>
<BR>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgkSaWQU4aI4OXqEV17ChrBkI1eQGNAdmLgl6g7sSwClc3ZNNeG_u2X_ytNYvtIcEizv622FzlaN9GwJfOUxkvOSzP_1c4u8n9LYY6Y_j04avJPPUL0lue5i4Ot1yBS2eNfAWM-7L7ojtY8/s1600/oie_2920266A13t479Y.jpg" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgkSaWQU4aI4OXqEV17ChrBkI1eQGNAdmLgl6g7sSwClc3ZNNeG_u2X_ytNYvtIcEizv622FzlaN9GwJfOUxkvOSzP_1c4u8n9LYY6Y_j04avJPPUL0lue5i4Ot1yBS2eNfAWM-7L7ojtY8/s320/oie_2920266A13t479Y.jpg"></a>
<BR>
6.Select your data provider plan. <i>In this case I’ve accepted the default settings>Continue.</i>
<BR>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCxlKd05vimPapgwC92ULIcDl806aAYwxCmJqYIYpdzK8SNQVaVBWufOJqzFsSRxVynIvBqUF1j3DuFicK7lBDvMPvF1v7n32x4SqOEFX7tkaWxyc1JYES-9DBAlzfD5Sz8PuzIyEtXeXx/s1600/oie_29202940Lh5QHCUy.jpg" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCxlKd05vimPapgwC92ULIcDl806aAYwxCmJqYIYpdzK8SNQVaVBWufOJqzFsSRxVynIvBqUF1j3DuFicK7lBDvMPvF1v7n32x4SqOEFX7tkaWxyc1JYES-9DBAlzfD5Sz8PuzIyEtXeXx/s320/oie_29202940Lh5QHCUy.jpg"></a>
<BR>
7. Click the Apply button to confirm your settings.
<BR>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjycDsizWBZJ1d2gcRAF66vdbPRBIQfzXAnwnkYli8DyUqO9BGmm0RS3zom1XhoES2GhO4D6Gtl-rRAinDwogpU_o1UNSE5hFwDaJDBQhM_xVfDktbw8gU2lBVbmoAX6YvyJTjel2Fm-6Em/s1600/oie_29203417DbnBMJ3X.jpg" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjycDsizWBZJ1d2gcRAF66vdbPRBIQfzXAnwnkYli8DyUqO9BGmm0RS3zom1XhoES2GhO4D6Gtl-rRAinDwogpU_o1UNSE5hFwDaJDBQhM_xVfDktbw8gU2lBVbmoAX6YvyJTjel2Fm-6Em/s320/oie_29203417DbnBMJ3X.jpg"></a>
8. A connection name window should then appear. <i>In this case, ived entered “Smart Bro” as a connection name. Any name should do. Just wanted it to be descriptive>Apply.</i>
<BR>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg3JD-HAXSRbAqD1XmI8c286beh99CbxoYVvDoxG3L5vuALduxgMp7wJrnkCt6-rRihygiepDrkw4G6G75aTdyOXj09lVe7n9E4eiHGfhVmG7maj2lgHJqrjBiivUKLoZL8RNn_RJFzrhrg/s1600/oie_29203755R06g5Tiw.jpg" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg3JD-HAXSRbAqD1XmI8c286beh99CbxoYVvDoxG3L5vuALduxgMp7wJrnkCt6-rRihygiepDrkw4G6G75aTdyOXj09lVe7n9E4eiHGfhVmG7maj2lgHJqrjBiivUKLoZL8RNn_RJFzrhrg/s320/oie_29203755R06g5Tiw.jpg"></a>
<BR>
9. To enable your broadband internet connection, CLICK(not right-click) the networking icon near in the notifications area>Then select your broadband connection name. <i>In this case Iv’e selected Smart Bro.</i>
<BR>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhhTKW24UJUZHOXavL8xGnFblnoeSs36ItSm5qHZurTqOSd6PTZuxuZfJDOhdW7tSW0yTrn0AJHpSzBBdXny0bI_R8ngICWAa9XbUT7PgxfcaLPVl0FeC8KzmoDfceop8g-e4FCA8sJuQU_/s1600/oie_2920429ZSomzblD.jpg" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhhTKW24UJUZHOXavL8xGnFblnoeSs36ItSm5qHZurTqOSd6PTZuxuZfJDOhdW7tSW0yTrn0AJHpSzBBdXny0bI_R8ngICWAa9XbUT7PgxfcaLPVl0FeC8KzmoDfceop8g-e4FCA8sJuQU_/s320/oie_2920429ZSomzblD.jpg"></a>
<BR>
<i>The network icon should now change into a broadband signal meter icon and you should not be able to connect to internet using a broadband connection.</i>
<BR>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjMzS2XUSdV9QnOHCKciyH_E0cL9p_FAhy-SdMTCehxhW1MRuTvCXPNjxRpssrMoFXrjzEhn04R7lLWmtlNwX8l5X3nu0H1b5ccDv9OP_P-zUolD6z7hXEJSpYRQkmOpS8GIW9rp1eJJ4Tr/s1600/oie_29204512mwM33QVz.jpg" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjMzS2XUSdV9QnOHCKciyH_E0cL9p_FAhy-SdMTCehxhW1MRuTvCXPNjxRpssrMoFXrjzEhn04R7lLWmtlNwX8l5X3nu0H1b5ccDv9OP_P-zUolD6z7hXEJSpYRQkmOpS8GIW9rp1eJJ4Tr/s320/oie_29204512mwM33QVz.jpg"></a>
<BR>
Enjoy xDRey Dacocohttp://www.blogger.com/profile/16795901672669072701noreply@blogger.com0tag:blogger.com,1999:blog-7232556147893180475.post-25719491018316821122014-04-03T02:44:00.001-07:002019-01-07T18:49:52.322-08:00BEAM Walking RobotsHey all, I’l be writing some programming guide as soon as I can but for the moment, just wanna share these awesome walking robots made by my former students.
<BR>
<BR>
This one is a coat hanger walker based on the book “Absolute Beginners Guide in Building Robot’s” by Gareth Branwyn.
<BR>
<BR>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgguSR-8Wql5RuG8GrCXXHbINAhHfRW_8i20bh5UseWPrxXwJvFv6YjiqUaSa0rvFJK9lKPTtN8D4VIbkpeVf9pvBDWVPbBZKx8J_JjM6FTSw3X8K9qOBW7fww1mivnF72LDfUzOMWYh9Lh/s1600/chwalker.jpg" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgguSR-8Wql5RuG8GrCXXHbINAhHfRW_8i20bh5UseWPrxXwJvFv6YjiqUaSa0rvFJK9lKPTtN8D4VIbkpeVf9pvBDWVPbBZKx8J_JjM6FTSw3X8K9qOBW7fww1mivnF72LDfUzOMWYh9Lh/s1600/chwalker.jpg"></a>
<BR>
<BR>
And here's another very simple BEAM walking robot made from old toy gears. Enjoy :D
<BR>
<BR>
<CENTER><iframe allowfullscreen="" frameborder="0" height="270" src="//www.youtube.com/embed/49RsMc1WeXc" width="480" align="center"></iframe></CENTER>Rey Dacocohttp://www.blogger.com/profile/16795901672669072701noreply@blogger.com0tag:blogger.com,1999:blog-7232556147893180475.post-74866744338018552392013-12-16T20:29:00.000-08:002019-01-07T19:00:55.318-08:00BEAM Solar RollersBEAM Solar Rollers are solar-powered wheelers that move in short distances. Here are some of the solar rollers made by my students. This is based on Mark Tilden’s “Junk Bots, Bug bots, and Bots on Wheels: Building Simple Robots with BEAM Technology”. Apart from being simple intelligent agents, they are actually very cool items to give as gifts.
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjD1widbIMUmdwkia3ijeOOt1jl49w3DKrkjYCfx-YwQe6YLmkE2rezwt2MgM2DWVENdPw-KWi1ZQlE-gL0xtz3QJ1wTpYf5rANYH0Co6CzD0sClsBfXZA1zmYcKzkxal6lsTkwlt2RvYyo/s1600/solar.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjD1widbIMUmdwkia3ijeOOt1jl49w3DKrkjYCfx-YwQe6YLmkE2rezwt2MgM2DWVENdPw-KWi1ZQlE-gL0xtz3QJ1wTpYf5rANYH0Co6CzD0sClsBfXZA1zmYcKzkxal6lsTkwlt2RvYyo/s1600/solar.jpg"></a></div>Rey Dacocohttp://www.blogger.com/profile/16795901672669072701noreply@blogger.com0tag:blogger.com,1999:blog-7232556147893180475.post-31479520063163298742013-10-04T23:35:00.000-07:002019-01-07T19:02:22.068-08:00Connecting BlueJ GUI Application to a MySQL Workbench Database FileHello friends! Am sure all of you newbie BlueJ user out there has probably been wondrin, “How the heck would I display my MySQL Workbench records in a BlueJ GUI application?”. Well, wonder no more because today we'll learn how to do it comprehensively.
<BR><BR>
Before we proceed to the actual step, I presume that you have a basic knowledge of developing GUI applications in BlueJ, JDBC API, and MySQL workbench. Let's proceed to the steps now shall way? I mean shall we?
<BR><BR>
1. Start MySQL workbench by clicking on Start>All Programs> MySQL>MySQL Workbench.
<BR><BR>
2. In the SQL Development pane, Double click Local instance MySql.
<BR><BR>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEit3l4daAi9l61wiyoHAxyZnzLzqI3Z3u3QOSOu6xhrypPnWFAYTuL2HsD8QUQFcx5QpoS5jaiiGuCwh93Wdm0iCpGbhmvzuO_pOhT4jUMPEyCAa3T8A7FdkXSrQ-LJuY9ViTrXkJf1_WTF/s1600/Doubleclickmysqlinstance.jpg" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEit3l4daAi9l61wiyoHAxyZnzLzqI3Z3u3QOSOu6xhrypPnWFAYTuL2HsD8QUQFcx5QpoS5jaiiGuCwh93Wdm0iCpGbhmvzuO_pOhT4jUMPEyCAa3T8A7FdkXSrQ-LJuY9ViTrXkJf1_WTF/s320/Doubleclickmysqlinstance.jpg"></a>
<BR><BR>
3. Click the “new sql tab for executing query” icon.
<BR><BR>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj2QR7NFZ9RRgkwWgGflEgGZF0UVLlxRuQkYMJAlVlnftO-i4jfSFuMDyX9W00lqNc_ngJ4ySxn5yPDTm6q8mL4KZWhqlkIiuLsdFiaY70RXdNu35GCTrUNALw1HxJhq0fhzXYANdl-Pndj/s1600/newsqltab.jpg" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj2QR7NFZ9RRgkwWgGflEgGZF0UVLlxRuQkYMJAlVlnftO-i4jfSFuMDyX9W00lqNc_ngJ4ySxn5yPDTm6q8mL4KZWhqlkIiuLsdFiaY70RXdNu35GCTrUNALw1HxJhq0fhzXYANdl-Pndj/s320/newsqltab.jpg"></a>
<BR><BR>
4. Enter the following MySQL script:
<BR><BR>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhTi9rorkQe_ASMUdFMr9sMl3ptyvtCCcK0M9lBRVoEaEcROqfdHuxVjO03xIkqpavYFpZAcUapMZ63Sm8QRCtsFJxSBFLuPejlvEzyRLMrhzfA1BfU_avoWwVzwd3jn2bNomzAu9mKpuld/s1600/sqlscript.jpg" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhTi9rorkQe_ASMUdFMr9sMl3ptyvtCCcK0M9lBRVoEaEcROqfdHuxVjO03xIkqpavYFpZAcUapMZ63Sm8QRCtsFJxSBFLuPejlvEzyRLMrhzfA1BfU_avoWwVzwd3jn2bNomzAu9mKpuld/s400/sqlscript.jpg"></a>
<BR><BR>
5. Click the “run everything” icon to execute the MySQL script.
<BR><BR>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh-RVGFRoTHviI6vjMTOn7bI4eI3saQbj4ZLtzKs78WpnJgjPe2G8JYlV_o-tpoWkT7hlHe01Wd4IAnTGIvb7vosjMEI4kT_bz1np5eFi_O3z9luwlZ6XdoR5uDnSKGHc-XZSzMdlV_5qHh/s1600/runall.jpg" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh-RVGFRoTHviI6vjMTOn7bI4eI3saQbj4ZLtzKs78WpnJgjPe2G8JYlV_o-tpoWkT7hlHe01Wd4IAnTGIvb7vosjMEI4kT_bz1np5eFi_O3z9luwlZ6XdoR5uDnSKGHc-XZSzMdlV_5qHh/s320/runall.jpg"></a>
<BR><BR>
What we have done so far is we've created a database file named dbNames and a user to that database named dbusername. We've also use dbpassword as our password. Additionally, we have a created a table named tblNames inside our dbNames database and added two records to it. What we are going to do next is we will create our Blue GUI application and then later on, we'll connect it to our database file.
<BR><BR>
6. Start BlueJ now by clicking on>BlueJ>BlueJ.
<BR><BR>
7. Click Project>New Project> Enter your desired project name>Create.
<BR><BR>
8. Click the New Class button>Enter “UseJDBC” as a class name no quotes. Use class as a class type then click OK.
<BR><BR>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgP460P94zVLAbao4n3GfbkSZXavs11sgBJUM5Tl3MrGa_RH5klQO15HBt9s-7jotNAHNQJZkbETiIpjZhyYvmAPBKNwdOsQCBodKAB4SPX3sXDxvwvlqzKWv0xJkHLy65cDLjnwQFSRb8m/s1600/new+class.jpg" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgP460P94zVLAbao4n3GfbkSZXavs11sgBJUM5Tl3MrGa_RH5klQO15HBt9s-7jotNAHNQJZkbETiIpjZhyYvmAPBKNwdOsQCBodKAB4SPX3sXDxvwvlqzKWv0xJkHLy65cDLjnwQFSRb8m/s320/new+class.jpg"></a>
<BR><BR>
9. Double-click the UseDBC class.
<BR><BR>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSFUznVyxwiMSI4L1iDusYzF6nfWIWtL2GcgeCGOAznb5W80ewa8LRhOShpwqqesd7vFzCHRNUBh54fdb7bxRui_UOxUkcnQfpqQlAutb6Cpi2v9JHGlezAUrgNxqbOnzJGmXWso_OUFY2/s1600/UseJDBC.jpg" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSFUznVyxwiMSI4L1iDusYzF6nfWIWtL2GcgeCGOAznb5W80ewa8LRhOShpwqqesd7vFzCHRNUBh54fdb7bxRui_UOxUkcnQfpqQlAutb6Cpi2v9JHGlezAUrgNxqbOnzJGmXWso_OUFY2/s320/UseJDBC.jpg"></a>
<BR><BR>
10. Press Control + A> then press Delete to delete all BlueJ's pre-written code, then enter the following codes:
<BR><BR>
<pre class="java" name="code">
/*imports the required packages*/
import javax.swing.*;
import java.awt.*;
import java.sql.*;
/*Creates a class named UseJDBC. extends JFrame means that UseJDBC is not just some class
it's also a Frame */
public class UseJDBC extends JFrame
{
/* Create a container named ca.*/
Container ca=getContentPane();
/* Create a borderlayout which will be used later to position our panel1
on the north portion of the container*/
BorderLayout border=new BorderLayout(2,2);
/* Create a gridlayout with 3 rows and 2 columns.
Will be used to arrange our labels and textfields in a grid format*/
GridLayout grid=new GridLayout(3,2,1,1);
/*Create a panel named panel1. this is where we will add our controls later*/
JPanel panel1=new JPanel();
/*Creates our textboxes where we want o display our records later*/
JTextField IDtextbox=new JTextField();
JTextField Fnametextbox=new JTextField();
JTextField Lnametextbox=new JTextField();
public UseJDBC()
{
/*Applies the borderlayout to our container*/
ca.setLayout(border);
/*Applies the gridlayout to our panel*/
panel1.setLayout(grid);
/*Add our controls to the panel*/
panel1.add(new JLabel("ID:"));
panel1.add(IDtextbox);
panel1.add(new JLabel("Firstname:"));
panel1.add(Fnametextbox);
panel1.add(new JLabel("Lastname:"));
panel1.add(Lnametextbox);
/*Adds the panel to our container and position it to the north(top)
* portion of the container
*/
ca.add(panel1,BorderLayout.NORTH);
/*Setup our frame*/
setContentPane(ca);
setSize(294,155);
setLocation(0,0);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setTitle("View Records");
setVisible(true);
/* Creates a connection object named connectionobj*/
Connection connectionobj;
try {
/*Creates a new instance of our jdbc driver*/
Class.forName("com.mysql.jdbc.Driver").newInstance();
/*Connect to our database named dbNames using the
username dbusername and password dbpassword*/
connectionobj = DriverManager.getConnection( "jdbc:mysql://localhost:3306/dbNames","dbusername","dbpassword");
/*Create a statement object named statementobj*/
Statement statementobj = connectionobj.createStatement() ;
/*Specify how we want to retrieve the record from MySQL Workbench
* by using the executeQuery method of our statement object. Since we want all records from
* all columns so we entered "Select * from tblNames" as a sql statement
* The resultset will be stored in a variable named resultSet
*/
ResultSet resultSet = statementobj.executeQuery( "SELECT * From tblNames" ) ;
/*Points the record pointer to the first record*/
resultSet.first( );
/*Retrieve the values of each fieldname or columns and store it to our local variables*/
String strid = Integer.toString(resultSet.getInt("intid"));
String strfname = resultSet.getString("chrfname");
String strlname = resultSet.getString("chrlname");
/*Display our first records on their appropriate controls*/
IDtextbox.setText(strid);
Fnametextbox.setText(strfname);
Lnametextbox.setText(strlname);
/*Close the database connection*/
connectionobj.close() ;
}
catch (Exception e)
{
}
}
/* Creates our main method*/
public static void main (String[] args)
{
UseJDBC UseJDBCinstance=new UseJDBC();
}
}
</pre>
<BR><BR>
11. Before we run our application. Ensure that MySQL Connector J has been added to BlueJ's user library. There are two ways to do this:
<BR><BR>
a. Download mysql-connector-java-5.1.25-bin.jar from MySQL.org. Extract downloaded file then copy
mysql-connector-java-5.1.25-bin.jar to C:\Program Files\BlueJ\lib\userlib.
<BR><BR>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0r2OeqYoERA96tbSbU-k8RRi9tpW7_AQErin7Friq7-y9kH8YdfF8INQBjaytGrw052eZlVv6O1leadqIeSacdkrhoD0ooBiMjB2dLkeZASewoXnjoV1y6BMn4mCeYZAPVRIjP4aGut4_/s1600/mysqlconnectorjuserlib.jpg" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0r2OeqYoERA96tbSbU-k8RRi9tpW7_AQErin7Friq7-y9kH8YdfF8INQBjaytGrw052eZlVv6O1leadqIeSacdkrhoD0ooBiMjB2dLkeZASewoXnjoV1y6BMn4mCeYZAPVRIjP4aGut4_/s320/mysqlconnectorjuserlib.jpg"></a>
<BR><BR>
b. Alternatively, in the BlueJ menu bar, click Options>Preferences>Libraries>Add>Locate and select your mysql-connector-java-5.1.25-bin.jar file>then click open.
<BR><BR>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhSx3JBX8ppiwrDzch5KaSoBexUCLX-lCQ0gOzlsGLdU2iX9T-_aQujCTR2GqXyYprsruBjYD5-ojUhsgxKgHxW6_ajHcMWtK2bgeicp9VwaRiwUInpq-yNfl5VCA7aTki7blHhNiGthM6_/s1600/librariesadd.jpg" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhSx3JBX8ppiwrDzch5KaSoBexUCLX-lCQ0gOzlsGLdU2iX9T-_aQujCTR2GqXyYprsruBjYD5-ojUhsgxKgHxW6_ajHcMWtK2bgeicp9VwaRiwUInpq-yNfl5VCA7aTki7blHhNiGthM6_/s320/librariesadd.jpg"></a>
<BR><BR>
12. Now that we have added MySQL connector-J to user libraries. Let's view our code once again and this time I've omitted the comments coz it's kinda messy or something.
<BR><BR>
<pre class="java" name="code">
import javax.swing.*;
import java.awt.*;
import java.sql.*;
public class UseJDBC extends JFrame
{
Container ca=getContentPane();
BorderLayout border=new BorderLayout(2,2);
GridLayout grid=new GridLayout(3,2,1,1);
JPanel panel1=new JPanel();
JTextField IDtextbox=new JTextField();
JTextField Fnametextbox=new JTextField();
JTextField Lnametextbox=new JTextField();
public UseJDBC()
{
ca.setLayout(border);
panel1.setLayout(grid);
panel1.add(new JLabel("ID:"));
panel1.add(IDtextbox);
panel1.add(new JLabel("Firstname:"));
panel1.add(Fnametextbox);
panel1.add(new JLabel("Lastname:"));
panel1.add(Lnametextbox);
ca.add(panel1,BorderLayout.NORTH);
setContentPane(ca);
setSize(294,155);
setLocation(0,0);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setTitle("View Records");
setVisible(true);
Connection connectionobj;
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
connectionobj = DriverManager.getConnection( "jdbc:mysql://localhost:3306/dbNames","dbusername","dbpassword");
Statement statementobj = connectionobj.createStatement() ;
ResultSet resultSet = statementobj.executeQuery( "SELECT * From tblNames" ) ;
resultSet.first( );
String strid = Integer.toString(resultSet.getInt("intid"));
String strfname = resultSet.getString("chrfname");
String strlname = resultSet.getString("chrlname");
IDtextbox.setText(strid);
Fnametextbox.setText(strfname);
Lnametextbox.setText(strlname);
connectionobj.close() ;
}
catch (Exception e)
{
}
}
public static void main (String[] args)
{
UseJDBC UseJDBCinstance=new UseJDBC();
}
}
</pre>
<BR><BR>
13. Click the compile button to convert our source code into byte code.
<BR><BR>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgouSdBvFVAIbgFVKnkPAl761GfLlRaGAh1uLyJb3A0JmpG8eM2IfUTrHL95W29seIdWduSmu1eLtmPTeZrs2cxLa9IlfCnKMHFHRklLNdxymH4T1SvSEfB-X555TPcEXWWGinK11AsQO0a/s1600/compile.jpg" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgouSdBvFVAIbgFVKnkPAl761GfLlRaGAh1uLyJb3A0JmpG8eM2IfUTrHL95W29seIdWduSmu1eLtmPTeZrs2cxLa9IlfCnKMHFHRklLNdxymH4T1SvSEfB-X555TPcEXWWGinK11AsQO0a/s320/compile.jpg"></a>
<BR><BR>
14. Click the close button on your source code window.
<BR><BR>
15. Right-click your UseJDBC class>Select void main string[] args>Ok.
<BR><BR>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgHBiQ1dcro9YSbasQ4jza2nKTBACQOp0lKhANFVbZVB-VnlcORDKgmOArkGG-mVjzYrZDoqvc_PfQ7hcZlFM8cjerFogXZjFkfNDOfiQbMMZAcw-CBdnbdiWZKXAhqBXUvdRV4CNfUq0PH/s1600/rightclickvoidstringmainargs.jpg" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgHBiQ1dcro9YSbasQ4jza2nKTBACQOp0lKhANFVbZVB-VnlcORDKgmOArkGG-mVjzYrZDoqvc_PfQ7hcZlFM8cjerFogXZjFkfNDOfiQbMMZAcw-CBdnbdiWZKXAhqBXUvdRV4CNfUq0PH/s320/rightclickvoidstringmainargs.jpg"></a>
<BR><BR>
16. You should now see the following output.
<BR><BR>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAnfKd_qajUSbMUeqvk0_oyXQEUS5ZrWc-W0rg7NzqcsuCVPgBdyfcdHI7VaPBvwG81ctmuFAip5ULiibPLHQsJX2GZIrEeUFYnjt3TsLhjhRrsGNWj9VZkE2mYxv_nY2A6uK34lUnZWLI/s1600/output.jpg" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAnfKd_qajUSbMUeqvk0_oyXQEUS5ZrWc-W0rg7NzqcsuCVPgBdyfcdHI7VaPBvwG81ctmuFAip5ULiibPLHQsJX2GZIrEeUFYnjt3TsLhjhRrsGNWj9VZkE2mYxv_nY2A6uK34lUnZWLI/s320/output.jpg"></a>
<BR><BR>
17. And that's all. Awesome right? Kiddin.Rey Dacocohttp://www.blogger.com/profile/16795901672669072701noreply@blogger.com1tag:blogger.com,1999:blog-7232556147893180475.post-43305410411030895342013-04-28T23:04:00.001-07:002019-01-07T19:04:29.813-08:00Printing Images in Visual FoxPro 9.0There are plenty of ways to do this and one of the easiest way by far is by using reports but since I can’t help but be attached to old things, we’ll do it the old way, the FoxPro for DOS way.
<BR>
1. Design your form as follows:
<BR>
<BR>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihMwbrTs-FricsjMxaiuNLuKdBe-vRrDWgDkR73OrRn1k10UE3yerLRKI3vQTVktp1-i_MRRBc2Me1ceIqvsCFib_1SMeOA-yOJAygutECzVZUQy-Dda1ydrQTZau3wamGHIw9lCPAn_TF/s1600/PrintImagesScreenshot.png" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihMwbrTs-FricsjMxaiuNLuKdBe-vRrDWgDkR73OrRn1k10UE3yerLRKI3vQTVktp1-i_MRRBc2Me1ceIqvsCFib_1SMeOA-yOJAygutECzVZUQy-Dda1ydrQTZau3wamGHIw9lCPAn_TF/s320/PrintImagesScreenshot.png"></a>
<BR>
2. Double-click the control named PrintButton and enter the following:
<BR>
<pre class="c++" name="code">
*Turns on the printer
SET PRINTER ON
*Prevent the data being printed from appearing on the screen
SET CONSOLE OFF
*Sends whatever specified in the @SAY command directly to the printer
*This is one of the important lines of code, without this, the image
* will not be printed at all
SET DEVICE TO PRINTER
*Displays an explainatory text just to let the user know that the data is being printed
WAIT WINDOW 'Printing...' TIMEOUT 3
*Displays our image in a specified row and column coordinate
*We use stretch so that the size of the image will adjust to
*the size of the image control
@ 1,5 SAY Thisform.iconimagecontrol.picture BITMAP SIZE 5,10 STRETCH
* Displays our text
@ 6,5 SAY 'Application Name:' + thisform.Appnamelabel.Caption
*Ejects the paper
EJECT
*Stops sending data to the printer
SET PRINTER OFF
</pre>
3. Here's the code again and this time I’ve omitted the comments coz it's kinda messy or something:
<pre class="c++" name="code">
SET PRINTER ON
SET CONSOLE OFF
SET DEVICE TO PRINTER
WAIT WINDOW 'Printing...' TIMEOUT 3
@ 1,5 SAY Thisform.iconimagecontrol.picture BITMAP SIZE 5,10 STRETCH
@ 6,5 SAY 'Application Name:' + thisform.Appnamelabel.Caption
EJECT
SET PRINTER OFF
</pre>
<BR>
4. Double-click the ExitButton and enter the following:
<BR>
<pre class="c++" name="code">
*Quits the form
RELEASE THISFORM
</pre>
<BR>
5. Click the Run icon or press CTRL + E> Click the Print button. Here’s a sample print out of how it should look like. I’ve tried it using EPSON LX 300 printer.
<BR>
<BR>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiC5HieW9qGU3YRt7tipcHUf3bFGaVs836k2AqmSx1D_TxPfR7119HLz_Dsuqz3OegEij2ULJWrS0MRanEomBaP8G8RBB7nE7Vxc1OvLjbBU7ITkXFbgA8ggBW5ZYuxWdJGyjKKgL-PpTES/s1600/941523_10152500952673538_628358673_n.jpg" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiC5HieW9qGU3YRt7tipcHUf3bFGaVs836k2AqmSx1D_TxPfR7119HLz_Dsuqz3OegEij2ULJWrS0MRanEomBaP8G8RBB7nE7Vxc1OvLjbBU7ITkXFbgA8ggBW5ZYuxWdJGyjKKgL-PpTES/s320/941523_10152500952673538_628358673_n.jpg"></a>
<BR>
6. So there...
Rey Dacocohttp://www.blogger.com/profile/16795901672669072701noreply@blogger.com0tag:blogger.com,1999:blog-7232556147893180475.post-34836965060220244862013-03-18T00:39:00.000-07:002019-01-07T19:06:29.044-08:00Bicore HeadbotBicore Headbot is a photovore(light seeking robot) that looks for the brightest light source and turns its head there. Here is a bicore headbot made by one of my appreciated students whose name you’ll see at the end of the video. This was based on the book “JunkBots, Bugbots, and Bots on Wheels:Building Simple Robots using BEAM technology” by Mark Tilden. Enjoy!
<BR><BR>
<iframe width="560" height="315" src="https://www.youtube.com/embed/_7uqnhomLnY" frameborder="0" allowfullscreen></iframe>Rey Dacocohttp://www.blogger.com/profile/16795901672669072701noreply@blogger.com0tag:blogger.com,1999:blog-7232556147893180475.post-17600206799729089172012-11-30T21:28:00.000-08:002019-01-07T19:12:02.858-08:00Make your very own game using Visual C++ Express Edition (or in any PL)
I’m sure you all have heard of “Guess the number” game. Well who hasn’t. It’s practically in every programming book of every programming languages by every programming authors. The reason perhaphs is you can actually make billions of games from it. All you need to do is make up some weird stories with number guessing involved in there then you are good to go. Here are some examples:
<BR><BR>
1. Mind Reader Game
<BR>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhlR-CfduAbVPGuliRHDjJKpeADywWrho5JhB6K2Iy9rvQrhTB1p3OQZq8lU5j-VUVgwB7-WIGoa-YewfRsMBORRTp5wTqz0Y5CPV7g-WZkXVyjzHznhOt8J4KrzhcADDFi0AWSbX7Msplo/s1600/2012-12-02+12_06_14-Mind++Reader.png" imageanchor="1" style=""><img border="0" height="315" width="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhlR-CfduAbVPGuliRHDjJKpeADywWrho5JhB6K2Iy9rvQrhTB1p3OQZq8lU5j-VUVgwB7-WIGoa-YewfRsMBORRTp5wTqz0Y5CPV7g-WZkXVyjzHznhOt8J4KrzhcADDFi0AWSbX7Msplo/s400/2012-12-02+12_06_14-Mind++Reader.png"></a>
<BR>
Here's the code:
<BR>
<pre class="c++" name="code">
#pragma endregion
//declare two variables. intrandom will handle the generated random numbers
//intcounter will handle the number of incorrect guesses
int intrandom;
int intcounter;
private: System::Void guessbutton_Click(System::Object^ sender, System::EventArgs^ e) {
//create a random object named randgen based on the Random class
Random^ randgen=gcnew Random();
//generate a random number from 1 to 31 and store the generated number into a variable named intrandom
intrandom=randgen->Next(1,31);
//if the date inputted by the user is lesser than the generated number
if (int::Parse(this->datetextBox->Text)<intrandom)
{
//display this message
this->statuslabel->Text="Sorry. Your guess is wrong. Perhaps you need some crystal ball?";
//if its lesser than the generated number obviously the user has guessed it wrong so we acummulate the value
//of the intcounter variable.
intcounter=intcounter + 1;
}
//if its greate than the generated number
else if (int::Parse(this->datetextBox->Text)>intrandom)
{
//display this message
this->statuslabel->Text="It's not what the audienced had picked.Perhaps you need some chant or something.";
//if its greater than the generated number obviously the user has guessed it wrong again so we acummulate the value
//of the intcounter variable.
intcounter=intcounter + 1;
}
else
{
//if the user has guessed it right. display the follwing message and disable the textbox.
this->statuslabel->Text="You guessed it right. Congratulations! You are now a fullfledge magician.";
this->datetextBox->Enabled=false;
}
//if the user has guessed it wrong thrice
if ( intcounter>2)
{
//dsiplay this then disbale the textbox.
this->statuslabel->Text="You have failed the test. Your remaining magic powers will be taken from you.";
this->datetextBox->Enabled=false;
}
}
};
}
</pre>
<BR><BR>
2. Oil Magnate Game
<BR>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNZd8cxM4DKuREalurCo3yetL_wAd0cmhAgc-ZdRVD0MVMU-rjH32MtjqTmvbUKjGlV0y_uADk04-qv6uO4rjkAvnAq7EIrInbw7MjJtFLCgfJEzPhMguG2Rnfigkf01FTMblLeAwuShW7/s1600/2012-12-02+12_29_54-Oil+Magnate.png" imageanchor="1" style=""><img border="0" height="315" width="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNZd8cxM4DKuREalurCo3yetL_wAd0cmhAgc-ZdRVD0MVMU-rjH32MtjqTmvbUKjGlV0y_uADk04-qv6uO4rjkAvnAq7EIrInbw7MjJtFLCgfJEzPhMguG2Rnfigkf01FTMblLeAwuShW7/s400/2012-12-02+12_29_54-Oil+Magnate.png"></a>
<BR>
Here's the code:
<BR>
<pre class="c++" name="code">
#pragma endregion
//I wont add comments on this one coz it’s practically the same code. we only //added random responses from the user if the answer is the answer is wrong
int intrandom;
int intcounter;
private: System::Void guessbutton_Click(System::Object^ sender, System::EventArgs^ e) {
Random^ randgen=gcnew Random();
intrandom=randgen->Next(20,50);
if (int::Parse(this->agetextBox->Text)<intrandom)
{
intrandom=randgen->Next(1,2);
if (intrandom==1)
{
this->statuslabel->Text="Im flattered but I'm not that young.";
}
else
{
this->statuslabel->Text="I have a feeling that you are just making fun of me.";
}
intcounter=intcounter + 1;
}
else if (int::Parse(this->agetextBox->Text)>intrandom)
{
intrandom=randgen->Next(1,2);
if (intrandom==1)
{
this->statuslabel->Text="That's rude, I'm not that old.";
}
else
{
this->statuslabel->Text="Are you stupid or something?";
}
intcounter=intcounter + 1;
}
else
{
this->statuslabel->Text="Congratulations! You have won the 3 billion dollars.";
this->agetextBox->Enabled=false;
}
if ( intcounter>2)
{
this->statuslabel->Text="You have used the maximum number of guesses and won nothing.";
this->agetextBox->Enabled=false;
}
}
};
}
</pre>
So there...enjoy game programming :)Rey Dacocohttp://www.blogger.com/profile/16795901672669072701noreply@blogger.com0tag:blogger.com,1999:blog-7232556147893180475.post-73162839605237404652012-11-18T20:22:00.000-08:002019-01-07T19:18:51.169-08:00Say "Hello" to Blender and Flash
I have not written any programming guide in a while now coz I’m sort of in a “hiatus” or something. But I’ll post some as soon as my dopamine level rises up.
<BR><BR>
Meanwhile, if you are interested in things that move i.e. computer graphics, some of the great computer graphic softwares out there are Blender 3D and Adobe Flash.
<BR><BR>
Here are some of the basic animations that you can do with flash. These are made by my former students, I captured them using KRUTS and edited using PD11. Enjoy!
<BR><BR>
<iframe width="560" height="315" src="https://www.youtube.com/embed/SSljt66bTKc?rel=0" frameborder="0" allowfullscreen></iframe>
<BR><BR>
Here are some of the basic blender animations that you can do with blender. These are made by my former apprentices, you’ll see their names at the end of the movie. Anyways, enjoy!
<BR><BR>
<iframe width="420" height="315" src="https://www.youtube.com/embed/7_72u4T_ye4?rel=0" frameborder="0" allowfullscreen></iframe>Rey Dacocohttp://www.blogger.com/profile/16795901672669072701noreply@blogger.com0tag:blogger.com,1999:blog-7232556147893180475.post-75585921985965070592012-10-29T18:34:00.000-07:002019-01-07T19:20:16.835-08:00Mousey the JunkbotMousey the Junkbot is a photovore(light-seeking robot) originally developed by Gareth Branwyn. It uses an old analog mouse, motors, light sensors. etc. It's not quite complicated to make and the steps in building it are readily available in the Internet. So if you have an idle time and you want to feel a sense of fulfillment or something, go ahead and build one.
<br>
<br>
Here’s a mobile video of a robot mouse made by one of my very appreciated minions.Lol. Enjoy!
<br><br>
<iframe width="420" height="315" src="https://www.youtube.com/embed/nkRxAu42ySE" frameborder="0" allowfullscreen></iframe>Rey Dacocohttp://www.blogger.com/profile/16795901672669072701noreply@blogger.com0tag:blogger.com,1999:blog-7232556147893180475.post-52482570933959129062012-09-25T20:31:00.000-07:002019-01-07T19:21:20.936-08:00How To Install WordPress On A Web Server Without MySQL Or CPANELToday we’ll be learning how to install WordPress on a web server without a CPANEL or MySQL database, just pure FTP. I’m sharing this because I run into similar problem before. The ftp server on the site that I’ve developed is not synchronized with my web server’s CPANEL thereby making it impossible to connect the database that I made there. It almost drive me crazy or something. I’ve searched the net for answers, but I haven’t found any clear solutions there and so I decided to do something about it. That’s like life actually, either you accept things as it is or you do something about it. Just kiddin.
<BR>
The solution is surprisingly simple, upload WordPress on your ftp server, and since you don’t have a CPANEL, you can create a MySQL database using a free data provider outside of your web server such as <a href="http://www.freemysql.net/">freemysql.net</a> or <a href="http://www.freesql.org/">freesql.org</a> . The details are listed in the following steps:
<BR>
1. Download the latest version of WordPress from http://wordpress.org/.
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh330qPOh_BWAitV9lYDT53JuTgDtW9NGz9DUxjVJXdqnD5RBr15PglEopDOq09OJH9Nz7SwQ4oClgxhEENw5aiwW7xUKwl91-X__aC3eGqbkHKF5QVyS3hfG1NiBgzsmUB5crAFkYeL3zp/s1600/downloadwp.png" imageanchor="1" style=""><img border="0" height="47" width="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh330qPOh_BWAitV9lYDT53JuTgDtW9NGz9DUxjVJXdqnD5RBr15PglEopDOq09OJH9Nz7SwQ4oClgxhEENw5aiwW7xUKwl91-X__aC3eGqbkHKF5QVyS3hfG1NiBgzsmUB5crAFkYeL3zp/s320/downloadwp.png"></a>
<BR>
2. Extract the downloaded files.
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXJ9QU9Fek2jkbYQL4KhwhQL8nUaBzBjf1Q7mHR4kUpE4VQND31b3uKozCfl-6ayHv2h4BqBEIlUNH8LQLsR8UN5_g-eaHHhY0rm1Xi0QMK_RwEgPd1_fQjyNf_m6eYY35tmg2XhPC7Sej/s1600/wpextract.png" imageanchor="1" style=""><img border="0" height="320" width="198" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXJ9QU9Fek2jkbYQL4KhwhQL8nUaBzBjf1Q7mHR4kUpE4VQND31b3uKozCfl-6ayHv2h4BqBEIlUNH8LQLsR8UN5_g-eaHHhY0rm1Xi0QMK_RwEgPd1_fQjyNf_m6eYY35tmg2XhPC7Sej/s320/wpextract.png"></a>
<BR>
3. Start Filezilla(If you don’t have Filezilla installed, you can download it from http://sourceforge.net/projects/filezilla/files/FileZilla_Client/3.5.3/FileZilla_3.5.3_win32-setup.exe)>Enter your FTP server host, username and password then click quick connect.
<BR><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjBlROErEJs0hUECT0TJ9ZQfZCSP5Z1pKgTu5Nox3cumepcbhd4wMthrlO2lSMQi8gom4PLKFCbxLhLeT09jHOmYHWdy8CninIwpwDwhN45Rc1dLdk8Bq1l_RYH9VuKPTDnJR6fH80ptXpY/s1600/filezilla.png" imageanchor="1" style=""><img border="0" height="245" width="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjBlROErEJs0hUECT0TJ9ZQfZCSP5Z1pKgTu5Nox3cumepcbhd4wMthrlO2lSMQi8gom4PLKFCbxLhLeT09jHOmYHWdy8CninIwpwDwhN45Rc1dLdk8Bq1l_RYH9VuKPTDnJR6fH80ptXpY/s320/filezilla.png"></a>
<BR>
4. Upload the contents of the wordpress folder to the public_html folder.
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMLYdAO3quLI1pE_10ig4rneYwepgnELBFXq2lqwRA1P5LVMppZ23biAPtGG06_JCvNrmCQf0UuBuQ_rtdzIjX4aDSfTP6X583DJ7xt_Un3RYpW2-Uk9ajypFyIyfzlaXSOGXwVYTtOFvc/s1600/filezillauploadwp.png" imageanchor="1" style=""><img border="0" height="307" width="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMLYdAO3quLI1pE_10ig4rneYwepgnELBFXq2lqwRA1P5LVMppZ23biAPtGG06_JCvNrmCQf0UuBuQ_rtdzIjX4aDSfTP6X583DJ7xt_Un3RYpW2-Uk9ajypFyIyfzlaXSOGXwVYTtOFvc/s400/filezillauploadwp.png"></a>
<BR>
5. Open your web browser. Enter the URL of your site on the address bar.
<BR>
6. Click Create Configuration File>Let’s Go button. The following should then appear.<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgBfWVY8CWQ1ORUrjXmPlgb_4yCu_u9v89ZRgd7xwUmdLBz26FgTn_Djy_16kRtJZjLGHwgMBYyoAKarEx3QXQ4NPH736i88L3_aZY5AzgFQza376hFks0uHRkGFF_10vCIMxLr7N3RfBB5/s1600/wpconfig.png" imageanchor="1" style=""><img border="0" height="291" width="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgBfWVY8CWQ1ORUrjXmPlgb_4yCu_u9v89ZRgd7xwUmdLBz26FgTn_Djy_16kRtJZjLGHwgMBYyoAKarEx3QXQ4NPH736i88L3_aZY5AzgFQza376hFks0uHRkGFF_10vCIMxLr7N3RfBB5/s400/wpconfig.png"></a>
<BR>
7. Since we do not have CPanel and we can’t obviously create a MySQL database file which is needed in this window>Press CTRL + N. This will open up a new browser window. Enter freemysql.net in the address bar. The following should then appear:
<BR><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhI8RzoECweWYu7qCUgAPc3i5vGYz_i0r0MQTilORbryvZl8Kx_984DIuz18uSRtOCRpRyq-fQR7dL4YbehDdI60IABzntp3cIiZXrAaBemTiFKO9XlVB5pIrwWzGugE1rMYXxr0YNiXqIf/s1600/freemysql.png" imageanchor="1" style=""><img border="0" height="95" width="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhI8RzoECweWYu7qCUgAPc3i5vGYz_i0r0MQTilORbryvZl8Kx_984DIuz18uSRtOCRpRyq-fQR7dL4YbehDdI60IABzntp3cIiZXrAaBemTiFKO9XlVB5pIrwWzGugE1rMYXxr0YNiXqIf/s400/freemysql.png"></a>
<BR>
Freemysql.net is a great site that offers free MySQL database storage for FREE.
<BR>
<BR>
8. Click the client area> then register.
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4AMBImfrg3CM1QTVTTvp9WfZrGh2aNw4JjEYJ8tm4G867aVjoL4K3N4ebopAEjKRsWv3hYIXVzBl7mPT6vFxFhgquOYWDeY5W_jNkBfhlN9aEdGAIRw3GYS1LbxQj4tgHsRmxwI8opkd2/s1600/freemysqlreg.png" imageanchor="1" style=""><img border="0" height="234" width="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4AMBImfrg3CM1QTVTTvp9WfZrGh2aNw4JjEYJ8tm4G867aVjoL4K3N4ebopAEjKRsWv3hYIXVzBl7mPT6vFxFhgquOYWDeY5W_jNkBfhlN9aEdGAIRw3GYS1LbxQj4tgHsRmxwI8opkd2/s400/freemysqlreg.png"></a>
<BR>
9.After you have registered. Login to your account and create a MySQL database file. Remember the name of the database file that you have made because that will be used as your wordpress database name.
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjog58MaaJnuDASAgD85nUP2uiPLJecsiMOtbHp-1Zl-ytDqPJjtefB72MJA6I1DfyT2bOcxVDjpY8PBGEI3gdxsquIoH5XJ7GbGl3a8ptg_EaoHsuLd69h0fWv8szno-UkcLy_CkDXl-Te/s1600/wordpressdb.png" imageanchor="1" style=""><img border="0" height="144" width="389" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjog58MaaJnuDASAgD85nUP2uiPLJecsiMOtbHp-1Zl-ytDqPJjtefB72MJA6I1DfyT2bOcxVDjpY8PBGEI3gdxsquIoH5XJ7GbGl3a8ptg_EaoHsuLd69h0fWv8szno-UkcLy_CkDXl-Te/s400/wordpressdb.png"></a>
<BR>
10. If you look on the bottom of your freemysql.net account, you will see your host or server name:
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgeLpFzC91Q4S0DJXG0YX20ff6tUdKMm2s2grUP7q_kuuoVma03tl7XA0Aq1M3UYA9ZYnjhRgMnt_sn2LL9gwNlvRlDi5PCgLvu7s6FWB9GMWCITWpc3r1hW7hyfLQveK-lmNlF_c_cYKyo/s1600/wordpressdatabasehost.png" imageanchor="1" style=""><img border="0" height="43" width="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgeLpFzC91Q4S0DJXG0YX20ff6tUdKMm2s2grUP7q_kuuoVma03tl7XA0Aq1M3UYA9ZYnjhRgMnt_sn2LL9gwNlvRlDi5PCgLvu7s6FWB9GMWCITWpc3r1hW7hyfLQveK-lmNlF_c_cYKyo/s400/wordpressdatabasehost.png"></a>
<BR>
11. Now switch the browser screen to your WordPress configuration file then enter your freemysql.net database credentials>Click Submit.
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgRa4NUZBQICJKZW07CPcdyBJQZMs1JyEkkDzUKgqy1hRsOPSRKFFEA0v9kxZPNlgLVfvK1GDySD1A2wxAFhR5SDZMRjfDL4B9Lj6tDyGqwr7VIYy7V13yUmB2YZ6fO_usEQ4UWc9J9hcTp/s1600/freemysqlcredentials.png" imageanchor="1" style=""><img border="0" height="288" width="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgRa4NUZBQICJKZW07CPcdyBJQZMs1JyEkkDzUKgqy1hRsOPSRKFFEA0v9kxZPNlgLVfvK1GDySD1A2wxAFhR5SDZMRjfDL4B9Lj6tDyGqwr7VIYy7V13yUmB2YZ6fO_usEQ4UWc9J9hcTp/s400/freemysqlcredentials.png"></a>
<BR>
12. Click the Run the Install button> And follow the on screen installation process to install wordpress.
<BR>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgD7PV_qrdZaVbZvuPe-9UXDTg4sJz5vFwYz3ZeNpRuIe_Pr9_ScLIqXSVgZ8vTXT5DF3J2CqC0CX7rgJ1tRb7-dAl3K1Ai8Ze096FifAiJZ3RJyWx84Y9BlCFT9kXvDL8_5aEXtx_NEkh0/s1600/runisntall.png" imageanchor="1" style=""><img border="0" height="133" width="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgD7PV_qrdZaVbZvuPe-9UXDTg4sJz5vFwYz3ZeNpRuIe_Pr9_ScLIqXSVgZ8vTXT5DF3J2CqC0CX7rgJ1tRb7-dAl3K1Ai8Ze096FifAiJZ3RJyWx84Y9BlCFT9kXvDL8_5aEXtx_NEkh0/s400/runisntall.png"></a>
<BR>
Note: For more information, visit the wordpress official installation guide here <a href="http://codex.wordpress.org/Installing_WordPress">http://codex.wordpress.org/Installing_WordPress</a>. That’s all.Rey Dacocohttp://www.blogger.com/profile/16795901672669072701noreply@blogger.com0tag:blogger.com,1999:blog-7232556147893180475.post-32155439897061134852012-09-16T23:09:00.001-07:002019-01-07T19:22:25.039-08:00Fixing the “Previous release of Microsoft Visual Studio 2008” failed error when installing SQL Server R2This error normally shows up if you try to install SQL Server R2 on a Windows machine. Unfornately, if you install Microsoft Visual Studio 2008 as the error implied, it still won’t work and it’s somewhat enough to make someone crazy or something.<br />
<br />
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbYEdutmzQF-XlEdC6pi0nsvXhzKWWM3eC8aQ-SPduodDosXBQBLodaecX3hHUFLv_0zY54lU_z-YQmHhQDLo3r88Wj6pXSUGtqiVoMScXKtFYq_S5Syt8cWdmUeR2DSg_1Lvd-fRXY5vm/s906/failed.png"></img><br />
<br />
<br />
This error could actually be fixed without installing Microsoft Visual Studio 2008. Follow these simple steps and I promise you, you will be able to install SQL Server R2 without fail. Trust me, I’ve tried it on ten (10) computers and it worked each and every time.<br />
<br />
1. Download the necessary files in installing SQL Server 2008 R2. I won’t be covering how to install SQL Server R2 here, because there are several sites on the net that already teaches people how to do that. Just do a Google search and find a site that teaches how to install SQL Server 2008 R2 step by step.<br />
<br />
2. Before you install SQL Server 2008 R2, uninstall any express edition applications such as Visual Basic Express Edition, Visual C# Express Edition and Visual Web Developer from your computer. Could be done by clicking Start>Control Panel>Add / Remove Programs> Select your Express edition file>Change/Remove >Uninstall>next>Finish.<br />
<br />
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYvw_pP-YnfpGlnH2nA27v_sMmsLAGNibtplJWK3QeGzn9V3wEWJVGV2VQKSXbSdKn9e1z2QVPdBTnimGXeuk6-_hAwEZGK4kNMfNJfzjEBVFG2pJWdbK6Vndd-V4ryYv0vQV1H99K3eCY/s938/vbunins.png"></img><br />
<br />
3. Clear the TEMP folder. Could be done by clicking the Start button>Run>Enter “%temp%” no quotes> then delete all the contents of the TEMP folder.<br />
<br />
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEijTTsD6GXc6Vzv9ghIjF3a12qATiflQNBEsxbeTkyQnSaO8tT8HOTxQpOrQpTX4g3xYDIGJSvtndi-HRBszl59PrWUoGKZY3pgvuamob3xeGPT8kRiMjOiZwiNOesSQwE46WH4v7-BIN9T/s954/temp.png"></img><br />
<br />
4. Clear the contents of the PREFETCH folder. Could be done by clicking Start>Run>Enter “Prefetch” no quotes>Ok.<br />
<br />
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhc9Sp7HqU-7uJ9WaLHNgTy9CTrbLjj_SAy3mRaZkfE8GTjzIvqxizRxOmWFWm4GfnYbhh2Crs42tp_e0SPXCPx8l5JHUHiT9O94GOffTI79TrYFYgFFIKKxFNuK3Irz7m48sX8wzUHllcR/s867/prefetch.png"></img><br />
<br />
5. After clearing the contents of the prefetch folder, restart your computer the Install SQL Server 2008 R2. That’s all! <br />
<br />
Note: This isn’t really the official way of doing this. But it worked for me and I thought it’s worth a share. Just tryin to help :)Rey Dacocohttp://www.blogger.com/profile/16795901672669072701noreply@blogger.com0tag:blogger.com,1999:blog-7232556147893180475.post-82264100638777963822012-03-14T01:07:00.025-07:002019-01-07T19:23:16.348-08:00Animating 3d models in DarkGDK using dbAppendObjectBeen watching 3d Animation tutorials lately but I’ve never really found a tutorial or detailed example for that matter that actually teaches how to animate 3d models in DarkGDK in a less unclear way. And so I’m sharing this example in hope that it will be used by some computer enthusiast out there like myself as a starting point in creating their very own 3d computer game.<br />
<br />
I have used the Babe model in this example. Babe model is a Dark Matter Model that is accesible by default when you install DarkGDK and is located at C:\Program Files\The Game Creators\Dark GDK\Media\Dark Matter Models\People. The controls and actions of our model in this example are illustrated in the following table.<br />
<br />
<table border="1"><tbody>
<tr><td>Controls</td><td>Actions</td></tr>
<tr><td>W,A,S,D</td><td>Move.x</td></tr>
<tr><td>Tab</td><td>Die.x</td></tr>
<tr><td>Q</td><td>Impact.x</td></tr>
<tr><td>No key Pressed</td><td>Idle.x</td></tr>
</tbody></table><br />
<br />
Enough said, here’s the code:<br />
<br />
<br />
<pre class="c++" name="code">// Dark GDK - The Game Creators - www.thegamecreators.com
// the wizard has created a very simple project that uses Dark GDK
// it contains the basic code for a GDK application
// whenever using Dark GDK you must ensure you include the header file
#include "DarkGDK.h"
// the main entry point for the application is this function
void DarkGDK ( void )
{
// turn on sync rate and set maximum rate to 30 fps
dbSyncOn();
dbSyncRate(30);
//loads our 3d model
//we'll be borrowing the Babe DirectX Darkmatter model
//it's included in the DarkGdk package located in
//C:\Program Files\The Game Creators\Dark GDK\Media\Dark Matter Models\People\Babe
//Just copy the contents of the Babe folder to your game project folder
dbLoadObject("H-Babe-Idle.x",2);
//Idle.x has 25 frames
//to find how how many frames there is in a .x animation
//Click Start>All Programs>The Game Creators>DarkGDK>Documentation>Information>Type "Frame"
//in the Textbox and the command used to determine the number of frames will reveal itself to you.
//appends the number of frames of the Move.x animation to the loaded model
//Move.x has 25 frames
dbAppendObject("H-Babe-Move.x",2,26);
//Attack.x has 24 frames
//adds the number of frames of Attack.x to the loaded model
dbAppendObject("H-Babe-Attack1.x",2,51);
//Die.x has 50 frames
//adds the number of frames of Die.x to the loaded model
dbAppendObject("H-Babe-Die.x",2,76);
//Impact.x has 10 frames
//adds the number of frames of Impact.x to the loaded model
dbAppendObject("H-Babe-Impact.x",2,126);
//positions the object in the -y axis cause its a little bit top aligned by default when loaded
dbPositionObject(2,0,-1,0);
while (LoopGDK())
{
//display descriptive text
dbSetTextSize(14);
dbText(10,0,"WASD-Movement");
dbText(10,10,"Spacebar-Attack.x");
dbText(10,20,"Tab-Die.x");
dbText(10,30,"Q-Impact.x");
dbText(10,40,"No key pressed-Idle.x");
//if the W or A or S or D or Spacebar or Tab or Q is pressed
if ( dbKeyState(17) || dbKeyState(31) ||dbKeyState(32) || dbKeyState(30)||dbKeyState(57) || dbKeyState(15)|| dbKeyState(16))
{
//stop the presently looping animation
dbStopObject(2);
//retrieves the object present angle
int ObjAngleY=dbObjectAngleY(2);
//determines if the object is presently looping
int looping=dbObjectLooping(2);
//if the key pressed is W
if(dbKeyState(17))
{
//move the object on the -Z axis
dbMoveObject(2,-0.05f);
//is the object presently not playing?
if (looping==0 )
{
//if yes then execute move.x
//move Move.x has 25 frames
//the number of frames from the starting frame to the ending frame must be at least 25 frames
dbLoopObject ( 2,26, 51 );
};
}
//if the key pressed is S
if (dbKeyState(31))
{
//move the object on the Z axis
dbMoveObject(2,0.05f);
//is the object currently not playing?
if (looping==0 )
{
//if yes then execute move.x
//move directx animation has 25 frames
//starting frame up to the end frame must be at least 25 frames
dbLoopObject ( 2,26, 51 );
};
}
//if the A key is pressed
if (dbKeyState(30))
{
//rotate the object along the Y axis
//for instance, if the objects current angle is 275-5
//The object will then be rotated 270 degrees which is exactly south
//from the user's POV
//the dbWrapValue is to ensure that the object rotation will not exceed 360 degrees
dbYRotateObject(2,dbWrapValue(ObjAngleY-5.0f));
}
//if the D key is pressed
if (dbKeyState(32))
{
//rotate the object along the Y axis
//for instance, if the objects current angle is 85+5
//The object will then be rotated 90 degrees which is exactly north
//from the user's POV
//the dbWrapValue is to ensure that the object rotation will not exceed 360 degrees
dbYRotateObject(2,dbWrapValue(ObjAngleY+5.0f));
}
//if the space key is pressed
if(dbKeyState(57))
{
//is the object currently not playing?
if (looping==0 )
{
//if yes then execute Attack.x
//Attack.x has 24 frames so from the starting to ending frames
//must be at least 24 frames
dbLoopObject ( 2,51,77 );
};
}
//if the Tab key is pressed
if(dbKeyState(15))
{
//is the object currently not playing?
if (looping==0 )
{
//if yes then execute Die.x
//Die.x has 50 frames so from the starting to ending frames
//must be at least 50 frames
dbLoopObject ( 2,78,127 );
};
}
//if the Q key is pressed
if(dbKeyState(16))
{
//is the object currently not playing?
if (looping==0 )
{
//if yes then execute Impact.x
//Impact.x has 10 frames so from the starting to ending frames
//must be at least 10 frames
dbLoopObject ( 2,127,137 );
};
}
}
else
//if no key is pressed
//execute Idle.x
//Idle.x has 25 frames so from the starting to the ending frames miust be at least 25 frames
{
dbLoopObject(2,1,25);
}
// update the screen
dbSync();
}
//return to windows
return;
}
</pre><br />
<br />
<br />
Another way of animating models is by using the dbShowObject and dbHideObject commands. I'll post an example of that here when I have time. If you want more information on animating darkGDK models or creating games per se, you can visit DarkGDK's official site www.thegamecreators.comRey Dacocohttp://www.blogger.com/profile/16795901672669072701noreply@blogger.com0tag:blogger.com,1999:blog-7232556147893180475.post-86167632932144865742012-03-07T01:32:00.000-08:002019-01-07T19:24:16.698-08:00Terminate an Executable Application in Visual Foxpro 9.0 at Run-time by ForceTo terminate an executable application in Visual FoxPro 9.0 at run-time, use the RUN and Taskkill command. RUN is a Visual FoxPro command that allows you to execute DOS commands, Taskkill, on the other hand, is DOS command that allows you to terminate an exe applications and processes , similar to using the task manager. For details on using the taskkill command, follow these steps:<br />
<br />
1. Click Start>Run>Type CMD> then press enter.<br />
<br />
2. In the command prompt, type TASKKILL/?.<br />
<br />
Using Run and Taskkill to terminate an executable application at run-time is essential especially if you have hidden the Visual FoxPro 9 IDE using the _SCREEN.VISIBLE command and your form just freezes when you click the Exit button, even though you have attached a THISFORM.RELEASE or whatever code to it. To see RUN and TASKKILL in action, follow these steps:<br />
<br />
<br />
1. Click Start>All Programs>Microsoft Visual FoxPro 9.0.<br />
<br />
2. Close the Task Pane Manager window.<br />
<br />
<br />
3. Let’s make a form by typing CREA FORM in the command window and pressing enter.<br />
<br />
Note: If the command window is hidden, just press CTRL + F2 to show it.<br />
<br />
4. Add two buttons to your form, Refer to the following screenshot for control names and values:<br />
<br />
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgxAKzqINgJLQvtuNPyvqdJGmmHkpM7CTX9faY1FaPwfLXy1gJjAWbX81xIIyTrwNK97dpBkI-Q543QPmiDGgIYQ9oYt6_NbBzxwf8edHyJg4-gNulpmMWyaqWU0xM-rEMFdVPVBpGG42Fu/s399/VFPterminate.png"></img><br />
<br />
<br />
5. Double-click the Terminate Ms-Word button, enter the following codes:<br />
<br />
<pre class="VB" name="code">private anyvariable
anyvariable=MESSAGEBOX(“Are you sure you want to terminate Ms-Word?”,4+32)
if anyvariable=6
RUN "Taskkill /f /im winword.exe”
ENDIF
</pre><br />
<br />
Your code window should now look like this:<br />
<br />
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj6vnzobVDel7kehqUX7BM7wReOZ4j13EHy4Sl76vAyBSQPzX7WFA-tajFeqOV7-HLn4ExAW6lOhH-mhPMyjMMci55-OQ3z69tIA189XTyI4Mubtk4ZTvn07tVKJ0if-FGWwY8ItdzOuwdO/s512/endword.png"></img><br />
<br />
6. Double-click the Terminate Visual FoxPro button, enter the following codes:<br />
<pre class="VB" name="code">private anyvariable
anyvariable=MESSAGEBOX(“Are you sure you want to terminate Ms-Word?”,4+32)
if anyvariable=6
RUN "Taskkill /f /im VFP9.exe”
ENDIF
</pre>Your code window should now look like this:<br />
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFAPbFunbBvEYI0TjFIZ8nO8hHzqusqlpTo0ux7JFCxbsZmFo9c1ZRYCk4ueVPAOeW21U3FZNOP8776sarkjjEqFtAaLQRtwDeBm-HF1WTHVSquE9BxKv11RMGxCjSsk21b4KWHonR5cOk/s583/endvfp.png"></img><br />
<br />
7. Press CTRL + F3 to test your application.<br />
<br />
8. Before Clicking the Terminate Ms-Word button, ensure that Ms-word is activated.<br />
<br />
9. Try clicking the Terminate Visual FoxPro button and see what happens. And that’s all :)Rey Dacocohttp://www.blogger.com/profile/16795901672669072701noreply@blogger.com0tag:blogger.com,1999:blog-7232556147893180475.post-84519876962084264392012-03-01T23:26:00.001-08:002019-01-07T19:25:25.461-08:00Retrieve values from another form in Visual FoxPro 9.0One of the ways to retrieve values from another form in Visual Foxpro is to use a Form Set. A Form Set (from the name itself) is a set or collection of forms. To create a Form Set, follow these steps:<br />
<br />
1. Click Start>All Programs>Visual FoxPro 9.0.<br />
2. Close the Task Pane Manager Window.<br />
3. To create a form, type CREA FORM in the command window, and then press enter.<br />
<br />
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgErWFZWYirpMBKZyulPIJRJn7q_QRsY3uybg_Gn2kc-nvqUTz17bEkH6_v2dsL3nvshL2WyywCQIDb2ZoZ2Hwarlo4pSML9t2fibvBg4TKP3Dvt9-CQ8yGyeie54xE-CpgWPSLL_HLxJjM/s341/creaform.png"></img><br />
<br />
Note: If the Command Window is not shown, Press CTRL + F2. <br />
4. A new form will now come into view.<br />
<br />
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiUsKvHOW8eDuOZPhO6mF2PsbG4X1n8QDYqP_XuraE7hW_SQTFL3RMVKM1QbukNSqpdZh9e5F7dXJn4Wat-MbxGDXTIx4Zt537R6F11Lf9meygjY1hyphenhyphengf4l0xRwT6gW3Px-sY44uSfe50zb/s393/form1.png"></img><br />
<br />
5. To create a form set, click Form>Create Form Set.<br />
<br />
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEYC9WjPf6o4nIz5aS_m3ro1s0W1nSTzro5-Zr4L0ETUq3J53sacQTtYZujH0yavuwNR2TA152TT0rUBlZVSfBmfwiYVFZE8piujaBu0-xVwmEug210cxoet1YUMGkZBGeN0fChdy4ph2h/s281/createformset.png"></img><br />
<br />
<br />
Although nothing appear to happen when you click the Create Form Set Submenu but essentially a new submenu will be enabled, the Add New Form submenu.<br />
<br />
6. To add a form to your Form Set, Click Form>Add New Form.<br />
<br />
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgzt3PLbTN-ucICi5wa_zWLxg_SPYXQZeVghXw_l9oMKwOHDiEfCljntkGyO2TT-YJkRY4dbyskUIJOCwNKKjHnUNUPcwN7LIXMMsK-lCJINv8mLBIDIhRbAxD7zJt97yUsdPzl7FdDKvV3/s280/formaddform.png"></img><br />
<br />
A new form named form2 will now be added to your Form Set. If you add another form, that form will be named form3 and so on. Repeat the step no. 6 to add one more form to your form set. Our form set will now have 3 forms named form1, form2, and form3.<br />
<br />
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXkF9TY033a-zh5-nt4P9XvQ6fHAeRdITAEOamHCJzz_9-DfqMg3zPS60vgfG10G5cmYNSopdMK-j8dDe_Wedadetalgow3H3ShDSZw5ppSBOQlDlmblA1U9_UIVzj66QHWsJMs8lwbLVa/s307/form1form2form3.png"></img><br />
<br />
<br />
7. For the sake of example, let’s make an application that will allow us to enter our first name in the first form, last name in the second form, and display our first name and last name in the last form. We also want to display just the main form when our application is first executed and hide the unneeded forms.<br />
<br />
8. If we click the Run icon or press control + E now. you’ll noticed that all forms are displayed at once.<br />
<br />
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1TT_zOzeAfYrClWHL3V8W5CKLo04Q0Wcs14xi1popYtAA7R_ywc-UYkomOjzXsT8cW1rSjyAhNPIgC35UrABNnNH9cpd76lZNHB7JdYbVxy7TpSKLvnSAEu71Rf-28e_5A7dJHEsqr64R/s313/form123runned.png"></img><br />
<br />
<br />
8. Click all the close button of all the opened form to go back to the design view. To hide Form2 and Form3 when the application is first executed, double Click Form1, in the Init procedure, enter the following:<br />
<pre class="VB" name="code">*hides the second form
Thisformset.Form2.Hide ()
*hides the third form
Thisformset.Form3.Hide ()
</pre><br />
<br />
The code window will now look like this:<br />
<br />
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh9SLDNMogfBvFh0tX7jMjmpc4fNeCvmukodWdt7yEXweDizXqbJXZPOTA_YqoL5quKuDLkcm2fMzVHQ77mdhC-mE48bHD9aq6MySJMSshKgnYA6KyjaYP6Rb2EvVlndlRQxiKptI9QMF7R/s512/form1hide.png"></img><br />
<br />
<br />
9. While still in the code window of Form1, Select the Unload event.<br />
<br />
Enter the following code:<br />
<br />
<pre class="VB" name="code">*Closes all the forms in the formset
RELEASE Thisformset
</pre><br />
<br />
The code window will now look like this:<br />
<br />
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiG-n03eLc2TrwfkPDcZ6kwvZzcLqnrYliVSiKgqDUXyvaCBQpr0POpbJ2CmJWx3J6QWUL7zUwKuuRpr8hN06x1klv1e6JwguiF7IhyAxLqQkqDGYiGPB2xpVWk6QyefnhldIDwAHmhxpC6/s511/form1unload.png"></img><br />
<br />
10. Click the close button of the code window to save all codes that we have entered so far in form1.<br />
<br />
11. Add a Label, a textbox and a button to form1, refer to the following screenshot for control property values:<br />
<br />
<br />
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjSDwhKD9i0XvemrGQDjpwENIEyBcan2h9QO6ZN4f5H9HteMju6hK_feBfFUHtg-0l6vT3NvbI1qKqlubiLXaQu7RDbtoQWzo0OTeM20A5VJpbVSjZLgaJBnHrkrK46HV00xebCd8ZTHUGc/s291/form1controls.png"></img><br />
<br />
12. What we aim to do here is if click the next button, form1 will be hidden and form2 will appear. To be able to do that, double click the Next button in form1 and enter the following codes:<br />
<br />
<pre class="VB" name="code">*Hides form1
Thisformset.Form1.Hide()
*Show form2
Thisformset.Form2.Show()
</pre><br />
The code window will now look like this:<br />
<br />
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhfV3IUYUQa4l2tTbnHoIzpqbBtjJN_PO26mRHjbjV-D2pvkL4BMUvBTL6i07ZTyb-qqXEQLUdAQvDtTi1NBabs7qEpL24bdeT581OV1_Tzn_bqrnm2Nh4xSW2cxmGBmS8BS_znPBFo1kBi/s573/NextButtonForm1.png"></img><br />
<br />
Click the close button of the code window to save the codes that we have entered in Command1.<br />
<br />
13. Add a Label, a textbox and two buttons to form2, refer to the following screenshot for control property values:<br />
<br />
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhXE6mgzvAWBjVB2WnVj-7EkkhErdRcSY1qOADATfFOa5tvdPdHKUCT1c-VI48ABD2HP4l966ESOScJb5VH181Z-AmZFaStnIednxFlX98EoyWZxLbQpA3cyco-JP5WS-qiIJpz2a7Nigel/s403/Form2Controls.png"></img><br />
<br />
14. What we intend to do here is if we click the Prev Button, Form2 will be hidden and Form1 will be shown. If we click the Next Form3 will be shown and Form2 will be hidden.<br />
<br />
15. Double click the Prev button then enter the following codes:<br />
<pre class="VB" name="code">*Shows form1
Thisformset.form1.Show()
*Hides form2
Thisformset.form2.Hide()
</pre><br />
Your code window will now look like this:<br />
<br />
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUcu-RokjlmS6YABO7di2CyK6Cs6LLr30pXr54abjNkG2yhjjC9cTUiSjS6rcwcQEZQkCnoWZJ2lUREM-Xy1OAyNa-VpwXaH_Dcac3QsyQLiWiutRkMu94MKxKyoy2tFPfDQdSjqY-pdIw/s625/Prevform2.png"></img><br />
<br />
<br />
Click the close of the code window to save your codes<br />
<br />
16. Double click the next button in form2 then enter the following codes:<br />
<pre class="VB" name="code">*Hides form2
Thisformset.form2.Hide()
*Shows form3
Thisformset.form3.Show()
</pre><br />
Your code window will now look like this:<br />
<br />
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEix_y5GYhIvILUw7cRwbDgNBMZdvJZ_40VNvIEADv3WdAhM8vikaoY9yocMzCEMFiB1BeFafMxlL0no4Nnhmi7KEAro34BfkFfVVsumy9eh3nRgEcY2vrz1tYSCh_YVUDkFAD4FPQpIs2zh/s622/Nextform2.png"></img><br />
<br />
Click the close of the code window to save your codes<br />
<br />
17. Add four labels to form3. Refer to the following screenshot for control property values:<br />
<br />
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjD6OnDHawelTkKOhldAeHuyl5Hzta4qYzJmTmM1ucVBgVrQaDn9OY2R9jroP6F2NuU5Kwbw2vWY4pJxmo-Bp5ZJdslGuLHOjEmWOhzBsTf8sNPATVyodbjQZpWBEEE462uvmoqRKweicT-/s387/form3.png"></img><br />
<br />
18. What we intend to do here is if Form3 is loaded, all the values from the previous will be displayed on their respective controls. Double-click form3. Select the Activate procedure then enter the following codes:<br />
<pre class="VB" name="code">*retrieves the value of the textbox in form1 and
*display it in the our label in form3
Thisformset.Form3.Label2.Caption=Thisformset.Form1.text1.value
*retrieves the value of the textbox in form2 and
*display it in our label in form3
Thisformset.Form3.Label4.Caption=Thisformset.Form2.text1.value
</pre><br />
Your code window will now look like this:<br />
<br />
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEigpIgYbWsRkIEoUjq4u6gXpX9QPyM6CPqKsNOVWMsYtQ6yJDGXg06ZsyqS0RNmvs70vbCEWXH47561sZKfflN93s2CBCyP1PohOwjKAimYm7lAIPS0BfhEpzmdzyBGrC34V0xLSmI3LGRD/s636/form3codes.png"></img><br />
<br />
19. Click the close button of the code window to save your codes. Let’s take a look to all our forms once more time.<br />
<br />
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEijCdFAUCnHHIbqZLqpkcSKxKH52rrdmepwbya5lfIcu0hDIHPS873ROgNBMGJ0K4JHYb0vm3iag222SStOr6EFYU6OP7zID5ljxFvPXl_Simric5zMzACMD_4n7FSaTEgxuuRkjGjx9Uds/s681/VisualFoxAllforms.png"></img><br />
<br />
20. Click the run icon or press Ctrl + E to test your Form Set.<br />
<br />
21. Try entering your first name on form1>Next. Your Last name on Form2>Next. Your first name and last name should now appear on form3.Rey Dacocohttp://www.blogger.com/profile/16795901672669072701noreply@blogger.com0tag:blogger.com,1999:blog-7232556147893180475.post-84671620077771541932012-03-01T18:11:00.005-08:002013-01-24T23:47:42.756-08:00Symet BEAM Robot<p>Time for some break in programming and delve into the exciting world of robotics. Symet, FYI , is an intelligent agent that can sense it’s environment through the solar cell and perform an action (e.i. tweaks or rotates) the moment it senses heat. A perfect example of a simple AI robot. Here is a mobile video taken by Christine (one of my apprentice LOL) showing Symet at work. This was edited using PowerDirector( A rich-featured video editing software by Cyberlink) which is available for download at www.cyberlink.com. The title and PIP Templates were downloaded from directorzone.cyberlink.com. The Kinetic Typography was made using Microsoft PowerPoint.</p><br /><br /><iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='320' height='266' src='https://www.blogger.com/video.g?token=AD6v5dx8PaKP6hwUoUZ-z4IO0EqmLt4epW0J8tlc-mg9zSO2k53e0HCDYA2JSeSo3kQRTOoopMm43lHoF6976JTyOg' class='b-hbp-video b-uploaded' frameborder='0'></iframe>Rey Dacocohttp://www.blogger.com/profile/16795901672669072701noreply@blogger.com0tag:blogger.com,1999:blog-7232556147893180475.post-26599500683656464522011-10-11T01:39:00.000-07:002013-11-05T19:47:49.571-08:00Linking to an Ms-Access Data Source using Visual C++ 2008 Windows Forms Application1.Create an Ms-Access database file using the following fields and data types:<br />
<br />
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgEvbJIzyNduJ0d0AhBUpz5iVRLasSF7OkaATAMi-wAaHpwAkH4YSoepfG0_PtEtJxuu-H2OXE8mZvM3cEROsiJGdO947W5tOQBpiyw61UTogRcGtOuUTJ0UM_4ErIHqOUU2w27gdG-7f-X/s278/tblApps.png"></img><br />
<br />
2. Name your table as “tblApps” no quotes. Add appropriate record values for instance:<br />
<br />
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEilCgJ1OHQMsV3wKSQip5IlZH3Eqwl1fWXsc9x5WWz3TOSHyqOd2dQKP9IFfssM2PeKtiboVRfYu-bTq2H0hAqJT00LsBb_EZ5J01HO1n9yqVymmU6DqRE0m_PxurVP16aIuwoOrcKnUxI9/s328/sampletableinputs.png"></img><br />
<br />
3. Name your Access database file as “dbICons” no quotes and save it in My documents. Make sure to close Ms-Access before you start Visual C++ 2008, otherwise you’ll get an “Already in use” error in the database connection part.<br />
<br />
4. Click Start>All Programs>Microsoft C++ 2008 Express Edition.<br />
<br />
5. Click File>New>Project>Select CLR from the Visual C++ Project Types tree view>Select Windows Forms Application from the Visual Studio installed templates pane>Enter your desired project name then click Ok.<br />
<br />
6. Design your form as follows:<br />
<br />
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj4d4nvgXrtj-Frq16bOiKF1n5W1ZpDyGKuy0l5qKY_iqyZbp45PkjeAYGgPdd-qTDErBmLq4ZwLnynVoqQvejJX7JS7lvj-Ho3PdAwMtusBGQ5nZAEm0Fyd1kT06snF6YTuWYGttw4lxwT/s537/formlayout.png"></img><br />
<br />
7. Just use the suggested control names above so that you will not get lost later on in this tutorial. To name a control, just select the control and change its name property value in the properties window.<br />
<br />
8. At this moment we will now specify the name of our database that we wanted to connect to. To do that, click the Tools menu and select Connect to database:<br />
<br />
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEirQ_Yrir-EAm6oy4yOu0jQJD-KEMFEb1lGSS-zX37NBUkQbhLLjGLSVF6LRmP4n5NWVEoAYvIucYeJZnMJ9B22c5n5GTry_zfOT82nQZcNmWKwuG0pY4KMrhkF0RnjUqXD8O7Mgm22e7I-/s287/toolsconntodb.png"></img><br />
<br />
9. Select Microsoft Access Database File (OLE DB) as a data source value then locate dbIcons and assign it as a Database filename value.<br />
<br />
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjswqDvzjZ_DTGMsfvYRXDl4-zgYCHpv0809mTdICTrJvoN5B-gwlHVhuLGngACYkcWOHFHsAMs_IiUdeuWwa-CHR-ePhPmsjNo9SBPs1ORUTK6B5Qk_Z1Zjm7NITQVfFbmfGkwO4IqgGwV/s328/addconn.png"></img><br />
<br />
10. Click the oledbDataAdapter control from the general category of the toolbox and drag it to your form. There instances wherein the oledbdataadapter is not shown, to show it, click Tools>Choose Toolbox items>type “ole” not quotes in the filter textbox> then check everything that starts with “ole” then click the Ok button.<br />
<br />
11. Once you have added an oledataadapter control, the data adapter configuration wizard will then come into view. If you noticed the table that you have connected previously (using step 8-9) is selected as a default value of the “what data connection should the data adapter use?” listbox. If not then click the listbox button then select “dbIcons” then click the Next button.<br />
<br />
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9zGS2e7bKC23-iShc4pTXPIkaR3uIbZ8TH1Ju6NqGxCsr8kgCa41crFz2iJ8IIl1lWG85SvuPsbWse_aVXFi-sKMY0_bwC7V0iCSFMJqnxiE7iUWxBHszSaToPOczJupf_pPdAciVOAkq/s431/whichdataconn.png"></img><br />
<br />
12. In the Choose a command type window, select the Use SQL statement radio button then click Next.<br />
<br />
13. In the Generate SQL statement window, type “SELECT * FROM tblApps” no quotes in the blank pane then click Next>Finish.<br />
<br />
14. Right-click>OleDbDataAdapter form the component tab>generate dataset>Ok.<br />
<br />
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgvdSLnxB9-u2oS3wUX_e6zaC732zWyRSSSfsbkt84ik13_5fFD9uztbUl3-OarMTVB70SAgzRUpQ5-zExzDp_uJ5Q5Cdj6aMW56ofmIt0XLDwAaBkGo1BsiVduvHMMRqtf7tMMOF7oK9Z5/s305/gendataset.png"></img><br />
<br />
15. Double-click your form then add the following in the Form_load event.<br />
<pre class="c++" name="code">//Populates the dataset
this->oleDbDataAdapter1->Fill(this->dataSet11,"tblApps");
</pre>16. This will fill our dataset with record values from our database.<br />
<br />
17. Bind the fieldname to an appropriate control using the following syntax:<br />
<br />
<pre class="c++" name="code">this->objectname->databindings->add(gcnew Binding(“Property”, datasetname,”Tablename.fieldname”);
</pre><br />
Add it below the oledbdataadapter.fill line. Your code should now look like this:<br />
<br />
<pre class="c++" name="code">private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {
//Populates the dataset
this->oleDbDataAdapter1->Fill(this->dataSet11,"tblApps");
//bind idlabel to the numappid fieldname
this->idlabel->DataBindings->Add(gcnew Binding("Text",this->dataSet11,"tblApps.numappid"));
//bind desclabel to the chrappdesc fieldname
this->desclabel->DataBindings->Add(gcnew Binding("Text",this->dataSet11,"tblApps.chrappdesc"));
//bind appPictureBox to the chriconurl fieldname
this->apppictureBox->DataBindings->Add(gcnew Binding("ImageLocation",this->dataSet11,"tblApps.chriconurl"));
}
</pre>18. Click the run icon to start debugging, you should see the following outputs:<br />
<br />
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0tRHp9x7HctrM1kILk-lBNDt9llV1UJ903IEneKUntLsqO7af5ANzLoh72TiQcy9sQEC3WyjZJDYglXZsctfsV4JAU_RPmtnDdQ2amSiXDPSfwZASTjHwBPTVtNgZKrgcCwPqWWEwP3A3/s328/output.png"></img>Rey Dacocohttp://www.blogger.com/profile/16795901672669072701noreply@blogger.com0tag:blogger.com,1999:blog-7232556147893180475.post-6151326681409325202011-08-24T20:22:00.000-07:002011-08-24T20:24:05.535-07:00A simple “Hello World” program in BlueJ1. Click Start>All Programs>BlueJ>BlueJ.<br />
The BlueJ Environment will then come into view.<br />
<br />
2. Click the Project menu>New project. In the Look in Listbox, select My documents> Enter “Example” (no quotes) in the Folder Name textbox then click Create.<br />
<br />
3. Click the New Class button>Type “Hello” (no quotes) in the Class Name textbox> Ensure that Class is selected in the class type radio buttons then click OK.<br />
<br />
<img src="http://img405.imageshack.us/img405/9999/hellonc.png"></img> <br />
<br />
A class icon with a caption “Hello” will then appear in the BlueJ workarea.<br />
<br />
<img src="http://img62.imageshack.us/img62/3901/classicoq.png"></img> <br />
<br />
4.Double click the Hello class icon, the following source code window will then appear:<br />
<br />
<img src="http://img855.imageshack.us/img855/1482/codewindow.png"></img> <br />
<br />
Before creating our “Hello World” program, let us first dissect the pre-made code bit by bit. If you noticed, I’ve enabled line numbers by clicking Options>Preferences>Display line numbers, for discussion purposes.<br />
<br />
Line 8: Is the class declaration section. It simply tells the BlueJ compiler the name of our class and to create class file based on it.<br />
Line 9: Indicates the beginning of our class.<br />
Line 10-12: Is the instance variable declaration section. This is where we declare the variables that will be needed in our application.<br />
Line 16-20: Is the variable initialization section. This is where we initialize the values of our variables.<br />
Line 28-32: Is the method declaration section. This is where we specify the actions that our application is capable of performing.<br />
Line 34: Simply specifies the end of our class.<br />
<br />
5. Now that we’ve understood (somehow) Blue’s code structure, let us now make our hello world program. Go to the instance variable declaration section (Line 10-12) and change “private int x;” to “private String strtext;” no quotes. The reason why we are declaring a string variable instead of the default integer variable is because we will be storing text i.e. “Hello World” to this variable in the variable initialization section.<br />
<br />
<img src="http://img685.imageshack.us/img685/1781/strtext.png"></img><br />
<br />
6. Go to the variable initialization section (Line 16 to 20) and assign a “Hello World” value to our previously declared variable. This can be done by erasing ‘x=0;’ and changing it to ‘strtext=”Hello World”;’. <br />
<br />
<img src="http://img94.imageshack.us/img94/5175/helloworldt.png"></img><br />
<br />
7. Go to the method declaration section (Line 28-32). Since we will not be accepting a numeric value from other methods nor we will be passing numeric value, change :<br />
<br />
<img src="http://img13.imageshack.us/img13/8708/samplemethodint.png"></img><br />
<br />
To<br />
<br />
<img src="http://img18.imageshack.us/img18/8485/strmethod.png"></img><br />
<br />
8. Your code will now look like this:<br />
<br />
<pre class="java" name="code">/**
* Write a description of class Hello here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Hello
{
// instance variables - replace the example below with your own
private String strtext;
/**
* Constructor for objects of class Hello
*/
public Hello()
{
// initialise instance variables
strtext="Hello World";
}
/**
* An example of a method - replace this comment with your own
*
* @param y a sample parameter for a method
* @return the sum of x and y
*/
public void sampleMethod()
{
//clears the previous outputs
System.out.println("\u000c");
//retrieves the value of the strtext variable and display it on the screen.
System.out.println(strtext);
}
}
</pre>9. Click the compile button to convert your Bluej source code into bytecode.<br />
<br />
10. Click the Close Button. <br />
<br />
11. Create an Object based on your Hello class by right-clicking the Hello class icon>new Hello.<br />
<br />
<img src="http://img841.imageshack.us/img841/183/newhello.png"></img><br />
<br />
12. Right-click the name of the Hello object>Click your method i.e., sampleMethod.<br />
<br />
<img src="http://img819.imageshack.us/img819/5498/voidsamplemethod.png"></img><br />
<br />
13. You should now see an output similar to the following:<br />
<br />
<img src="http://img204.imageshack.us/img204/7071/outputbluej.png"></img><br />
<br />
Rey Dacocohttp://www.blogger.com/profile/16795901672669072701noreply@blogger.com0tag:blogger.com,1999:blog-7232556147893180475.post-64212013187387139312011-07-14T07:03:00.000-07:002011-07-28T20:16:29.519-07:00Google has recently deindexed all co.cc domain extensions names. You can see the details of that here <a href="http://www.theinquirer.net/inquirer/news/2092882/security-experts-claim-googles-cocc-ban-inefficient">http://www.theinquirer.net/inquirer/news/2092882/security-experts-claim-googles-cocc-ban-inefficient</a>. <a href="www.aprogguide.co.cc">www.aprogguide.co.cc</a> will be transferring to blogspot for good in one week time.Rey Dacocohttp://www.blogger.com/profile/16795901672669072701noreply@blogger.com0tag:blogger.com,1999:blog-7232556147893180475.post-31752568967118073922011-03-03T23:16:00.000-08:002011-03-03T23:16:21.146-08:00Creating a Hit Points (HP) Indicator in DarkGDKHP indicators are normally used in Adventure games to show the character’s present HP level. There are several ways to create an HP level indicator in DarkGDK but the easiest way (I guess) is to create a sprite sheet with three or more columns and with different HP numbers per column. For instance, three HP’s on the first column, two on the second and one on the last. If a character dies, display the appropriate column relative to the character’s HP level. This method can also be used to specify the remaining number of bullets left or the character’s current energy level. If you are confused, follow these steps:<br />
<br />
1. Start Microsoft Visual 2008 C++ Express Edition.<br />
<br />
2. Click File>New Project>Select the Wizards Project type>Select Dark GDK-2d Game from the Visual Studio installed templates.<br />
<br />
3. Click View>Solution Explorer. Double-click main.cpp. The following should then appear:<br />
<pre class="c++" name="code">// Dark GDK - The Game Creators - www.thegamecreators.com
// the wizard has created a very simple 2D project that uses Dark GDK
// it can be used as a starting point in making your own 2D games
// whenever using Dark GDK you must ensure you include the header file
#include "DarkGDK.h"
// the main entry point for the application is this function
void DarkGDK ( void )
{
// in this application a backdrop is loaded and then several
// animated sprites are displayed on screen
// when starting a Dark GDK program it is useful to set global
// application properties, we begin by turning the sync rate on,
// this means we control when the screen is updated, we also set
// the maximum rate to 60 which means the maximum frame rate will
// be set at 60 frames per second
dbSyncOn ( );
dbSyncRate ( 60 );
// a call is made to this function so we can stop the GDK from
// responding to the escape key, we can then add in some code in our
// main loop so we can control what happens when the escape key is pressed
dbDisableEscapeKey ( );
// now we will set the random seed value to the timer, this will
// help us to get more random values each time we run the program
dbRandomize ( dbTimer ( ) );
// we are going to display a backdrop for the scene, to do this
// we load our image and give it an ID number of 1, this particular
// image is of a sky at night with stars
dbLoadImage ( "backdrop.bmp", 1 );
// the next step is to create a sprite that uses this image, this
// is achieved by calling dbSprite and passing in a value of 1 for the
// sprites ID, 0 for the X coordinate, 0 for the Y coordinates and a
// value of 1 for the image
dbSprite ( 1, 0, 0, 1 );
// next we will load in some animated sprites, before doing this
// we need to adjust the image color key, by using this function we
// can make a specific color be transparent, in our case we want this
// to be bright pink
dbSetImageColorKey ( 255, 0, 255 );
// in this loop we're going to create some animated sprites, the image
// we load contains frames of animation for an asteroid
for ( int i = 2; i < 30; i++ )
{
// create an animated sprite and give it the ID number from the
// variable i, next is the filename, now we come to how many frames
// across and down, in our case this is 4, finally we come to the image
// ID that the sprite will use, again we use i
dbCreateAnimatedSprite ( i, "sprite.bmp", 4, 4, i );
// position our sprite at a random location
dbSprite ( i, dbRnd ( 640 ), -dbRnd ( 1500 ), i );
}
// now we come to our main loop, we call LoopGDK so some internal
// work can be carried out by the GDK
while ( LoopGDK ( ) )
{
// run a loop through all our sprites
for ( int i = 2; i < 30; i++ )
{
// move the sprite down and play its animation
// moving from frame 1 to 16 with a delay of 60 ms
dbMoveSprite ( i, -2 );
dbPlaySprite ( i, 1, 16, 60 );
// check the position of the sprite, if it has gone off scren
// then reposition it back to the top
if ( dbSpriteY ( i ) > 500 )
dbSprite ( i, dbRnd ( 640 ), -dbRnd ( 1500 ), i );
}
// here we check if the escape key has been pressed, when it has
// we will break out of the loop
if ( dbEscapeKey ( ) )
break;
// here we make a call to update the contents of the screen
dbSync ( );
}
// when the user presses escape the code will break out to this location
// and we can free up any previously allocated resources
// delete all the sprites
for ( int i = 1; i < 30; i++ )
dbDeleteSprite ( i );
// delete the backdrop image
dbDeleteImage ( 1 );
// and now everything is ready to return back to Windows
return;
}
</pre>
4. Since we intend to make our sample application from the scratch, delete all the pre-made codes, except the following:
<pre class="c++" name="code">// Dark GDK - The Game Creators - www.thegamecreators.com
#include "DarkGDK.h"
// the main entry point for the application is this function
void DarkGDK ( void )
{
dbSyncOn ( );
dbSyncRate ( 60 );
while ( LoopGDK ( ) )
{
// here we make a call to update the contents of the screen
dbSync ( );
}
}
</pre>5. Make a spritesheet using gimp or photoshop. In this example we will be using the following image:
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgH1UJYI-zyqaLDHnmzocVC2w9NOcci-p7Qo56OjUnLGEFKy3mnu9nHPTridh179_-uj_CMitHikYd9z4BRK_fdZfg84uZo2Th2vRv6ctfqI1-R3h11sGBWRXXzlRUQYnnsIsTxTZB9Zz_z/s288/hplevel.png"></img>
6. Later on we will be dividing this image into three columns. If you noticed if we divide this image into three divisions each divisions we will have different number of HP’s.
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzU339EP9r6D4dshN8YglKbqllqct_DW4xR5jpZ5lPJ_OpsHLW_4ANRlD6cSRrm7HgCkYGLOao0J6T6Ccxkx6pC1AkAslBr5C6joLFW3JZ9NQvrSz6bWkRUEsHlGK8sywN7pzZ9OIV21U0/s288/3divs.png"></img>
7. Copy this image from whatever location you have saved it. In this example, I have saved it on my desktop so all I need to do is go to the desktop. Select the file “hplevel.bmp”. Then press CTRL + C to copy it.
<br>
8. Switch to Micorsoft Visual C++ 2008 DarkGDK to view our game again then click the Open File icon from the formatting toolbar.
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhMVdQfcFliyv1LSqakN3RQt98cXeAuAiQNokr67X6kPF2C9NxhUSIxmHuuJfilKA8kCFbrl-sWrw7UizfFxDLp33NGc6CPYpt-EdtdTqyHR7LloDwicvX7qDOdRfsBhK-gsMEl5uF80TLh/s288/openfile.png"></img>
9. This causes the Open File dialog box to appear. Click on the empty pane>Press Ctrl + V to paste our “hplevel.bmp” file.
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhZr6NvcqNlJS4oGtpauIb4idt5W6FXUe5F29ulwOcl4nvTDvKLIbhaQrZlimDbWXmnwahsqXtzEyRKzxKwAbr-w6nY7CyiOw55rfKOAf8QZVDvgH0mRdxWvcXUm1EIV2-pASY2EYOLrm_P/s288/pastehplevel.png"></img>
10. The next thing that you’ll need to do is to load this image into the computer’s memory, and divide it into three columns. We can do so by using the dbCreateAnimatedSprite command. Click the cancel button from the open dialog box to close it. This causes our code window to appear. Enter the ff. after the dbSyncRate(60); line.
<pre class="c++" name="code">//divides the image into 3 columns
dbCreateAnimatedSprite(1,"hplevel.bmp",3,1,1);
</pre>
11. If you run your application now, it will just display a blue screen. To display your animated sprite,use the dbSprite command. Enter the following code after the dbCreateAnimatedSprite line.
<pre class="c++" name="code">//displays our animated sprite
dbSprite(1,0,0,1);
</pre>
12. Press Ctrl+ F5 to test our application again. If you noticed the first column of our animated sprite is shown together with a white background. To clear the white background, use the dbSetImageColorKey command. Enter the following before the dbCreateAnimated line:
<pre class="c++" name="code">//clears the white background
dbSetImageColorKey(255,255,255);
</pre>
13. Your code should now look like this:
<pre class="c++" name="code">// Dark GDK - The Game Creators - www.thegamecreators.com
#include "DarkGDK.h"
// the main entry point for the application is this function
void DarkGDK ( void )
{
dbSyncOn ( );
dbSyncRate ( 60 );
//clears the white background
dbSetImageColorKey(dbRgb(255,255,255));
//divides the image into 3 columns
dbCreateAnimatedSprite(1,"hplevel.bmp",3,1,1);
//displays our animated sprite
dbSprite(1,0,0,1);
while ( LoopGDK ( ) )
{
// here we make a call to update the contents of the screen
dbSync ( );
}
}
</pre>
14. The next thing that we want to do is to subtract the number of HP’s everytime the space key is pressed. Of course you can replace this with more advanced algorithms such as when your player dies or when a shot is fired, etc. But for the sake of simplicity, lets just go with the space key(hehehe).
15. Declare an integer variable named intspritesheetcols just below #include "DarkGDK.h" line and assign a a default value 1.
16. Enter the following after the while ( LoopGDK ( ) ){
<pre class="c++" name="code">//you can replace dbSpaceKey with "if a player dies" or "if a gun is fired" algorithms
if (dbSpaceKey())
{
//increment the value of intspritesheetcols by 1
//if you recall we've initially assigned a starting value 1 to
//our intspritesheetcols variable. If you press the
//the space key for the first time it will be incremented by 1
intspritesheetcols=intspritesheetcols + 1;
//displays the spritesheet division relative to the specified
//intspritesheetcols value. The first time you press the space key
//intspritescols will have a value to causing the second column
//of our spritesheet to be displayed
dbSetSpriteFrame(1,intspritesheetcols);
//displays our sprite
dbSprite(1,0,0,1);
}
//if the number of columns exceeds 3
//you can display your game over screen here but in this case let's
//just exit the game
if(intspritesheetcols>3)
{
return;
}
</pre>17. Your whole code should now look like this:
<pre class="c++" name="code">// Dark GDK - The Game Creators - www.thegamecreators.com
#include "DarkGDK.h"
int intspritesheetcols=1;
// the main entry point for the application is this function
void DarkGDK ( void )
{
dbSyncOn ( );
dbSyncRate(5);
//clears the white background
dbSetImageColorKey(255,255,255);
//divides the image into 3 columns
dbCreateAnimatedSprite(1,"hplevel.bmp",3,1,1);
//displays our animated sprite
dbSprite(1,0,0,1);
while ( LoopGDK ( ) )
{
//you can replace dbSpaceKey with "if a player dies" or "if a gun is fired" algorithms
if (dbSpaceKey())
{
//increment the value of intspritesheetcols by 1
//if you recall we've initially assigned a starting value 1 to
//our intspritesheetcols variable. If you press the
//the space key for the first time it will be incremented by 1
intspritesheetcols=intspritesheetcols + 1;
//displays the spritesheet division relative to the specified
//intspritesheetcols value. The first time you press the space key
//intspritescols will have a value to causing the second column
//of our spritesheet to be displayed
dbSetSpriteFrame(1,intspritesheetcols);
//displays our sprite
dbSprite(1,0,0,1);
}
//if the number of columns exceeds 3
//you can display your game over screen here but in this case let's
//just exit the game
if(intspritesheetcols>3)
{
return;
}
// here we make a call to update the contents of the screen
dbSync ( );
}
}
</pre>
18. Press CTRL + F5 to run your application. You should now see an output similar to the following:
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXdXK0Upv5VTUtRbvbHc2n-_jtVVPSnZW_n1d1Xrnpo28CRMdntTV8Sx1eGTLooTnqs_IOU9uondlIx3IJu0Ek-vUZiTW7-Vi5F6l9Vf7cTihizRpIqvZ6RjOJAnb3oxw8aKmZlDwVcf7H/s288/output.png"></img>
<br />
19. That’s all.Rey Dacocohttp://www.blogger.com/profile/16795901672669072701noreply@blogger.com0tag:blogger.com,1999:blog-7232556147893180475.post-41322331780747879022011-03-01T05:23:00.000-08:002011-03-01T05:25:27.506-08:00Blender 2.5 Beta Boids Particle SystemBoids particle system is used to emulate the movements of animals moving in clusters or groups. To create a simple boids simulation in Blender 3d 2.5 Beta, follow these steps:<br />
<br />
1. Start Blender by clicking on Start>All Programs>Blender Foundation>Blender>Blender.<br />
<br />
2. Press Esc to get rid of the Splash screen then select the default cube by right-clicking it.<br />
<br />
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhVia1QPvGUefu8-Vj44QKOavbECF4NRHC2cAIkZkMpkUKF-7yVAwMsYgg5oyniWTnXcQEd8RE0DRvkt_P_FCA1XMv60cdxpM4AR4YPtp1yoUZ7S9evkVe5K4rB58JBDZabPt5gRFUjsSI0/s288/rightclickcube.png"></img><br />
<br />
3. Click the particles button in the Properties View (formerly known as Buttons Window).<br />
<br />
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkJkuYFiPVekZkh0V77UsP-4UTarBYgv-D3I8WNTAijwFCdFM7H5YRAKcK3JuIdTD5auHG-LYTXeu7psgJM-z2iPSyaFxjHh3N27xPWlCw9MXCJ9Pz8I-O1oNoZMfTvzeyhc8IodC4EVdm/s288/particlesbutton.png"></img><br />
<br />
4. Click the + (add particles) button.<br />
<br />
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJwRIQePSyWzt63HgxicXhKKPqLSlgzMZnPLQoKQ2a2wS4-DE_7dnXAT8fRhB3W0OPyEUXcUf-3rpLQNKTGXRlozcDAyn-gVi_OTPDq4Z0azl8zL5mCIql8A6cPLEOqBrc33VuTOJ35JXz/s288/plusbutton.png"></img><br />
<br />
5. Blender will automatically create a particle system named “ParticleSystem”. Locate the Physics category by scrolling the scrollbar down> Then click the boids button.<br />
<br />
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNg3CqD9DOXZSmlsfoJkRWctc36d5wUaOfeYYsgHx3nuOZzjDKnmn2VNPWlXYYiX2XM73hFNTDMe3PEx3MzC6GZ40-ap-UCG1uIlyvgzKhYF41i1qmVCUx_GwYA82p-OiP97n4W4xg9U2h/s288/boidsbutton.png"></img><br />
<br />
6. At this point you can press Alt+A to test our animation.If you noticed, our simulation does not would do that much because what we have done so far is to create the cube object as a source or emitter of our boids particles.<br />
<br />
7. The next thing that we need to do is to add an object that will serve as destination or goal of our boids particles. To do that, position the 3d cursor a few blender units away from our cube object.<br />
<br />
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEijGTBvY9rPoQRysPiDqGxCtj8YoVZHIpklI-XCUfehxS62f89O9htIykE7DcWdagqr4zIpariOcDgifSUNSSq53efuqOI3kT32rzUb1gmL60BR7SjUwXMMMX4_kkVHTc6wbCtoAW9lrd53/s288/3dcursor.png"></img><br />
<br />
8. Press Shift + A>Mesh>Icosphere.<br />
<br />
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWVJelo5rcwrW2QMy7h0b0L8zHPRvr8WerKSX5688lz5CLukdT28agGEWPldtvISaHHnauJ1qqu1guU1PduRdEsZXpuKFxXkh42mGbTLP91WvEgHOwseNJWNoEBsJiH0eU3Upsl6wtXa8S/s288/icosphere.png"></img><br />
<br />
9. You can add any object you want as a destination of our boids particles but in this case we’ve used an icosphere as our goal object(no reason in particular). Select the icosphere by right-clicking on it>Click the Physics button from the Properties View.<br />
<br />
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPY9Yq8dbAMKFEI5i1Pl88GAQu8w70G3iqy3y3anWraQk4AiZBvlJ2wDZRVR2yIOHVXwR7rt_JHhtIQOyycKA9M3DMHhTRgVcEHTIarW8duOnsn20sUYsstYjzSpY4vZhbll62XurfiVCa/s288/physicsbutton.png"></img><br />
<br />
10. Locate the Force Field category. Select Magnetic from the type listbox.<br />
<br />
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXuA3GsPC07DBNLfSmwqYvBXVkP7VRhnvjEqwwAGZgdO_irD0940SuiHg4_DOkumsH4E-gc2yxVdAzpMR7MpTGjMe0Mv68VqtleERHT4a_3WTgxVXpIsNhIzWc6GP_YwQfialsIAa8kHJ9/s288/magnetic.png"></img><br />
<br />
11. Select your cube object by right-clicking on it>Click the particles button> Locate the Boid Brain Category>Click the +(Add Rule) button>Select Goal.<br />
<br />
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiuSv7Qq8sERzLfVf8dDK9pszR446ZdRrC_4Q6yd7us6IhKtWb1j8_MoxLEokulrPKiJ33jIQCZkafaP2ntaPT2k1vrsmbjatIs5_9BeykAWKRr0dC-_EEGzFk02NEudRq9TaWlVoKD9SXI/s288/goal.png"></img><br />
<br />
12. Click the Goal object textbox> Select icosphere.<br />
<br />
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjKgZGw7SoYSLDITjFMKn_JHCHNtMBFvjAnLucf3G-z9jZhHI8locrbGlDbbwjcnhObNiAM5hRz2aKlg57-KHOJ8VuZfoXXyTIHSJmyM8MKJqh27nXJWF_CVs2lydOTsl-U5tVxrhZVzWFd/s288/goalobject.png"></img><br />
<br />
13. Press Alt+A to test your animation. If you noticed our boids particles seemed to be moving in the direction of our destination object (icosphere). Unfortunately it does not actually reached the icosphere because it dies after 50 frames. To increase the boids life, right-click the cube object>Click the Particles button. In the emission category, change its Lifetime value to 999.000.<br />
<br />
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUVlyfTkD_3qnnB8J5ZhTIQ-i4_cTznz_ZaQAxHCZG6naBiqRBkUpPyHbreOobw8kaUicl8QUxhRk8nrzJmHO9fu8d8NdRBOWuj16gpzJPK_lqZ1Kmvnn6Q9_vP22KK9OwcsZUyZBZEEwN/s288/lifetime.png"></img><br />
<br />
14. You can change whatever particles lifetime value you like just make sure that it is identical to the ending frame of our animation. To change the ending frame of our animation, locate the End option in the timeline then change it to 999.<br />
<br />
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgcvaPGd_5r5zW-p-C3zrxrWp3K-GPufGO_3jyKnp64gsO0FYZOyRvP0gAUwez5Ym1E55OgCzq8XpNuc8Oeo8C09L5Ips0xPvBCMnMnoj6cmJmv69w2bLsjNxFL9N_NzLbX3xid1uYNCdzI/s288/timeline.png"></img><br />
<br />
15. Press Alt + A to test your animation. You should now see an output similar to the following.<br />
<br />
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhWEKpJVKQWLtGlaFWS-wpRZPOrRyU5Od0ARjnbSUVqNmU7HqXXU3BL3W6dqwnkY_KEJCRXN8H2B4N_8LfOH6Q8_LiUrO55FDJZZkKH_qrwdTuZINcTmhQv2oN2DonW_CgQql759rApTKPw/s288/output.png"></img>Rey Dacocohttp://www.blogger.com/profile/16795901672669072701noreply@blogger.com0tag:blogger.com,1999:blog-7232556147893180475.post-7520094178002625972011-01-29T01:10:00.000-08:002011-02-26T05:30:45.467-08:00Display Record Values from Two Tables in ASP.net Visual Web Developer Express EditionTo display data from two tables in ASP.net, we’ll need two tables with one or more identical fields. One field should act as a primary key on one table and the other should act as a foreign key or normal key on the other table. For the sake of example, let’s make two tables tblStudents and tblBooks using the following structures:<br />
<br />
a. tblStudents<br />
<table border=1><tr><td>Column Name</td><td>Data Type</td></tr>
<tr><td>chrstudid</td><td>nchar(10)</td></tr>
<tr><td>chrstudfname</td><td>nchar(20</td></tr>
<tr><td>chrstudlnam</td><td>nchar(20)</td></tr>
</table><br />
b. tblBooks<br />
<br />
<table border=1><tr><td>Column Name</td><td>Data Type</td></tr>
<tr><td>chrbookid</td><td>nchar(10)</td></tr>
<tr><td>chrtitle</td><td>nchar(30</td></tr>
<tr><td>chrauthor</td><td>nchar(30)</td></tr>
<tr><td>chrstudid</td><td>nchar(10)</td></tr>
</table><br />
1. Start Visual Web Developer Express Edition.<br />
<br />
2. Click File>New Website>Select Asp.net website from Visual Studio Installed Templates options>Click Ok.<br />
<br />
3. Click View>Solution Explorer>Right-click App_Data from the solution Explorer>Add New Item>Select SQL Server Database from Visual Studio Installed templates options>Accept the default database.mdf name>Click Add.<br />
<br />
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVqpQNwwcTom7VU6Rg2mAcc16ueFLLLZKS5Gfb25n6qJLfvRYHymfMNc8-0kXiEqMjx1lNig9gROFXwZF5jnbry7Hmy7509vfsIFDiyD6WYqlvOtdWBGUzBIjL4QKZODahBuODURnzZmb7/s288/appdata.png"></img><br />
<br />
4. The Database Explorer panel will then come into view. To create a new table>Right-click Tables from the database explorer panel>Select Add new table. <br />
<br />
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOyKmHJ8MDAwO4e5vWVVXinmqjwcNG8cKex9xedcfNjx7cOwBnll_mOsNB_xYOyR1zQG3wEmq_RbTs6eiq56jwYzbOM9Y1eTp10FE4g22gvLUEvI1csWrPoDrXCFNC3Vq5knJaVx08_1tF/s288/addnewtable.png"></img><br />
<br />
Enter the following column names, use chrstudid as a primary key:<br />
<br />
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEilRQwz3ts_Ko4E0p1MUX8G7psLRr-F66aL0LTUE5SjX23a1Ij3O_08oAmiT2f19bc0kNdh54Gzr9xA_7TUMwAhxTn07xJCCgGDqrAr5MmRbtoRbu08dusmakb3bdQhrySrI6Z1mZsNJeOQ/s288/tblstudents.png
"></img><br />
<br />
5. Click the close(x) button when done. You will be prompted if you wanted to saves changes to the table, just Click the Yes button>Enter “tblStudents” in the Enter a name for the table textbox>Click Ok.<br />
<br />
6. Click the + icon beside the Tables node in the database Explorer>Right-click tblStudents>Click Show Table Data. <br />
<br />
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEixYF5JYpIRmpNshaOolnDwluhN6YJT-5NZaOHKxfjWMnt301iHggIdw6VIVYEF2RQVMswX8E4DRc8v6X5pQM7FhhXuOFwmJ61pAHWuNdditWNcEOqNOqDPbXl7dmWjTVJt0yHbg3o5Ui3P/s288/addnewstudents.png
"></img><br />
<br />
Enter the following values:<br />
<br />
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEixYF5JYpIRmpNshaOolnDwluhN6YJT-5NZaOHKxfjWMnt301iHggIdw6VIVYEF2RQVMswX8E4DRc8v6X5pQM7FhhXuOFwmJ61pAHWuNdditWNcEOqNOqDPbXl7dmWjTVJt0yHbg3o5Ui3P/s288/addnewstudents.png
"></img><br />
<br />
<br />
7. Right-click Tables from the Database Explorer again then Select Add New Table. <br />
<br />
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYZAt126YO26XTw9LXh-bEe0SRm2OXT9Jay8CcNzT59FxCuSWtUOiVydXLo5HeMPUg3CFVZ59pyfB9J-X0JYulsBBemG505B2OqK91GRV38k7DvAqQajqeLMrNS3QBRXuVtZelcW7hkw0c/s288/tblbooks.png
"></img><br />
<br />
Enter the following Column names using chrbookid as a primary key:<br />
<br />
<br />
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiITMuTyv-4SwbllM7w8XlUAvheqXgRyfwDO7OSQiXIEMlNPzcCnGGshtbSF7jBarlso8rl2DPe2t4qAzwCt7hscc1PHyoX1TadouQQQhk8RIfmoNUpC4nhpB-3tjq72ZIlKGdvqsJm0QbF/s288/tblbooksstru.png
"></img><br />
<br />
<br />
8. Click the close(x) button when done. You will be prompted if you wanted to saves changes to the table, just Click the Yes button>Enter “tblBooks” in the Enter a name for the table textbox>Click Ok.<br />
<br />
9. Click the + icon beside the Tables node in the database Explorer>Right-click tblBooks>Click Show Table Data.<br />
<br />
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgHdz_3D7afgotVDBUI9BbRB3vQZOyE8JOdBPtwOg6r6qO3FwZS7PVKRVdnvUMSfSNsK6iDxbrn1dIoHOCtrOovSlV7A3sAkB-U9meWEc1Gyo394uRTyv8tqctyiSIPftEv_2tpNaxQ2-Z6/s288/addnewbooks.png
"></img> <br />
<br />
Enter the following values:<br />
<br />
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_1o5QscKIfwoTL-7AKAZMyOUs9hHhatIIUQmuehkA8eotoAAOgugMGxFFgnBS7HIeizfV9xg-X7aIx778bTlPlfrAFHo_hA8-StgF-xymZa1dTDSyUAzG847toAX3eiTOhqyPT-9RYI89/s288/bookstablevalues.png
"></img><br />
<br />
10. Click View Solution Explorer > Double-Click Default.aspx> Double-click the design button>Expand the Data category of the toolbox>Click and drag a SqlDataSource control to the Outline Designer window.<br />
<br />
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMjZExqWYbbKifyhQDXldPb6yBhlXECRjCmA2GonF-uPmQAZPIHiJ3N3RKCVEdF2jYYaLiZcx0MzLoqBhuxP2J123iG223w9WAjQVmzc1Q26928tWbN2yx-jiqwZggHboXcYeiQNjd3D3o/s288/sqldatasource1.png
"></img><br />
<br />
11. Click the configure data source link>Select Database.Mdf from the “Which data connection should your application use to connect to the database?” listbox>Next.<br />
<br />
<br />
12. Click the Specify a custom SQL statement or stored procedure radio button>Next.<br />
<br />
13. Click the SELECT tab then enter the following SQL statements in the SQL Statement textarea:<br />
<br />
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgyGajnS5GcaZvKRO_yS_bqfZfjKXkBFgZNJHS_lF8SB2LrrmHsIcdnE9O3wgqH7NOmIyVeSbBVqCV6kgUzOb50Y4VT2JKYuFk1xE01oI2KzxKADeO9wvUj7sUxyqxWMs7bF7aPFcjQluDL/s288/sqlstatement.png
"></img><br />
<br />
14. This statement retrieves the values of our specified column names from both tables. If you noticed, we’ve added tblStudents dot chrstudid to specify that the values should be retrieve from the tblStudents table since tblBooks table also has chrstudid.Moreover, we’ve added INNER JOIN to join our tables using a common field<br />
due to the fact that chrbookid, chrtitle, and chrauthor exists on the other table.<br />
<br />
<br />
15. Click next. You can click the test query button to preview the result then click the finish button.<br />
<br />
16. Click a grid view control from the data category of the toolbox then drag it onto the Outline Designer. Select the name of your SQLDataSource from the gridview’s Choose Data Source List Box.<br />
<br />
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjGj-yeEKUMbunaAbpdn-F0HwkYi1NsIWsa-6ROtmS2Bs3h4BCWziH3Ws3RV6wg1Tij43wvfGUiJf2o_bKpBt5p3dvt3DvtNEsRR-L-WfSAkknDio_pNzMwNY0hFfyKpjkAuSNLeSVBxidd/s288/gridview.png
"></img><br />
<br />
16. Press CTRL + F5 to test your application.<br />
<br />
17. You should now see an output similar to the following screenshot:<br />
<br />
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiwJ1h9KetYxVTbL9r9utUIs8qZZQXbskS2NQeJ9LYLk_uujrbC9Jff5CFJCZaEHophI53L1vwxR71H4o87Lj83XNMjr9LEyECNrIdQa9PfBLDadGo_x2m9kALNK4iv9aGGJgW87BgbPJWu/s288/outputpp.png
"></img>Rey Dacocohttp://www.blogger.com/profile/16795901672669072701noreply@blogger.com0tag:blogger.com,1999:blog-7232556147893180475.post-5066777726583981542010-12-09T22:50:00.000-08:002011-02-26T05:09:35.273-08:00Example 18: Race to Ten Text-Based GameProblem: Make a simple Race to Ten text-based game. The details of the game is shown in the following screenshot:<br />
<br />
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjypYl9AW1bRnNIDhKrshrdhJALfemsoEYfB_s_CHSp_WY03FOEWj0rmk_kt3fKqQRgoqDYfmnMmp1DrtWExrfsS_81-kYb16M0a7dpzv4ECzuQzCi1uFUZQWP74ezDrvDWsOsRPaYHivAY/s288/fgame.png"></img><br />
<br />
Code:<br />
<pre class="c++" name="code">// Learn more about F# at http://fsharp.net
open System
//change the console title
System.Console.Title<-"Race to Ten"
//adds the foreground and background color
System.Console.ForegroundColor<-ConsoleColor.DarkBlue
System.Console.BackgroundColor<-ConsoleColor.Gray
//clears the screen. This is to apply the background color once the
//console application is loaded
System.Console.Clear()
//display the game title screen
printfn "\t\t\t\tRace to Ten"
printfn "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t\t\tPress any key to continue..."
System.Console.ReadLine()|>ignore
System.Console.Clear()
//display the game description screen
printfn "Instructions:"
printfn "In this game, each player(you vs. the computer) enters a number between 1 to 3"
printfn "The previously inputted number will be added to the present number"
printfn "The first player to enter a number that adds up to 10 wins the game"
printfn "Press Esc to quit the game"
printfn "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t\t\tPress any key to continue..."
let mutable userkey=System.Console.ReadLine()
System.Console.Clear()
//declares our variables
let rndnum=new Random()
let mutable intsum=0
let mutable intusernum=0
let mutable intremain=0
//loop while sum is not equal to 10 and
//the spacebar key has been pressed
while (intsum < 10 ) do
//computer generates a number
printfn "\n\nAI's turn..."
let intainum=rndnum.Next(1,3)
printfn "AI num: %d" intainum
//accumulates the number to the
//value of sum
intsum<-intsum + intainum
printfn "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t\t\tPress any key to continue...Esc to quit"
System.Console.ReadLine()|>ignore
System.Console.Clear()
//display how many numbers more to go
//before 10
intremain<-intsum-10
printfn "%d more to go!" intremain
//if the sum is equal to 10
//display "computer wins"
if intsum>=10 then
System.Console.Clear()
//reset the value of sum so that
//the game will loop again
//remove intsum<-0 if you want the
//game to end after one game
printfn "Computer Wins!"
intsum<-0
printfn "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t\t\tPress any key to continue...Esc to quit"
System.Console.ReadLine()|>ignore
System.Console.Clear()
//otherwise ask for a number
printfn "\n\nYour turn:"
intusernum<-(int)(System.Console.ReadLine())
//if the number exceeds 3 then
//ask for a number again
if intusernum>3 then
printfn "Number must be between 1 to 3"
printfn "You turn:"
intusernum<-(int)(System.Console.ReadLine())
intsum<-intsum + intusernum
System.Console.Clear()
//accumulates the inputted number to the value of sum
intsum<-intsum + intusernum
intremain<-intsum-10
printfn "%d more to go!" intremain
if intsum>=10 then
System.Console.Clear()
printfn "You Win!"
intsum<-0
printfn "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t\t\tPress any key to continue...Esc to quit"
System.Console.ReadLine()|>ignore
System.Console.Clear()
</pre>Rey Dacocohttp://www.blogger.com/profile/16795901672669072701noreply@blogger.com0tag:blogger.com,1999:blog-7232556147893180475.post-76878086407677204992010-11-22T21:32:00.000-08:002010-11-22T21:32:41.400-08:00Example#17(Array.Iter)Problem: Make a console application that will convert the following singular nouns to plural. Use Array.Iter:<br />
<br />
1. ally<br />
2. army<br />
3. baby<br />
4. lady<br />
5. navy<br />
<br />
<pre class="c++" name="code">// Learn more about F# at http://fsharp.net
open System
//change the console title
System.Console.Title<-"Convert to Plural"
//adds the foreground and background color
System.Console.ForegroundColor<-ConsoleColor.Blue
System.Console.BackgroundColor<-ConsoleColor.White
//clears the screen. This is to apply the background color once the
//console application is loaded
System.Console.Clear()
//assigns the singular nouns to our array variable singularnouns
let singularnouns=[|"ally";"army";"baby";"lady";"navy"|]
printfn "Singular words:"
//iterates through the values of our singularnouns array variable
singularnouns|>Array.iter(fun singularwords->printfn "%s" singularwords)
printfn "Plural words:"
//iterates through the values of our singularnouns array variable
//replace the word in each array element from "y" to "ies"
singularnouns|>Array.iter(fun pluralnouns->
let pluralwords= pluralnouns.Replace("y","ies")
printfn "%s" pluralwords)
</pre><br />
This will display the following output:<br />
<br />
<img src="http://img530.imageshack.us/img530/2688/1123201012039pm.png"></img>Rey Dacocohttp://www.blogger.com/profile/16795901672669072701noreply@blogger.com0tag:blogger.com,1999:blog-7232556147893180475.post-67750407261173572492010-11-19T02:00:00.000-08:002010-11-19T17:56:55.433-08:00Visual F# 100 Examples: Example Number 16(Search a Record Value)Problem: Make a Windows Forms Application that will allow the user to search a record value from a database file.<br />
<br />
<pre class="c++" name="code">// Learn more about F# at http://fsharp.net
//specifies the memory location of the class files
//that will be needed in our application
open System.Collections.Generic
open System
open System.Windows.Forms
open System.ComponentModel
open System.Data
open System.Drawing
open System.Data.OleDb
//creates a font
let ffont=new Font("Verdana", 9.75F,FontStyle.Regular, GraphicsUnit.Point)
//creates a connection object
let oleconn = new System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;
Data Source=C:\Documents and Settings\Station03\My Documents\dbEmployee.mdb")
//creates an OleDbDataAdapter
let dataadpter = new System.Data.OleDb.OleDbDataAdapter("Select * from tblEmployee", oleconn)
//generates a dataset
let dataset11 = new DataSet()
//fills the dataset with recod values
dataadpter.Fill(dataset11,"tblEmployee")|>ignore
//creates a form
let dataform = new Form(Text="Search a Record Value",AutoScaleDimensions=new System.Drawing.SizeF(60.0F, 13.0F),ClientSize=new System.Drawing.Size(400, 360),StartPosition=FormStartPosition.CenterScreen)
//creates our controls
let exitbutton=new Button(Text="Exit", Location=new System.Drawing.Point(300, 320))
let searchbutton=new Button(Text="Search", Location=new System.Drawing.Point(220, 320))
let label1=new Label(Text="Enter the employee number:",Location=new System.Drawing.Point(0, 10),AutoSize=true)
let label2=new Label(Text="Empno:",Location=new System.Drawing.Point(0, 50),AutoSize=true)
let label3=new Label(Text="Firstname:",Location=new System.Drawing.Point(0,100),AutoSize=true)
let label4=new Label(Text="Lastname:",Location=new System.Drawing.Point(0,150),AutoSize=true)
let empnotext=new TextBox(Location=new System.Drawing.Point(200,10))
let emplabel=new Label(Location=new System.Drawing.Point(100,50),BorderStyle=BorderStyle.FixedSingle)
let fnamelabel=new Label(Location=new System.Drawing.Point(100,100),BorderStyle=BorderStyle.FixedSingle)
let lnamelabel=new Label(Location=new System.Drawing.Point(100,150),BorderStyle=BorderStyle.FixedSingle)
//creates a datagrid
let datagrid = new DataGridView(ColumnHeadersHeightSizeMode=DataGridViewColumnHeadersHeightSizeMode.AutoSize,Size=new System.Drawing.Size(300, 120),Location=new System.Drawing.Point(10, 180))
//creates a grid control colums
let chrempnocol=new DataGridViewTextBoxColumn()
let chrfnamecol=new DataGridViewTextBoxColumn()
let chrlnamecol=new DataGridViewTextBoxColumn()
//adds the columns into our datagrid
datagrid.Columns.Add(chrempnocol)|>ignore
datagrid.Columns.Add(chrfnamecol)|>ignore
datagrid.Columns.Add(chrlnamecol)|>ignore
datagrid.DataSource <- dataset11.Tables.["tblEmployee"]
//assingns the font to our form
dataform.Font<-ffont
//links our fieldname to each grid
//and change its header text
chrempnocol.DataPropertyName<-"chrempno"
chrempnocol.HeaderText<-"Employee No."
chrfnamecol.DataPropertyName<-"chrfname"
chrfnamecol.HeaderText<-"First Name"
chrlnamecol.DataPropertyName<-"chrlname"
chrlnamecol.HeaderText<-"Last Name"
//add the datagrid to our form
dataform.Controls.Add(datagrid)
//adds the controls to our form
dataform.Controls.Add(exitbutton)
dataform.Controls.Add(searchbutton)
dataform.Controls.Add(label1)
dataform.Controls.Add(label2)
dataform.Controls.Add(label3)
dataform.Controls.Add(label4)
dataform.Controls.Add(empnotext)
dataform.Controls.Add(emplabel)
dataform.Controls.Add(fnamelabel)
dataform.Controls.Add(lnamelabel)
//binds the fieldnames to our label
emplabel.Text<-Convert.ToString(dataset11.Tables.["tblEmployee"].Rows.Item(0).Item(0))
fnamelabel.Text<-Convert.ToString(dataset11.Tables.["tblEmployee"].Rows.Item(0).Item(1))
lnamelabel.Text<-Convert.ToString(dataset11.Tables.["tblEmployee"].Rows.Item(0).Item(2))
searchbutton.Click.Add(fun search->
//handles the row index number
let mutable introws=0
//determines if the record has been found or not
let mutable blnfound=false
//handles the total number of records
let mutable inttotrec=Convert.ToInt32(dataset11.Tables.["tblEmployee"].Rows.Count)
//handles the data inputted by the user
let strtext=Convert.ToString(empnotext.Text)
//while no match is found and the end of the file has not been reached
while((blnfound=false) && (introws<=inttotrec-1)) do
let strempnum=Convert.ToString(dataset11.Tables.["tblEmployee"].Rows.Item(introws).Item(0))
//compare the data inputted in the textbox to the employee number in our table
//if they are equal, display the match record
if strtext.ToUpper()=strempnum.ToUpper() then
blnfound<-true
emplabel.Text<-Convert.ToString(dataset11.Tables.["tblEmployee"].Rows.Item(introws).Item(0))
fnamelabel.Text<-Convert.ToString(dataset11.Tables.["tblEmployee"].Rows.Item(introws).Item(1))
lnamelabel.Text<-Convert.ToString(dataset11.Tables.["tblEmployee"].Rows.Item(introws).Item(2))
//compare to the next record while no match is found
introws<-introws + 1
//if no match is found, display this
if blnfound=false then
MessageBox.Show("Record not found.","Search a Record Value",MessageBoxButtons.OK,MessageBoxIcon.Information)|>ignore)
//when the exit button is clicked
exitbutton.Click.Add(fun exit->
//close the form and dataconnection
dataform.Close()
oleconn.Close())
//executes our application
Application.Run(dataform)
</pre><br />
Since Visual F# is very particular with the code indention, I posted below the screenshot of our code in the while loop section.<br />
<br />
<img src="http://img842.imageshack.us/img842/3404/1120201085855amfinal.png"></img><br />
<br />
Here's what it should look like if you click the run icon:<br />
<br />
<img src="http://img19.imageshack.us/img19/6843/1120201083823am.png"></img>Rey Dacocohttp://www.blogger.com/profile/16795901672669072701noreply@blogger.com0