Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6796281
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:26:54+00:00 2026-05-26T18:26:54+00:00

Because each time I try to assign a word to one it doesn’t work

  • 0

Because each time I try to assign a word to one it doesn’t work and it results in 1, 2, 3 or 4 because there are 4 variables.

:foodrandom
set /a dish=0
set /a rfood1=4*%random%/32768+1
IF %rfood1%==1 set /a food1=carrots
IF %rfood1%==2 set /a food1=potatoes
IF %rfood1%==3 set /a food1=cabbage
IF %rfood1%==4 set /a food1=corn

set /a rfood2=4*%random%/32768+1
IF %rfood2%==1 set /a food2=hazelnuts
IF %rfood2%==2 set /a food2=acorns
IF %rfood2%==3 set /a food2=apples
IF %rfood2%==4 set /a food2=strawberries

set /a rfood3=4*%random%/32768+1
IF %rfood3%==1 set /a food3=parsley
IF %rfood3%==2 set /a food3=sage
IF %rfood3%==3 set /a food3=rosemary
IF %rfood3%==4 set /a food3=thyme

echo You make a nice meal from a few %rfood1%, some %rfood2% and scent it with some %rfood3%.

echo You win.
ping localhost -n 5 >nul
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T18:26:55+00:00Added an answer on May 26, 2026 at 6:26 pm

    You need to review the description of SET command.

    set variable=string assigns the string to the variable. set /A variable=expression evaluate the arithmetic expression and assign the numeric result to the variable. In the expression you may use the value of another variable by just using its name.

    So…

    Your command set /a food1=carrots mean assign to food1 the same numeric value of carrots; if this variable does not exists or contains a non-numeric value, assign a zero. Perhaps the intended result is set food=carrots?

    Also, note that you are NOT displaying the value of food1, food2 or food3 variables that supposedly contains the strings, you just show the values of the rfood... numeric variables…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I subscribe to a newsletter from www.sqlservercentral.com that I like because each day I
I have periods table that has start_at:datetime end_at:datetime . Because each period begins and
Because Canvas3D doesn't have the ability to resize dynamically with the parent frame, I
Ok saddle up cowboys, because this is going to be a long one. I
i am trying to display a random string each time a button is pressed
I'm just trying to run a new thread each time a button click even
So what I need is simple: each time we perform our shader (meaning on
The first time I open one of my child forms from the main form
I have a strange problem with a method is called each time a button
I am trying to use microsoft translator and each time I am trying to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.