Welcome to Dream.In.Code
Getting Help is Easy!

Join 136,105 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,699 people online right now. Registration is fast and FREE... Join Now!




Applescript Doing C++

 
Reply to this topicStart new topic

Applescript Doing C++

xtreampb
20 Nov, 2007 - 06:13 AM
Post #1

D.I.C Head
**

Joined: 20 Jun, 2007
Posts: 57



Thanked: 1 times
My Contributions
Hey,
yall have been a great help.

I have recently discoved the power of apple script and have been recomended for me to use applescript instead of C++ for what i am trying to do

i am trying to make an applescript application do what my C++ code is doing here:

CODE

#include <iostream>
#include <string>

using namespace std;

int main()
{
    int number_incorrect=0, number_correct=0, total_questions=0, point_value, score=100;
    string name;
    char answer;
    
    
    cout<<"\n\nWelcome to CET PRETEST";
    cout<<"\nWhat is your name:";
    cin>>name;

//must not have 3 questions    
    
    cout<<"\n\nGet ready "<<name<<endl;
    ++total_questions;
    cout<<"\n\nQuestion 1:\nA computer takes _____ and gives ______.";
    cout<<"\n    A) AC-AC \n    B) AC-DC \n    C) DC-AC \n    D) DC-DC";
    cout<<"\nYour answer:";
    cin>>answer;
    cout<<"\ncorrect answer: B"<<endl;
    if (answer == 'B' || answer=='b')
        ++number_correct;
        
    
    else
        ++number_incorrect;

    
    cout<<"\ntotal correct:"<<number_correct<<endl;
    
    ++total_questions;
    cout<<"\n\nQuestion 2:\nCMOS stands for:";
    cout<<"\n\n    A) Computer Made On Service\n    B) Computer Mode Onside Service\n    ";    
    cout<<"C) Complementry Metal Oxcide Semicunductor\n    D) Computer Mode Online Service";
    cout<<"\nEnter your Answer:";
    cin>>answer;
    cout<<"\ncorrect answer: C"<<endl;
    if (answer == 'C' || answer=='c')
        ++number_correct;
    
    
    else
        ++number_incorrect;
    
    cout<<"\nTotal correct:"<<number_correct<<endl;
    
    ++total_questions;
    cout<<"\n\nQuestion3:\nSIMM stands for what?";
    cout<<"\n\n A) single inline memory module\n B)    standard intergrated memory mode\n C)    Standard inline mmory mode\n D)    seriously infected motherboard mainframe"<<endl;
    cout<<"Your answer:";
    cin>>answer;
    cout<<"\ncorrect answer: A";
    if (answer == 'A' || answer =='a')
        ++number_correct;
    else
        ++number_incorrect;
    
    cout<<"\n Total correct:"<<number_correct<<endl;
    
    ++total_questions;
    cout<<"\n\nQuestion"<<total_questions<<"\nA floppy drive cable has how many pins?";
    cout<<"\n\n A) 20\n B) 30\n C) 32\n D) 40"<<endl;
    cout<<"Your answer:";
    cin>>answer;
    cout<<"correct answer: C";
    if (answer=='C' || answer=='c')
        ++number_correct;
    else
        ++number_incorrect;
    cout<<"\nTotal correct:"<<number_correct<<endl;
    cout<<"\nTotal incorrect:"<<number_incorrect<<endl;
    
    
    

//score
    point_value=100/total_questions;//100 divided by 2 = 50
    score=point_value*number_correct;//50 times number correct
    cout<<"\n\nYour score is: "<<score<<endl;

return 0;
}


i am trying to use applescript so that i can put the above code in a GUI. I am having a hard time figuring out how to do math in apple script
could yall help please
thx
chris
User is offlineProfile CardPM
+Quote Post

girasquid
RE: Applescript Doing C++
20 Nov, 2007 - 07:53 AM
Post #2

Barbarbar
Group Icon

Joined: 3 Oct, 2006
Posts: 1,266



Thanked: 14 times
Dream Kudos: 650
My Contributions
Math is pretty easy in Applescript:
CODE

set myVariable to 6 + 9



User is offlineProfile CardPM
+Quote Post

xtreampb
RE: Applescript Doing C++
20 Nov, 2007 - 11:03 AM
Post #3

D.I.C Head
**

Joined: 20 Jun, 2007
Posts: 57



Thanked: 1 times
My Contributions
thx,
but i want to put the test i posted above in an application.
how would i do that using applescript.

if you compiled the C++ code above, you will see that it is a test and everything for a basic computer class. The reason why i am trying to convert that test into apple script is so that i can quickly and eaisly make a GUI for that test.

i am obviously new to applescrip but I have messed around and been able to make a simple application

thx for the help

X

This post has been edited by xtreampb: 20 Nov, 2007 - 11:09 AM
User is offlineProfile CardPM
+Quote Post

girasquid
RE: Applescript Doing C++
20 Nov, 2007 - 06:02 PM
Post #4

Barbarbar
Group Icon

Joined: 3 Oct, 2006
Posts: 1,266



Thanked: 14 times
Dream Kudos: 650
My Contributions
You could just have it pop up dialogues with the questions, or windows - it's up to you, really. Try using dialogues, it would be the closest stylistically to what you've done with C++.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/1/08 09:09PM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month