3 Replies - 2150 Views - Last Post: 20 November 2007 - 07:02 PM Rate Topic: -----

#1 xtreampb  Icon User is offline

  • D.I.C Regular

Reputation: 14
  • View blog
  • Posts: 337
  • Joined: 20-June 07

Applescript Doing C++

Posted 20 November 2007 - 07:13 AM

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:

#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

Is This A Good Question/Topic? 0
  • +

Replies To: Applescript Doing C++

#2 girasquid  Icon User is offline

  • Barbarbar
  • member icon

Reputation: 108
  • View blog
  • Posts: 1,825
  • Joined: 03-October 06

Re: Applescript Doing C++

Posted 20 November 2007 - 08:53 AM

Math is pretty easy in Applescript:
set myVariable to 6 + 9


Was This Post Helpful? 0
  • +
  • -

#3 xtreampb  Icon User is offline

  • D.I.C Regular

Reputation: 14
  • View blog
  • Posts: 337
  • Joined: 20-June 07

Re: Applescript Doing C++

Posted 20 November 2007 - 12:03 PM

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 November 2007 - 12:09 PM

Was This Post Helpful? 0
  • +
  • -

#4 girasquid  Icon User is offline

  • Barbarbar
  • member icon

Reputation: 108
  • View blog
  • Posts: 1,825
  • Joined: 03-October 06

Re: Applescript Doing C++

Posted 20 November 2007 - 07:02 PM

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++.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1