473,573 Members | 3,904 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

printing a redacted word in an if loop

heiro1
29 New Member
My code won't print "REDACTED" in place of the redact variable. I do not know why though. Can anyone shed some light? I appreciate it! Here is my code :

Expand|Select|Wrap|Line Numbers
  1. puts "Whats your input brah?"
  2. text = gets.chomp
  3. puts "Whatchu are you hiding bro?"
  4. redact = gets.chomp
  5. words = text.split(" ")
  6. words.each {|x| if x == redact print "REDACTED"+" " else print x+" "}
Apr 25 '13 #1
2 5965
heiro1
29 New Member
This code definitely works if I use "do" instead of the curly braces. I tested it. The tutorial I am using said that those two are the same thing and can be used inter-changably but as I found, it doesn't work when I use curly brackets. Unless I am missing something important.
Apr 25 '13 #2
heiro1
29 New Member
I found the answer already but thank you if you were about to post something helpful!

Expand|Select|Wrap|Line Numbers
  1. puts "Whats your input brah?"
  2. text = gets.chomp
  3. puts "Whatchu are you hiding bro?"
  4. redact = gets.chomp
  5. words = text.split(" ")
  6. words.each {|x| if x == redact then print "REDACTED"+" " else print "#{x}"+" " end}
Apr 25 '13 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
3967
by: Andy Newland | last post by:
Hi Guys, I would like to print out a word document using a VB .NET component. I have got VBA and VB.Net talking to each other and can pass word objects between COM and .NET. My reason for doing this is to enable myself to be able to use the PrintSettings class and all of its advanced features - Duplex on/off, Color on/off etc.
2
5122
by: SSK | last post by:
hi i was trying to print a word document from a stored prcedure using the following two methods 1) cd C:\&&"C:\Program Files\Microsoft Office\OFFICE11\winword.exe" "c:\temp.doc" /mfileprint "/mfileprint" - this macro contains the code to print the word document and exit the word , this command runs fine when i run it at the command
0
2201
by: Les Desser | last post by:
We currently use Word documents, saved as OLE objects in the database, to print letter headings and the like. As this bloats the database, we would like to store instead the path (as text or Hyperlink) to an external Word document and then somehow, at run time, pull in the document onto a report. Does anyone have any idea how we could do...
4
7630
by: Jeff Harbin | last post by:
I've got an ACCESS 2000 application that I'm developing. One of the outputs of this app will be to generate a series of 'jobs' which corresponds to a record in the database. Each record will be printed on its own page which I've set up as a report and that's working fine. Accompanying each job is a Word (or Excel) document. Most jobs will...
5
3321
by: Stefania Scott | last post by:
I am trying to print a word document from Access. The code I've written works well in my computer but does not in the one were it is needed. Here the piece of code: 'doc path strObjectPath = "P:\2004worksheets\IIS_WS.doc" Set oWord = New Word.Application oWord.Documents.Add (strObjectPath) oWord.PrintOut
3
2391
by: David | last post by:
Hello, hope someone can help. I have a request to print word .doc check lists with selected records in Access for surgery procedure cards. I have hyperlinked the word doc's to a field in each record, but do not know how to write the code to open the word doc and print it. I assume this code should be put in the list box print button. As you...
5
1266
by: CJ Taylor | last post by:
I've been looking everywher efor this but all I can find is that Word's automation library doesn't allow you to pick a printer programatically... Anyone know of a soluition? Thanks, cJ
9
3449
by: ewolfman | last post by:
Hi, I need to provide the user with the option to click something, and what follows is: 1. Download a word document, without displaying winword. 2. Printing the document to the default printer (no print dialog should pop). 3. Close word. All of this must be completely "transparent" to the user, just like a
17
8685
by: wparrott | last post by:
Hello experts! I'm having trouble coding a button on a form and could use some help. In a nutshell, I'm attempting to code the button to do the following: 1. Choose the appropriate Word document 2. Fill in form fields on the doc using fields from the record 3. Print the document. 4. Close the word document suppressing any save dialogs. ...
0
1670
sueb
by: sueb | last post by:
I have a document with a watermark. In Word 2003, this watermark doesn't print but is only displayed (which is exactly what I want). However, in Word 2007, this watermark is printed and I can't figure out how to turn it off without actually removing it (which is not what I want). How do I tell Word 2007 not to print the displayed watermark?
0
7661
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8165
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7730
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6347
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5252
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3692
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3686
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2163
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1256
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.