Time variables with if and else statements for class script

Hello, for an in class assignment to create a script using random generated answers im trying to get the script set up for different answers depending on the time of day here is what i have so far, in bold is my second time that i would like to have if the
time is 6pm, the one that works right now is the one that is anything greater then 12pm and the one that is everything before 12pm the 6pm will not work:
#Clear the Windows command console screen
Clear-Host
#Define the variables used in this script to collect player inputs
$question = ""   #This variables will store the player's question
$status = "Play"  #This variable will be used to control game termination
$answer = 0  #This variable stores a randomly genrated number
$time = (Get-Date).Hour  #This variable stores the current hour of the day
#Display the game's opening screen
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host "               W E L C O M E   T O   T H E   W I N D O W S"
Write-Host
Write-Host
Write-Host
Write-Host "            P O W E R S H E L L   F O R T U N E   T E L L E R"
Write-Host
Write-Host
Write-Host   
Write-Host "                          By Zelandra"
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host " Press Enter to continue."
#Pause script execution and wait for the player to press the Enter key
Read-Host
#Clear the Windows command console screen
Clear-Host  
#Provide the player with instructions
Write-Host
Write-Host " The fortune teller is a very busy and impatient mystic. Make"
Write-Host 
Write-Host " your questions brief and simple and only expect to receive"
Write-Host
Write-host " Yes / No styled answers."   
Write-Host 
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host " Press Enter to continue."
#Pause script execution and wait for the player to press the Enter key
Read-Host
#Continue game play until the player decides to stop
while ($status -ne "Stop") {
  #Ask the player the first question
  while ($question -eq ""){
    Clear-Host  #Clear the Windows command console screen
    Write-Host
    $question = read-host " What is your question? "
  $question = ""  #Reset variable to a empty string
  #Retrieve a random number between 1 and 7
  $answer = Get-Random -minimum 1 -maximum 8
  #If it is the night the fortune teller will be a little more cranky 
  if ($time -gt 18) {
    Write-Host
    if ($answer -eq 1) { " Grrrr. The answer is NO, now let me get back to sleep!" }
    if ($answer -eq 2) { " Grrrr. The answer is !!!NEVER!!!" }
    if ($answer -eq 3) { " Grrrr. The answer is unclear, did you really think i would know?" }
    if ($answer -eq 4) { " Grrrr. The answer is sure whatever!" }
    if ($answer -eq 5) { " Grrrr. Even if i wanted to tell your fortune i wouldnt!" }
    if ($answer -eq 6) { " Grrrr. Look at the time, im busy SLEEPING!" }
    if ($answer -eq 7) { " Grrrr. Take whatever answer you want and leave me alone!" }
  #Select an answer based on the time and the random number
  #If it is the afternoon the fortune teller will be a little cranky
  if ($time -gt 12) {
    Write-Host
    if ($answer -eq 1) { " Grrrr. The answer is no!" }
    if ($answer -eq 2) { " Grrrr. The answer is never" }
    if ($answer -eq 3) { " Grrrr. The answer is unclear!" }
    if ($answer -eq 4) { " Grrrr. The answer is yes!" }
    if ($answer -eq 5) { " Grrrr. The answer is absolutely not!" }
    if ($answer -eq 6) { " Grrrr. The answer is unforseeable!" }
    if ($answer -eq 7) { " Grrrr. Im sorry could you repeat that?" }
  #If it is morning the fortune teller will be in a good mood
  else {
    Write-Host
    if ($answer -eq 1) { " Ah. The answer is yes!" }
    if ($answer -eq 2) { " Ah. The answer is Always" }
    if ($answer -eq 3) { " Ah. The answer is uncertain!" }
    if ($answer -eq 4) { " Ah. The answer is no!" }
    if ($answer -eq 5) { " Ah. The answer is there is a fair cha... OH LOOK A SQUIRREL!" }
    if ($answer -eq 6) { " Ah. I think you meant to ask something else!" }
    if ($answer -eq 7) { " Ah. Well it looks like your wish will be ready tonight!" }
  Write-Host
  Write-Host
  Write-Host
  Write-Host
  Write-Host
  Write-Host
  Write-Host
  Write-Host
  Write-Host
  Write-Host
  Write-Host
  Write-Host
  Write-Host
  Write-Host
  Write-Host
  Write-Host
  Write-Host
  Write-Host
  Write-Host
  Write-Host " Press Enter to continue."
  #Pause script execution and wait for the player to press the Enter key
  Read-Host
  #Clear the Windows command console screen
  Clear-host
  Write-Host
  #Prompt the player to continue or quit
  $reply = read-host " Press Enter to ask another question or type Q to quit."
  if ($reply -eq "q") { $status = "Stop" }
#Clear the Windows command console screen
Clear-Host
#Provide the player with instructions
Write-Host 
Write-Host " Very well then. Please return again to get all your questions"
Write-Host " answered." 
Write-Host
Write-Host 
Write-Host
Write-Host
Write-Host
Write-Host 
Write-Host
Write-Host
Write-Host  
Write-Host 
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host 
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host
Write-Host " Press Enter to continue."
#Pause script execution and wait for the player to press the Enter key
Read-Host
#Clear the Windows command console screen
Clear-Host  
Thanks again if anyone can provide help.

Hi,
Use -and in your afternoon if test.
Don't retire TechNet! -
(Don't give up yet - 12,950+ strong and growing)

Similar Messages

  • I just bought and backed up my computer and time machine with a "Seagate BackUp Plus for Mac". Now my time machine is empty. Panicked. can anyone help?

    I just bought and backed up my computer and time machine with a "Seagate BackUp Plus for Mac". Now my time machine is empty. Panicked. can anyone help?

    Lets start over...
    Please restart the network.. shut down everything..
    Restart in order.. modem.. router.. if different to TC.. or TC.. client devices.. wait 2min between each startup.
    If the TC does not show up on the computer, in finder.. then we need more info.. what OS are you running?
    Does the TC show up in Airport utility? Are you running wireless or ethernet?
    If you still have issues.. plug the TC directly into the computer by ethernet.
    Do a full factory reset of the TC.. and see if it now shows up.
    Please tell us exactly what model TC it is and how old.. the A1xxx model number from the base will help if you don't know.
    You take a screen shot of the TC opened in finder.
    eg..
    My TC is named Tardis4.. click on it.. and then open the data folder.. on this one called Tardisdata.
    Then take a screen shot of it so we can see what the problem is.. screenshot.. with area selection.. control + shift + 4 .. the picture goes into the desktop.. and then you click the picture icon in the posting web page controls and select the picture.

  • Compilation error with simple if-else statement

    package chapterFive;
    * Author: Sarab
    * Filename: MainClass.java
    * Purpose: Try and get my mind around the concept of the selection
    * control structures and repetition statements
    class MainClass {
         public static void main(String [] args)
              // some variables and prompt for input
              java.util.Scanner scan = new java.util.Scanner(System.in);
              System.out.print("Please enter your name: ");
              String input = scan.nextLine();
              // some repetition statement, for loop
              if (input.equals("Sarab"));
                   System.out.println("Welcome Sarab!");
              else
                   System.out.println("You are in the else statement");
                   for(int sentinelValue; sentinelValue<5; sentinelValue++)
                        System.out.println("The following is the numbers 0-4"
                                  + " printed on separate lines: " + sentinelValue);
              System.out.println("This line will print regardless of whether you"
                        + " entered the if or the else portion of the selection"
                        + " statement.");
    }I am getting the following error:
    Exception in thread "main" java.lang.Error: Unresolved compilation problem:
         Syntax error on token "else", delete this token
         at chapterFive.MainClass.main(MainClass.java:26)What's the matter? This looked straight forward enough to me.

    if (input.equals("Sarab"));
    // is the same as
    if (input.equals("Sarab")) {}
    // so what you have amounts to this:
    if (input.equals("Sarab")) {}
      System.out.println("Welcome Sarab!");
    else { ... }You've got an if block that does nothing, then a block that always executes, calling println, and then your else. Since you have that block between if and else, the if has ended and it's not legal to use else.
    Get rid of the semicolon after if.

  • Essbase Variable with more than a value for use after in Planning forms.

    I want to now if it would be possible to create a variable with more than a value for use after in Planning forms.
    The variable that I want to use is created in Essbase.
    Example:
    &Years = FY08,FY09,FY10

    Hi.
    The only workaround I know for the problem is to create parent in the dimension.
    In your case, create member “planyears”.
    Then you define children that are shard (this are the multiple member for the variables FY08, FY09 etc..)
    Create Essbase sub variable that will have 1 member value “planyears”
    When you use the Sub Variable in form select function “Children” and in that case it will use the member FY08,FY09 etc on the form.
    Limitation: I’m working on version 9.2.0.3 so you can’t create hierarchy in the year dimension, but you can use it in other dimension.
    AE

  • I use a Win7 PC with iCloud and Outlook 2010 for syncing my calendar and contacts. I can enter data in my Outlook Calendar and it will appear in iCloud, but data entered in iCloud does not sync back to Outlook.  ICloud syncs to my iphone fine both ways.

    I use Win 7 PC with iCloud and Outlook 2010 for syncing my Contacts and Calendar.  They have stopped syncing...mostly.
    Now, appointments I enter on my local Outlook (iCloud) Calendar goes up to iCloud fine.  But, data I enter on iCloud directly does not come down to my local Outlook iCloud Calendar.  If I reboot the computer, the iCloud data shows up.
    Also, Contacts I try to enter on my Outlook (iCloud) Contacts goes up to iCloud fine, but does not show up in my local iCloud Contacts.
    All syncing works with my iPhone.
    I have signed out of iCloud on PC.  I have stopped syncing and re-started.  No change.
    I have an .aplzod folder for iCloud.  I have a separate Earthlink.net.pst email account in Outlook and a me.com.pst Outlook email account (which I don't actually use) listed under Data Files.
    Any help would be appreciated.  Curious that Outlook will upload to iCloud but not receive downloads unless I reboot.  However, rebooting does not download the missing Contacts.
    Jim Robbins

    Hi Jim!
    You've started off with some good troubleshooting steps, so let's see if we can take this a little further and figure out what the issue is with your iCloud contacts and calendars. I have two articles here that will help you troubleshoot this issue a little further, but the troubleshooting steps for both articles are exactly the same, so I will lay those out for you here:
    Note: When using iCloud Control Panel 2.0 and later, iCloud Calendar event descriptions in Outlook 2010 do not support text formatting (bold, italics, or underline), HTML, images, or attachments. The contextual (right-click) menu has also been disabled.
    If you are having trouble with a PC (with Outlook 2007 or 2010) and iCloud Calendar, try each of these steps, testing after each to see if the issue is resolved:
    Verify that you are using a Windows configuration that is supported by iCloud. For more information, see iCloud system requirements.
    When enabling Calendars in the iCloud Control Panel, part of the setup process is to copy your Calendars data from the default Outlook ".pst" file to iCloud, and then remove the Calendars from the ".pst" file by placing them in the Deleted Items folder in Outlook. The Calendars data is then stored in the iCloud data set within Outlook so that changes can be pushed to and from Outlook by iCloud. Be sure you are looking for your data within the iCloud dataset within Outlook after enabling Calendars in the iCloud Control Panel. The deleted files can be seen by viewing Deleted Items within your Outlook Folder List. This is not iCloud removing your data; iCloud simply copies your data into the iCloud data set and then removes the local Calendars data by placing it in the Deleted Items folder.
    Make sure your computer is online. Attempt to view www.apple.com and iCloud.com. If you can't connect to the Internet, your iCloud calendars and events will not update in Outlook. Click here for more information about troubleshooting your Internet connection.
    Open a secure website to test if you are online as is necessary for iCloud Calendar. This also tests if the ports 80 and 443 are accessible. Outlook requires port 443 access to iCloud in order to push and pull updates to and from the iCloud Calendar servers.
    Verify that your iCloud member name is entered into the iCloud Control Panel pane. See iCloud Setup for more information about setting up iCloud on Windows.
    Completely close and reopen the iCloud Control Panel.
    If you recently made changes in Outlook and they are not moving to your other devices or vice-versa, click the Refresh button in Outlook.
    Turn iCloud Calendar off and back on:
    Close Outlook.
    Open the Windows Control Panel:
    In Windows 8, move the pointer to the upper-right corner of the screen to show the Charms bar, click the Search charm, and then click the iCloud Control Panel on the left.
    In Windows 7 and Vista, choose Start menu > All Programs > iCloud > iCloud.
    Remove the checkmark in the checkbox next to Mail, Contacts, Calendars & Tasks, and click Apply. Wait a few seconds, then replace the checkmark, and click Apply.
    Open Outlook and test to see if the issue has been resolved.
    Ensure the iCloud Outlook Add-in is active within Outlook.
    Outlook 2010:
    Open Outlook 2010.
    Click the File menu.
    Click Options in the left panel of the Outlook window.
    Click Add-Ins in the left panel of the Outlook Options window.
    Look at the list of add-ins beneath "Active Application Add-Ins" and verify that the "iCloud Outlook Add-in" is listed.
    For Outlook 2007, follow these steps to verify the iCloud Outlook Add-in is active
    Open Outlook 2007.
    From the Tools menu, choose Trust Center.
    Select Add-ins from the left column.
    Look at the list of add-ins beneath "Active Application Add-Ins" and verify that the "iCloud Outlook Add-in" is listed.
    For additional information about managing Add-ins with Microsoft Outlook, see this Microsoft support document.
    Restart your computer. This may sound simple, but it does reinitialize your network and application settings and can frequently resolve issues.
    iCloud: Troubleshooting iCloud Contacts
    http://support.apple.com/kb/ts3998
    iCloud: Troubleshooting iCloud Calendar
    http://support.apple.com/kb/ts3999
    Thanks for using the Apple Support Communities!
    Cheers,
    Braden

  • Hello, I use photoshop cc 10 days and I did a lot of files with layers and channels. For two days in two different locations that only happens in some documents when you reopen the job done no more .. Example 6 channels on the facts I see only one .. Than

    Hello, I use photoshop cc 10 days and I did a lot of files with layers and channels.
    For two days in two different locations that only happens in some documents when you reopen the job done no more .. Example 6 channels on the facts I see only one ..
    Thank you for your attention.
    Annalisa 

    Don't understand what you writing here.  Screen shoots would be most helpful.
    Supply pertinent information for quicker answers
    The more information you supply about your situation, the better equipped other community members will be to answer. Consider including the following in your question:
    Adobe product and version number
    Operating system and version number
    The full text of any error message(s)
    What you were doing when the problem occurred
    Screenshots of the problem
    Computer hardware, such as CPU; GPU; amount of RAM; etc.

  • My Apple Earphones with Remote and Mic White For iPhone says: made ​​in vietnam. i want to know if they are OEM?

    My Apple Earphones with Remote and Mic White For iPhone says: made ​​in vietnam right in the cord. i want to know if they are OEM? here my email: [email protected], thanks.

    Accidental damage is not covered under the warranty but if possible to reset the screen without causing additional damage, the Apple Store should do this without charging for it.

  • I already have a new book that is ready to publish as an iBook. In addition I also have an app prepared for this book. Please tell me how to upload this book (title is: "How To Cope...with life") and the app for it into your iBook Authors app so I can hav

    I already have a new book that is ready to publish as an iBook. In addition I also have an app prepared for this book.
    Please tell me how to upload this book (title is: "How To Cope...with life") and the app for it into your iBook Authors app so I can have it offered for sale @$0.99, in your app store?
    FROM: Terry Weber, Email: [email protected]

    https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/wa/bookSignup

  • Balance Sheet and Income Statement for Plan data

    Hi Everyone,
    in our Company  we maintain Plan in COPA for next year that is for 2009 , we have finished all the Planing activities and now (users asked me), they want to have Balance Sheet and Income Statement for the data we have in Plan version , I am not sure what they are Talking about, please help me ,
    where can I set up that requirement ?  and what is actually Balance Sheet and Income Statement for Plan data?
    Thx
    Niki

    Is the issue resolved?
    What did you do?
    Thanks
    Naveen

  • Risk with Locking and changinf password for SAPCPIC

    Hi All,
      Please advice if there is any risk with locking and changing password for SAP standard user SAPCPIC .We are on system 4.6D .
      Somewhere I could find that if there is any RFC destination defined with this user then it may cause problem after locking .I found following entry in RFCDES table .
    a       I                                          
    M=200,U=SAPCPIC,L=E,v=3FB20DF66CA32E419606388B51,   
    But I could not find any entry in sm59 for this .What is this entry as it is not there in SM59 .
    Any other known risks pls tell me .
    Thanks,
    Chittaranjan

    Can password of SAPCPIC user be changed without any problem?
    We are on ECC6.
    Report RSUSR003 refer to note 29276 and note says that changing password will cause problem with SM51 and some other report as the password is hard-coded there. Though this note seems to be bit old.
    Edited by: Pawan Kesari on Jun 9, 2009 7:58 PM

  • HT201210 my got to many times enter wrong pasword and it lock for 23,455,555 minutes and i try to reset but its not reseting and i got error number 9

    i enter too many times a wrong pasword and it lock for 23,465,444 minutes and i try to reset but its not hapening

    Locked Out, Forgot Lock or Restrictions Passcode, or Need to Restore Your Device: Several Alternative Solutions
    A
    1. iOS- Forgotten passcode or device disabled after entering wrong passcode
    2. iPhone, iPad, iPod touch: Wrong passcode results in red disabled screen
    3. Restoring iPod touch after forgotten passcode
    4. What to Do If You've Forgotten Your iPhone's Passcode
    5. iOS- Understanding passcodes
    6. iTunes 10 for Mac- Update and restore software on iPod, iPhone, or iPad
    7. iOS - Unable to update or restore
    Forgotten Restrictions Passcode Help
                iPad,iPod,iPod Touch Recovery Mode
    You will need to restore your device as New to remove a Restrictions passcode. Go through the normal process to restore your device, but when you see the options to restore as New or from a backup, be sure to choose New.
    You can restore from a backup if you have one from BEFORE you set the restrictions passcode.
    Also, see iTunes- Restoring iOS software.

  • Problem with if/else statement for adventure game

    Can anyone offer a hint as to why I am getting a null value printed out in the last line. I have comments that indicate what progress or validation step has occurred to move forward. There is something obviously not working with my user input if/else block. It's supposed to the user input, n,s,e, or w and execute the code, nextRoom = current.get*(); * - referring to whatever direction is specified by the user. For instance if the user enters "e", then this code is executed ... nextRoom = current.getEast(); and the players' new room is set to this room: player1.setCurrentRoom(nextRoom).
    That is not what is currently happened as validated by the last line System.out.println(player1.getCurrentRoom()); which prints null; This must be something obvious no?
    Room r1 = new Room();  //instantiates new room r1
            r1.setName("Hallway");  //sets r1's name to Hallway
            r1.setDescription("Long and dark.  There are exits to the north, east and west");
            Room r2 = new Room();  //new room2, etc...
            r2.setName("Bathroom");
            r2.setDescription("Bathroom stinks. There are no doors other than the entry");
            Room r3 = new Room();
            r3.setName("Kitchen");
            r3.setDescription("This is where the food is cooked");
            Room r4 = new Room(); 
            r4.setName("Master Bedroom");
            r4.setDescription("Bedroom of the master");     
            r1.setEast(r2); // sets r2 east of r1
            r1.setWest(r3); //sets r3 west of r1
            r1.setNorth(r4); //sets r4 north of r1
            System.out.print("The room east of r1 is: ");  // this is simply a check to verify that it has set the room properly and it does
            System.out.println(r1.getEast());               
            System.out.printf("You are currently in the %s", r1.getName());
            System.out.println();          //another validation step
            System.out.println("There are exits on the north end of the\n" +
                                "hallway and midway on both sides\n");
            System.out.println("To move you can type the following: \n"+
                    "(n) to move north\n" +
                    "(e) to move east\n" +
                    "(w) to move west\n" +
                    "(s) to move south\n");
            player1.setCurrentRoom(r1);
            System.out.print("You are currently in ");
            System.out.println(player1.getCurrentRoom()); //this prints out the correct value for current Room, which is the Hallway
            Room current = player1.getCurrentRoom();     
            System.out.println(current);  //as a double check this does print out the correct value for current, which is the Hallway
            System.out.println("Where would like to go?  Your choices are east, west, and north.\n" +
                    "Enter e, n, or w");
            Scanner ns = new Scanner(System.in);       
            String input = ns.next();
            Room nextRoom = null; 
            if (input == "e") {
                nextRoom = current.getEast();
            else if (input == "n") {
                nextRoom = current.getNorth();
            else if (input == "w") {
                nextRoom = current.getWest();
            else if (input == null) {
                System.out.println("Illegal Move");
            player1.setCurrentRoom(nextRoom);  //somehow this is setting the current room value to null
            System.out.println(player1.getCurrentRoom());  //this prints out null

    I initially thought of that but my IDE (netbeans) gives me the incompatible data types (expects boolean, gets string) error when I use input = rather than input (==.). I really want to avoid asking the dumb ass java questions (I should have posted the new to java forum) but how do you set this up if Scanner is expecting a String, my input variable is String and the if statement is expecting a boolean instead of a String?
    Scanner ns = new Scanner(System.in);       
    String input = ns.next();
    if (input = "e" ) {
                nextRoom = current.getEast();
            else if (input = "n" ) {
                nextRoom = current.getNorth();
            else if (input = "w" ) {
                nextRoom = current.getWest();
            else if (input = null) {
                System.out.println("Illegal Move");
            player1.setCurrentRoom(nextRoom);  //somehow this is setting the current room value to null
            System.out.println(player1.getCurrentRoom());  //this prints out null

  • Printer error using Time Capsule with Vista64 and HP printe.  Any one else?

    I'm running Time Capsule with my MacBook and Vista 64 PC, and trying to print on a HP5510 All-in-one.
    The Time Capsule is set up according to the manual and I can print wirelessly from the MacBook. Also, the MacBook and the PC can both access the TC HD.
    The problem comes when I'm trying to print with the PC. It will print about 3/4 of the page and stop, showing an error. At that point, I cannot purge/cancel/restart the print job. I need to shut down the PC and printer to get rid of the error.
    Anyone else have this problem?
    Thanks
    Ray

    Have you downloaded and installed the following updated Mountain Lion compatible driver and software for your model?:
        http://h10025.www1.hp.com/ewfrf/wc/softwareDownloadIndex?softwareitem=mp-107723- 1&cc=us&dlc=en&lc=en&os=219&product=4073738&sw_lang=
    Hope this helps

  • Help with TYPE and LIKE statements

    HI guys,
    I know this is really novice stuff, but I am a little confused.
    Can anyone please explain the exact difference between TYPE and like with the help of a program, to understand it.
    What situation would demand the use of each of the LIKE statement, since I can do all these things using the TYPE ?

    Hi Akhil,
    I summarized the info in SDN posts and SAP Help, to make it easier for you to understand. I also included some code snippets. Hope these prove to be helpful to you.
    The following is from SAP Help:
    The Additions TYPE and LIKE
    The additions TYPE type and LIKE dobj are used in various ABAP statements. The additions can have various meanings, depending on the syntax and context.
    ·        Definition of local types in a program
    ·        Declaration of data objects
    ·        Dynamic creation of data objects
    ·        Specification of the type of formal parameters in subroutines
    ·        Specification of the type of formal parameters in methods
    ·        Specification of the type of field symbols
    A known data type can be any of the following:
    ·        A predefined ABAP type to which you refer using the TYPE addition
    ·        An existing local data type in the program to which you refer using the TYPE addition
    ·        The data type of a local data object in the program to which you refer using the LIKE addition
    ·        A data type in the ABAP Dictionary to which you refer using the TYPE addition. To ensure compatibility with earlier releases, it is still possible to use the LIKE addition to refer to database tables and flat structures in the ABAP Dictionary. However, you should use the TYPE addition in new programs.
    The LIKE addition takes its technical attributes from a visible data object. As a rule, you can use LIKE to refer to any object that has been declared using DATA or a similar statement, and is visible in the current context.  The data object only has to have been declared. It is irrelevant whether the data object already exists in memory when you make the LIKE reference.
    ·        In principle, the local data objects in the same program are visible. As with local data types, there is a difference between local data objects in procedures and global data objects. Data objects defined in a procedure obscure other objects with the same name that are declared in the global declarations of the program.
    ·        You can also refer to the data objects of other visible ABAP programs. These might be, for example, the visible attributes of global classes in class pools. If a global class cl_lobal has a public instance attribute or static attribute attr, you can refer to it as follows in any ABAP program:
    DATA dref TYPE REF TO cl_global.
    DATA:  f1 LIKE cl_global=>attr,
           f2 LIKE dref->attr.
    You can access the technical properties of an instance attribute using the class name and a reference variable without first having to create an object. The properties of the attributes of a class are not instance-specific and belong to the static properties of the class.
    Example
    TYPES: BEGIN OF struct,
             number_1 TYPE i,
             number_2 TYPE p DECIMALS 2,
           END OF struct.
    DATA:  wa_struct TYPE struct,
           number    LIKE wa_struct-number_2,
           date      LIKE sy-datum,
           time      TYPE t,
           text      TYPE string,
           company   TYPE s_carr_id.
    This example declares variables with reference to the internal type STRUCT in the program, a component of an existing data object wa_struct, the predefined data object SY-DATUM, the predefined ABAP type t and STRING, and the data element S_CARR_ID from the ABAP Dictionary.
    The following info is from various posts:
    --> Type: It is used when userdefined object link with SAP system data type.
    Local types mask global types that have the same names. When typing the interface parameters or field symbols, a reference is also possible to generic types ANY, ANY TABLE,INDEX TABLE, TABLE or STANDARD TABLE, SORTED TABLE and HASHED TABLE.
    --> Like: It is when data object link with the other data object.
    --> TYPE, you assign datatype directly to the data object while declaring.
    --> LIKE,you assign the datatype of another object to the declaring data object. The datatype is referenced indirectly.
    you can refer to all visible data objects at the ABAP program's positon in question. Only the declaration of the data object must be known. In this case it is totally irrelevant whether the data object already exists physically in
    memory during the LIKE reference. Local data objects mask global data objects that have the same name.
    --> Type is a keyword used to refer to a data type whereas Like is a keyword used to copy the existing properties of already existing data object.
    Types: var1(20) type c.
    data: var2 type var1. ( type is used bcoz var1 is defined with TYPES and it
    does not occupy any memory spce.
    data: var3 like var2. ( like is used here bcoz var2 is defined with DATA
    so it does occupy space in memory ).
    data: material like mara-matnr. ( like is used here bcoz mara-matnr is stored in memory)
    --> Type refers the existing data type
    --> Like refers the existing data object
    Please Reward Points if any of the above points are helpful to you.
    Regards,
    Kalyan Chakravarthy

  • Boolean error with a If else statement

    Hello, i am new to java, and the only other programing language i have used is pascal, and compared to java its ALOT different any ways my problem. I am trying to write a simply little program which random selects a number between 1 and 10, i did that fine got to show that on screen with no probelm . Next i wanted to but in a if else statement, depending which numbers was selected it would show a different message this is where i am getting a probelm, here is the code for the whole thing:
    // randomColour
    import javax.swing.JOptionPane;
    public class randomColour {
      public static void main ( String args [])
        int value;
         value = 1 + ( int ) ( Math.random() * 10 );
            if (value = "1" )
             System.out.println("Green");
               else
                System.out.println("Blue");
              System.exit( 0 );
       } // end mainWhen i try to Compile it comes up with error saying required:boolean why is this? and what can i do to change to fix it?

    A single = is used to indicate assignment. You are testing for equality which requires ==. Also, "1" is a String. Value is an int. Changeif value = "1" to if value == 1Mark

Maybe you are looking for

  • IPod Nano troubles, please help

    I'll try to explain this problem to the best of my ability, this has been an ongoing problem since my sister got her iPod Nano: Me and my sister both got iPods for Christmas, her a Nano and myself a Video, now this isn't about me, my iPod works with

  • HT5493 Java update and reverting to 1.6 plug in.

    Good afternoon. After installing the java update this week I've realised it makes my Macbook useless for work. I regularly rely on a Corporate Information System at my University to access student records. This system is incompatible with Java 7, upo

  • Can we schedule a report to run in  foreground daily

    Hi, I want to run a report in foreground daily.I know this can be done in background but i want to schedule in foreground. Can we schedule a report for running on daily basis. I am getting a dump if i do this in background job.Plz reply me. regards,

  • Best way to handle cliet disconnection

    hello my friends. im working on a project that there is one server and it runs always and it should receive clients connection requests and handle their disconnection. i wrote my disconnect code on clients like below: private void button2_Click(objec

  • On starting Essbase, system throws error "CSS Initialization Fails"

    Hi I have been using the hyperion essbase in the past. Today the someone removed the network cable connecting to the servers. I put them back but since then i am facing issue where i cannot connect to Essbase server. I tried restarting the essbase se