Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

1401.

Solve : VB Keypress function?

Answer»

I'm using VB and I wandered how to get a KEYPRESS to carry out a function. For example I run the program, and I enter UP on my keyboard, this carries out a function. So when a key is entered (it can be any key) it calls a function.

====SAMPLE CODE====

sub draw_circle()

'x, y are positions
picture.circle (x, y), 80

End sub

'if statement is carried out when specified key entered, such as A
If [Key is pressed] then
'calls statement to draw circle in picture when key is entered
call draw_circle

End if
==============
You can use KeyPress, KeyUp, KEYDOWN Events for this

Example:

Private Sub Form_KeyPress(KeyAscii As INTEGER)
If KeyAscii=13 Then '13 is Ascii Code for "ENTER" key
'Call FUNCTIONS Here
ElseIf KeyAscii=27 Then '27 is Ascii Code for "ESC" key
'Call Functions Here
End If
End Sub


or

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode=38 And Shift=0 Then 'UP Arrow Key
'Call Functions Here
ElseIf KeyCode=37 And Shift=0 Then 'Left Arrow Key
'Call Functions Here
ElseIf KeyCode=39 And Shift=0 Then 'Right Arrow Key
'Call Functions Here
ElseIf KeyCode=40 And Shift=0 Then 'Down Arrow Key
'Call Functions Here
End If
End Sub



'This doesn't seem to be working exactly for me. I do as you ask but it does not call the function.

If I do it with a textbox or a LABEL say and select "ENTER" (13 in ascii) then it carries out the function I want, but it isn't working for the whole form.

Anyone?You can try setting your Form.KeyPreview = True at RunTime or DesignTime.

1402.

Solve : Lock ComboBox?

Answer»

Hello. I have a little problem with VBA (in Excel 2003)

I WANDERED what is the code to lock down a combo box on a combo box in excel. All I want to do is lock is so that people cannot alter the text already in the combo box, but still be able to use it. I have tried combobox1.lock but so far no luck...and I cannot find anything in the properties that will do this. (bear in mind it is taken from the control toolbox not the form toolbox).

Any help would be appreciated, thanks.

BUMP

Can you help please?I was unable to find whether the .locked property had been dropped for Excel 2003 combo boxes. If you can't find it on the property SHEET, you may be able to define a range object for the cells the combo box covers. The range object should have a .locked property.

Double check that there are no overlaps or INTERSECTS with other controls you may have defined.

Good luck. There is a .locked because when ENTER "." it gives me an option of possible choice. And
the combo box is not covering any cells it is over the spreadsheet, as they are the same as VB controls...Quote

All I want to do is lock is so that people cannot alter the text already in the combo box, but still be able to use it.

This statement seemed contradictory until I realized this has nothing to do with the .locked property. Try setting the .style property to 2.

yes it worked! thank you thats all I needed. Setting the Combo1.Style to 2 just stops users typing into the Combo. If you want to stop users using the Combo1 then just set
Combo1.Enabled = FALSE.
1403.

Solve : VB project to Exe.?

Answer»

Hi Everybody!!

I got CD of Visual basic 6.0 having may example too with Book of Microsoft press, Could anyone guide me how could i make .exe.

Thanks
JayFrom the File menu (about ⅔ down) click on Make projectname.exe

OR

use the Run menu for OPTIONS to use during testing (run or compile and run)Thanks!! Gr~d!! but could u know little more as file menu this option is not available.Is it version problem??
Is there any link to get exact version?

Thanks n Best Regards

JayNot sure what version you have. Are you saying there is no file drop down menu or that there is no make option? Did the CD come with the book as one package?

To check your version, click on help==>about

A screen should appear with all the relevant version info.

Quote from: Sidewinder on April 09, 2007, 05:25:37 AM

Are you saying there is no file drop down menu or that there is no make option?
Quote from: Sidewinder on April 09, 2007, 05:25:37 AM
Did the CD come with the book as one package?

Thanks!!
No, There is no make option.
Yes cd come with the book.

Thanks n Regards,
JayWhen you installed the VB program, did you get the complete INTEGRATED development environment (IDE)? It looks something like a workbench where you can design your forms, write your code, and test your programs.

What info did you get when you CHECKED the version information? What options do you have on the file menu?

I didn't realize Microsoft Press included full BLOWN products with their books.

Let us know. Quote from: Sidewinder on April 09, 2007, 05:58:40 AM
It looks something like a workbench where you can design your forms, write your code, and test your programs.



Thanks!!

I think so, VB 6.0 working model

Thanks n RegardsPlease let us know what is on the file menu and also the run menu. Also you might check the Help; look for something like Make or Build or Compile.

Thanks!!

As already u said, someone also saide that this is not full virsion so this facility is not available.

Have to buy full version CD.

:-\Besides this i want to get advice-Is the must background of software Engineering to learn the programming and get the job respected. If my humble request is being answered by you, Please also know which prgramming is preferable.

Thanks N Regards,Software engineering is a huge field and there is no real agreement about it's definition or who it's members are.

Quote
Safe to say knowledge from software design, software construction, software testing, and software maintenance tasks, computer engineering, computer science, management, mathematics, project management, quality management, software ergonomics, and systems engineering are all included in software engineering.

Source: Wikipedia

As for choosing a language, it's difficult to pick one over another as they are all useful for one thing or another. VB is good for programs that require interactive input and output. C is good for writing system programs such as entire operating systems, programs that keep aircraft aloft, or even calculating real time orbital equations for spacecraft. Persons maintaining databases, systems or networks may use any of the SCRIPTING languages to assist in their duties. Statisticians in an insurance company may prefer a package such as SAS which can model and trend massive amounts of data. Many devices such as phones, traffic lights and even refrigerators are Java-enabled. Utility companies can now read their meters from your curb. Someone will have to program these and yet to be invented devices.

Good luck.

By default you can't make exe's with VB6 Student or Learning Edition. There are ways around this but I don't think I'm allowed to post them here.
1404.

Solve : McAfee won't uninstall?

Answer»

I am trying to uninstall McAfee anti virus program that was installed on my new laptop when I bought it. It began to play up after only two weeks, and I prefer Trend. After a few UNSUCCESSFUL efforts going through 'install/ uninstall programs' on the Control panel, I am getting "The INSTALLATION cannot CONTINUE because components (c:\program-1\mcafee.com\agent\uninst\screm.ini) are missing". Could someone please talk me through the process please? :-?Do you have a CD with the McAffee program on it?
Try reinstalling it from CD, then uninstalling it again.
Alternatively, try using CCleaner's uninstaller to remove the program - see here for instructions.
Hope this helps.Thank you Calum, I have done that and McAfee is banished from my system! I actually had ccleaner downloaded as I have used it on my last comuter with great success. Your instructions did the trick.Cool, glad you got it sorted.
Mcaffee PRODUCTS can be TRICKY to remove, but not as bad as Norton/Symantec.There is a McAfee uninstaller you can download from McAfee but I don't have the link. Here is another one.

1405.

Solve : Runtime error 3027?

Answer»

Hi guys,

I need help figuring out how to fix this error messege that I'm getting on my pc.

Runtime error 3027 can anybody help me with this fix!! thank you ..

It might have helped if you had told us when this error happened, what program you were running, what you were trying to do, that sort of thing, you know? But no, we have to be mind readers! So, now you have to read my mind! It's thinking about a search engine. Its name begins with G.

Hint:

Quote

Because of legal issues, Microsoft has disabled the functionality in Access 2003 and in Access 2002 that let users change the data in linked tables that point to a range in an Excel workbook.




I'm sorry contrex ..you're right..

I'm using Access 2000 as my database..and every time I try to open a file in access
I get this messege, it won't let me do any changes. Is this help?? OK you did your penance

This is expected behaviour (it is meant to happen, it is not a fault). The reason it happens is: because of legal issues, Microsoft has disabled the functionality in Access that let users change the data in linked tables that point to a range in an Excel workbook. However, when you make changes directly in the Excel workbook, the changes appear in the linked table in Access.

Quote
WORKAROUND

To work around this expected behavior, use one of the following methods.

Method 1: Use Microsoft Excel
Open the linked Excel workbook in Microsoft Excel, and then make your changes to the workbook. When you have completed the changes, save the changes and then close the workbook.

Method 2: Use OFFICE Access 2007, Access 2003, or Access 2002
Import the linked Excel workbook into Access, and then make your changes to the data. When you have completed the changes, export the data as an Excel .xls file.

Link to Microsoft explanation and full workaround (Took me 10 seconds to find, by typing "Runtime error 3027" into Google!)

http://support.microsoft.com/kb/904953


Thanks for the help contrex Promise to use Google more in the future!
Hello!
I am getting the same error, but my SCENARIO is different.

I am running Access 2003. I have a VB line that is exporting the CONTENTS of a table into a text file. There is no writing/changing of excel files. Any suggestions??

DoCmd.TransferText acExportFixed, "CMS Generic Portfolio Import File Format", "CMSExportTable", "G:\SPBlend.prn", False

Thanks for any help!



Possibly something here will cast some light

http://support.microsoft.com/kb/161252


1406.

Solve : Installer / autorun file anyone??

Answer»

I create databases for different THINGS I sell them on a CD format. I am looking for a good installer that I can use to install the database and support files. Also some incite on how to create an autorun file would be much appreciated. I have played around with I but I got gravy and mash potatoes but no turkey. (A little late, I know) :-? :-? :-? :-?Hello,

For the autorun here is an example:

[autorun]
open=Setup.exe
icon=youricon.ico

and then SAVE it as autorun.inf

For the installer look on freewarefiles.com


HOPE this helps

Al968You haven't said what you've made your PROGRAM with? Are we supposed to guess?

1407.

Solve : New TO Programming?

Answer»

Hi, I'm knew to programming and I want to learn and understand more.
I have Beginning programming for Dummies.

is that ok or do you think there's a better book out there!

thanks again
spider

yes..that will be ok. Most important thing is, don't give up half waytry the easy visual basic programming.
Quote from: kuszmania9999 on September 16, 2007, 10:25:05 PM

try the easy visual basic programming.

vb can be easy but IMO a beginner to programming should not be exposed to GUI based languages so soon. Thanks guys

spiderA GREAT book for people who are completely new to programming is "Objects First with Java" - ISBN 0-13-197-629X.
It introduces you to object oriented programming in general and Java in PARTICULAR. It comes with a programming environment designed for teaching called BlueJ. In my opinion it's an incredibly easy way to get start with object oriented programming. And once you know Java you pretty MUCH know C# as well so that's two languages in one. deerpark, thanks I will pick that up too.
I have Visual Basic 6 and beginning programming for Dummies!

thanks again guys
spiderGlad I could help.
Though I would recommend you choose either VB or Java to focus on at first else it might get quite confusing.
When you first know one language pretty well, learning a second language isn't hard since most languages have some similarities. hi,

since it is your first time, as you have well mentioned, i would personally suggest, you take programming by the heart, what do i mean here is, take into the foundation, the logic programming, i admit there are hundreds of programming language available around each one of its own DESIGN, power and capabilities but none of them goes without the logic. hope you get what i mean, a fair start would always be good to hit it soft then gradually moving on. i suggest C or C++.

GUI world is a lot easier but you tend to lose the gist. but if you need thunder apps to be developed in lightning then use them.

but suggestion of people are real cool and good to take into your consideration.

good luck.
1408.

Solve : Just started learning VB and need help please?

Answer»

Hi guys I wonder if you can help me I have just started to learn VB6 and am playing around with a small program I have just created a splash screen etc,and now want to create my next page. I have created a new form and have put six buttons on it that relate to six questions about scooby doo. What I would like help with is

how do I make the program move from one form to another using the next command on the form

how do I make the buttons link to the questions i.e SHOW when the right q has been selected etc

And finally I have tried to find code already written that I can cut and paste but when I cut and paste the progs won't run. Can you please tell me where on the code page the code has to be pasted.

I know this may seem basic to some but we all have to start somewhere
many thanks
Quote

how do I make the program move from one form to another using the next command on the form

If you are asking how to get from one form to another, here's how:

Assuming you've created the second form, use code similar to this for button_click (or whatever you call the BUTTON in question).

Code: [Select]Dim SecondForm As Form2
SecondForm.Show
Of course, that can be used with If/Then statements, and the like. You can change the SecondForm to whatever you want, like most variables, but the Form2 bit must be the name of the form you are trying to access.

If you want to close the first form as the second opens, you might use something like this:

Code: [Select]Dim FirstForm As Form1
Dim SecondForm As Form2

SecondForm.Show
FirstForm.hide
Do not use FirstForm.Close. I've found that ANY form used with .Close will exit the program.

Quote
how do I make the buttons link to the questions i.e show when the right q has been selected etc

If I read this correctly, you could have the correct answer go to a Form that says, "You're right" or something like that. The others can link to a form that tells you you messed up.

Quote
And finally I have tried to find code already written that I can cut and paste but when I cut and paste the progs won't run. Can you please tell me where on the code page the code has to be pasted.

That depends. If you want it to be code for when, say, ButtonC is clicked, you'd put it under the Sub called ButtonC_Click. If it is to be run when the form loads, it would go under Form1_load, if I recall correctly. (I can't open Visual Studio right now (stupid IE 7) so I can't look it up.)

Hope it helps!My Form works without typing Dim Form2 As Form2
Because is already save in a slot the form has

Anyway i was trying to ague i am just saying this work for me

scania11 check this toturial http://www.vbwm.com/learnvb/tutorials.aspGuys Thank you very much I will take onboard your advice.

again thaks Quote
My Form works without typing Dim Form2 As Form2
Because is already save in a slot the form has

Okay, the Form does work without the "Dim"s. I was under the impression she wanted to open that second form with the first form. Am I correct, scania11?

ALSO, I don't understand "Because is already save in a slot the form has". Can you please clarify?
To dilbert this is how i will do it.
Coding a simple question with no DIM statement
Coding with simple code
T-Chai way
The easier way (mayby)
This how i will do the code for 2 simple question
Let say we are going to code 2 simple question about this forum
There will be 3 form:
form1 - Question 1 Who is pavane
form2 - Question 2 How crazy is pavane
form3 - Answer

form1 Next button = Private Sub Next1_Click()
form2 Next button = Private Sub Next2_Click()
form2 Back button = Private Sub back_Click()
form3 Show the answer button = Private Sub back_Click()
form3 Quit button = Private Sub End_Click()

As you see i havent name the option because i cant be *censored*
You can do as many question as you want
My spelling is crap

Tha's great T-Chai. What is the program called? Mac/Pavane is a Loon?Very well done, if it works, do it. My way was one way and I use Visual Basic .NET, maybe there's a difference. If not, then well... is my method not do-able as well? I made a Millionaire game and used similar code. (Only, I used images that linked. It looked a lot like the actual game. But that got lost due to a virus on my previous machine...)

Code: [Select]Private Sub Button1_Click(ByVal SENDER As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim question1 As Form1
Dim question2 As Form2
Dim answer As Form3
Dim wronganswer As Form4

If RadioA.Checked = True Then
answer.Show()
question1.Hide()
Else If RadioB.Checked = True Then
wronganswer.Show()
question1.Hide()
Else If RadioC.Checked = True Then
wronganswer.Show()
question1.Hide()
End If
End Sub
That would be for the first form, when "next" is clicked. I'm leaving out the other forms because that can be anything you want. But this would work, no?

EDIT: Oh wait, that's almost identical. Oh well...Guys many thanks for going to all that trouble I will try it later

T-CHAI your spelling is fine with me my friend again many thanks for your time.

Scania GX man - Visual Basic 6.0

Dilbert - i naver use VB net so i dont know wheather is a different codeing stye or not but the language should be the same for all VB and Flash coding it has nearly the same laguage as VB as well
But hey you code it way shorter than mine Well, I didn't include the other forms. Actually, my Form1 length is about the same as your Form1 by itself. My Form2 would be about the same, and 3 and 4 would be short (having Continue and Start Over, respectively.) I guess my version would be a little simpler, as it uses simple code, but I don't think you need dynamite to clean up paper. I still say your code works, we just have different methods. Sorry if I'm replying to an old topic.

Why do you need six different Forms to make a simple quiz. They can all be done on one Form. You just need your questions and answers in an array and just keep moving through them.

Here is a quiz I made many years ago and it uses Microsoft Agents to bring a bit of life to it. Yeah... I never did get proficient with VB.
1409.

Solve : Print Web Browser in VB6 to Printer?

Answer»

Hi,

I am having a very dificult time getting it right to PRINT a webbrowser form to printer.

On Error Resume Next
If ActiveForm Is Nothing Then Exit Sub


With dlgCommonDialog
.DialogTitle = "Print"
.CancelError = TRUE
.Flags = cdlPDReturnDC + cdlPDNoPageNums
If ActiveForm.rtfText.SelLength = 0 Then
.Flags = .Flags + cdlPDAllPages
Else
.Flags = .Flags + cdlPDSelection
End If
.ShowPrinter
If Err <> MSComDlg.cdlCancel Then
ActiveForm.rtfText.SelPrint .hDC
End If

End With

The above code can print my rtf docs, but I am really having a bad DAY trying to print the web page in my browser I have in VB. Can anyone please help me with this.

Regards
ChristoI KNOW this is an old topic but no one as given an answer.

What I do when I want to print a webbrowser is just right-click on the browser and select Print.

1410.

Solve : Dos Batch file help?

Answer»

I need to create a batch file that will open a command line and run the command "IPCONFIG /displaydns"
I made one to run "ipconfig /flushdns" and that works FINE and the dos window CLOSES after it completes the flush. However with the displaydns I need the dos window to STAY open. Any help is appreciated.
I'm just using the batch format to run a dos command.

Kumlause PAUSE in your script.

Like this
Code: [Select]ipconfig /displaydns
pause

1411.

Solve : MSDN Library?

Answer»

I have vb 6 but not the msdn library, every time i CLICK help on something in vb 6, it says that the MSDN library is not there, please reinstall. Is there a link to download it, and if there is, can someone please tell me where to put it so when i click help or something, the msdn library will pop up and look up what i am LOOKING for? thank you if you can. if you cannot, can someone tell me what format its in, other than the HTML format on the Microsoft.com website, and if i can put it on a 3 1/2 floppy disk or something and refer to it anytime? thanks.No you can't download the MSDN Library. If I were you I would search ebay. And no it won't fit on a few floppies its 2 CD Roms.

Mind you If you don't have the MSDN then your running a pirate version of VB6. uh oh now you're in trouble.There are a wealth of books that can help you make routines, but you are going to have to teach yourself you Pirate! LOL I have several Word books if you really need help. Send me a message!

Ted

1412.

Solve : Works in "Dev-C++, but not in "Microsoft Visual C++ 6.0"????

Answer»

The following code works in "Dev-C++, but not in "Microsoft Visual C++ 6.0"

Code: [Select]#include <iostream>
using namespace std;

int main()
{
cout << "\n";
cout << "\t";
cout << "Hello World\n";
cout << "\n";
cout << "\n";
system("pause")

return 0;
}

Anyone know why it won't work in "Microsoft Visual C++"?Not quite sure why it works in one but not the other, considering there's a semi-colon missing. Try this instead: Code: [Select]#include <iostream>
using namespace std;

int main()
{
cout << "\n";
cout << "\t";
cout << "Hello World\n";
cout << "\n";
cout << "\n";
system("pause");

return 0;
}
Quick edit: I compiled it myself to make sure it works, and it does. Although I am using Visual Studio 2005. See if it works, and if not, try it without system("pause").Your code, before the fix, should not compile in either program. I find it odd that it did.Sorry, The missing semi-colon was missed when I was typing it into the FORUM.
The correct code (with the semi-colon) works in "Dev" but not "Visual C++".

Sorry about that mistake.

and Alan when I TAKE the system("pause") out the command prompt windows just comes up and automatically closes, so you don't get a chance to read what it prints out.Would "Dev" have different libraries than what "MS Visual C++" has?I've just compiled and run the above code and it works. I'm downloading Visual C++ 2005 Express Edition to see if that works. This will take about 10 minutes or so.

EDIT: The iostream.h file should be the same on VC++ and Dev-C++.

EDIT 2: In order to compile a Console program like this, Create a Blank Project (Under General in my VC++). Then make the .cpp file and add it to your project. After doing that, I was able to compile your program. (But what a pain it was.)

I'll add SCREENSHOTS in a moment.My program doubtlessly looks different, but you'll get the main idea:







From there, BUILD normally. (Though personally, I just prefer Dev-C++. It's cleaner and easier. )Thanks so much for your help. Although, It still doesn't work in "MS Visual C++".
Lol I'm new to C++ and I just heard that "Dev" had it's libraries out of date or something, So I installed "MS Visual C++". But as I've realized already and with your comment:

Quote

(Though personally, I just prefer Dev-C++. It's cleaner and easier. Smiley)


I'm just going to stay with "Dev". Plus it's open source - Yay!
1413.

Solve : Split: Operator overload -- Factorials (C++)?

Answer»

Hi, I'm KNEW to programming and I want to LEARN and understand more.
I have Beginning programming for Dummies.

is that ok or do you think there's a better BOOK out there!


thanks again
spider

@spiderlucci

hi, try posting this as new thread, you just can't post it here because its would be irrelevant, you won't get any significance. ANYWAY, no flames just directions. thanks Message split into a new thread. Where is it?This is the new thread.

1414.

Solve : Vb.net Process Path?

Answer»

Hello,

I am TRYING to wirte a program that lists in a listbox all the running program along with their path on the hard drive.
So far I have the following but it returns an error and deosn't show all of them:

Code: [SELECT] Dim PSSS As Process()

Dim P As Process
Psss = System.Diagnostics.Process.GetProcesses


For Each P In Psss
lst.Items.Add(P.MainModule.FileName.ToString)


Next

The name of my listbox is lst

Any Help appreciated

Thanks

Al968
Anyone

Al968What is the error returned?


Just hang tight, ghostdog is really good with stuff like this, so once he arrives you'll be fine."Just hang tight, ghostdog is really good with .vbs, so once he arrives you'll be fine."
This isn't vbs

I get this message :

Code: [Select]System.ComponentModel.Win32Exception: Access Denied
at System.Diagnostics.ProcessManager.OpenProcess(Int32 processId, Int32 access, Boolean throwIfExited)
at System.Diagnostics.NtProcessManager.GetModuleInfos(Int32 processId)
at System.Diagnostics.Process.get_Modules()
at System.Diagnostics.Process.get_MainModule()
at ProcessKiller.Form1.Button2_Click(Object sender, EventArgs e) in C:\A1\Products\ProcessKiller\Form1.vb:line 95
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
Thanks for the info

Al968are you going to kill some PROCESSES? the error you supplied is quite intuitive. Its to do with permissions...make sure the user running the program have the permission to do more privileged tasks other than read (eg kill a process ). If the process is started by say, SYSTEM, a normal user will not be able to kill it...Quote from: Dark Blade on September 09, 2007, 12:45:09 AM

Just hang tight, ghostdog is really good with stuff like this, so once he arrives you'll be fine.
nope.my knowledge is till vb6 too lazy to learn new stuffs Sorry for the late responce

No I just want to list all the running processes

Al968Any one ?

Thanks

Al968Quote from: Clippy on October 09, 2007, 12:50:09 PM
Anyone? LOL




Up and up goes the THREAD count...

1415.

Solve : i want a short program or software for my mobile shop?

Answer»

...

I don't think you need to make a computer program for SOMETHING like this.

I suggest using a program like Microsoft Access, or Open Office Base. (Download OpenOffice: http://download.openoffice.org/2.3.0/index.html )
You can create a form to ENTER INFORMATION into. This is probably a better solution.

Most Office type programs, you can PRESS CTRL+F and type in what you are searching for.

1416.

Solve : Fun C++ Problem?

Answer»

Hey everyone,

I've used this site as a resource for such a long time, but never GOT into the forum... until now. I thought a good way to get my feet wet would be to post a fun C++ problem I have enjoyed before. Hopefully it is a new problem to some of you!

Give it your best! (and don't post answers when you get them... let everyone have a fair chance)


Code: [Select]#include<iostream>

using namespace std;

int main() {
int i, n = 20;
for (i=0; i<n; i--) {
cout << "x" << endl;
}
}

/*
Directions:
===========
Find three ways to make the above code print x 20 times
(by changing only one character)
*/

Click http://www.blarged.com/blog/CPP_Problem.cpp to download the source file straight to your box.

Best of luck! Hopefully you do better than I did!A tip to all: The current code is an infinite LOOP. I'm on it, because I can't resist.

EDIT: Question: Does the "--" COUNT as one character? It's certainly only one operator... Quote from: Dilbert on July 10, 2007, 04:49:11 PM

A tip to all: The current code is an infinite loop. I'm on it, because I can't resist.

EDIT: Question: Does the "--" count as one character? It's certainly only one operator...

no, the '--' counts as two SEPARATE characters. each KEYSTROKE is one character :-)

its tough!Nobody's playing? Well, I've found two. And I'd really like to know the one I'm missing.
Has anyone found the three solutions?Odd. It won't compile for me anymore.

Permission denied
ld returned 1 exit status

is all I'm getting for an error message, though. Doesn't help me find out what's wrong. Ok, found the third as soon as I woke up. Who said sleeping was a waste of time ? lol

Dilbert, everything compiled for me. Sorry I can't help (real noob at programming).
1417.

Solve : Running Dos Commands from VB.net?

Answer»

hey all,

I need to run loads of dos commands from within vb.net and display each line as it's run to a listbox.

I would also like a progress bar as well, and since i know the AMOUNT of dos commands it needs to run that shouldn't be so hard. (but I'll get to that later)

I'm very new to vb.net and I'd like to write it my self (a nice little project:p)

If SOMEONE could POINT me in the direction of loading a dos prompt and running the "net use \\ipaddress /user:username password" command which wait UNTILL it has finished to display the output to my listbox that would be very helpful.

cheers guys!
you are mapping network drives? VB.Net is a programming language, i am sure there are classes provided that does network drive mapping. A random search on google i found this . Calling a dos command like the way you described should be the last thing on your mind.Really!

VB can do that easy as DOS. PERHAPS easier!

1418.

Solve : Compile C++ without programs - Is it possible???

Answer»

Hi Everyone,

I have finally got time to do some programming.
I was reading an article on how to build an OS.

On the 1st page it said you'll need

Quote

Programming experience, preferably C or C++ - Since systems programming is harder than conventional programming, it's assumed that if you want to write an operating system, you have at least some programming experience. Hopefully, you know either C or C++ fairly WELL. You should know pointers, structs and the basic data types, control loops, and the preprocessor well, but don't worry about the standard libraries, ANSI or otherwise, since those are essentially irrelevent in systems programming (you'll most likely have to write these yourself in the later stages).

Does that mean, if I did not use C++ to write my OS, all would be IMPOSSIBLE?

I have VB 2008 Express, with the .NET Framework 3.5 BETA, but I don't want to download, uninstall, install again, just to find out that half my knowledge of VB programming would be useless.

So how do I compile a C++ program without software?

Running Windows XP Home Edition SP2.

Until I find something, listening to anyone's ideas.
Thank you.First, to compile source code you need a COMPILER. Period. (You also need a linker and some other things, but maybe we're getting a bit advanced now)

It says "preferably" C or C++. You can write a kind of toy OS using other programming languages, even QBasic. You could hardly write an OS in Visual Basic, since it needs Windows to work.

It also says, "systems programming is harder than conventional programming". That's a very great understatement. The bottom LINE is that if you are not a fairly complete master of C type languages you probably don't know enough to write an OS. You would also realistically need to be very advanced (that is, a wizard) at assembly language.

"Programming languages" like VB, Delphi, etc, are designed to protect the programmer from the nasty scary realities of the OS. You get forms, classes, buttons, error trapping, etc, all ready made, and all you have to do is write a few lines to join it all together. Systems programming is not like writing "hello world / What is your name? Hello Biff" type programs in VB.

The Linux OS is open source which means that you can study the source code. Doing that will give you a very good idea if you (a) have a feel for that kind of coding (not everybody does!) and (b) if your programming understanding is at a high enough level.

The bottom, bottom, bottom line is that BUDDING OS writers don't generally write "how can i write an OS" type posts on beginner-level forums. But don't let me put you off. Read up on OS design, CPU operation, file systems, memory management, get stuck into Linux, and have a go!
1419.

Solve : Windows Applications?

Answer»

I would like to study a programming language on how to create windows applications like a simple game.
Which language should I learn first. By the way I've never learned any languages like VB or C before. I've only learned web languages.
Thanks.There are a lot of ways to make a tiny GAMES or programs
you can use programming languages or programs.
programming languages you can use :
FLASH:for graphics games, and its language(THE ACTION SCRIPT) is very very easy to learn.
when you use this program you will REALY enjoy.
visual basic: an easy programming language and if you are a beginner
programs you can use:
game maker :it is a very famous prog and i advice you to use it.
but before all of that i think that you should start with pascal or visual basic
because i started with these programming languages and now my EXPERIENCE is Good "as I think"

regards



1420.

Solve : Need help identifying program language & with modifying/editing a game?

Answer»

Hello,

I still play an old now abandonware football management game called 'championship manager 93/94' that I would love to be able to edit some of the data to, in order to bring it up to date.

It would only be modifying existing player/team names, so I'm sure it can't be that difficult?

The game is now abandonware, written in 1993 & so I don't think it would be illegal & I have no intention to profit from it in anyway & as the game is old it might be easier to 'hack'.

Here's a download link for the game:

http://hometown.aol.co.uk/champmanager/downloads/cm93.zip

If ANYONE can OFFER any help or advice I would be very greatful.

GlennThe names are located in the Clrecs file. You can try opening it up in notepad and editing it that way, if that doesn't work just use a hex editor.

- JPHHey JPH,

I downloaded a hex editor & was able to see some of the names of players under clrecs, so I altered a couple to see if it would work but it made no difference.

Strange.Did you make sure that you REPLACED all instances of the NAME you changed? Also did you keep the d in front of the name, I think it's NECESSARY (i.e. dLiverpool). Also, if you replace a long name with a short name you might have to pad it with nulls (00) or spaces (20)

Example:

dD.Holdsworth = 64 44 2E 48 6F 6C 64 73 77 6F 72 74 68

replace with

dGlenn = 64 47 6C 65 6E 6E 00 00 00 00 00 00 00

or 64 47 6C 65 6E 6E 20 20 20 20 20 20 20

In other words, try to occupy the same amount of space the original name took up.Try hexing the Cmexe.exe instead, I found names in there too.

1421.

Solve : I want to get into the Video Game Development industry, please help.?

Answer»

Hello, I am hoping to get into the Video GAME Development professional when I get older, and I would want to know if there are any "Top" C++ Compilers, 3D Design Tools, or anything ELSE I would/might need. THANK you in advance.

P.S.
If this isn't the section that I should post this in, please provide me with a link. Thanks again.I know of some very good 3D Graphic Design programs. i'm not sure about the C++ COMPILER area, but here is an address to some good 3d design programs. I think 3ds Max is the best program overall. http://en.wikipedia.org/wiki/3D_computer_graphics_softwareThank you very much.

1422.

Solve : Batch file to copy from ftp site?

Answer»

hello, I have been working on a batch file with no SUCCESS, i was WONDERING if you guys could help me out. I am trying to COPY files from a ftp to a local drive. There are going to be about 1500 files on this ftp site so when it copies the file i want it to only download the new files and skip over the older files.

I have searched the internet high and low for examples but i haven't found any. I have seen programs that do this for me but I do not want to purchase it.

could someone please help me out?I SEE people viewing this topic, but no one is helping. Can someone please help me out?Quote from: burchill on October 11, 2007, 02:19:40 PM

...

I have searched the internet high and low for examples but i haven't found any. I have seen programs that do this for me but I do not want to purchase it.

Name them. Provide links, if possible.
Maybe that will remind somebody else of something that you somehow did not find.

Quote
could someone please help me out?

I'm one of those that has read your thread a couple times now. I'm just curious to see what the answer is myself. That could explain why others are reading it too.

If you discover how to accomplish your goal elsewhere, please do POST the solution here for all to read.

Quote from: burchill on October 11, 2007, 02:19:40 PM
hello, I have been working on a batch file with no success, i was wondering if you guys could help me out. I am trying to copy files from a ftp to a local drive. There are going to be about 1500 files on this ftp site so when it copies the file i want it to only download the new files and skip over the older files.

I have searched the internet high and low for examples but i haven't found any. I have seen programs that do this for me but I do not want to purchase it.

could someone please help me out?
Do you have a list of "old" files on your local machine?
windows(DOS) FTP client has no commands to help you determine which file is old or new. anyway, here's a thought
1) log into FTP server
2) get a directory listing of all files in FTP server, then output to a file A.txt
3) depending on what methods you defined for calculating newer files, you can compare timestamps . ie perform date comparisons on your local machine against A.txt
4) From step 3), get the results of those newer files?
5) create FTP script on the fly, for each newer files found in 4)
6) execute FTP script for each newer files found

I
1423.

Solve : C++ beginner help please!?

Answer»

Hi

I'm new to programming & would really appreciate some help with modifying an existing C++ program.

I'm using XVI32 hex editor & I'm looking at the following:



I'm presuming that the names at the bottom (Aston Villa Man Utd etc) have all been assigned to one of the variables (if that's the terminology) above, for example a$=Aston Villa b$=Man Utd etc.

So how do I find which is represented by which? there are exactly 80 names so I'm guessing there's 80 variables, but I don't know where to begin. Once I find which is ASSOCIATED with what, I then have to find those representations in another part of the program... is there an easier way to do this?

Thanks guys...What you really want to do is "Reverse Engineer" the binary file and that's a job for someone with a high level of knowledge and experience. Below is an extract from this site.

"Software reverse engineering is done to retrieve the source code of a program because the source code was lost, to study how the program performs certain operations, to improve the performance of a program, to fix a bug (correct an error in the program when the source code is not available), to identify malicious content in a program such as a virus or to adapt a program written for use with one microprocessor for use with another. Reverse engineering for the purpose of copying or duplicating programs may constitute a copyright violation. In some cases, the licensed use of software specifically prohibits reverse engineering.

Someone doing reverse engineering on software may use several tools to disassemble a program. One tool is a hexadecimal dumper, which prints or displays the binary numbers of a program in hexadecimal format (which is easier to read than a binary format). By knowing the bit patterns that represent the processor instructions as well as the instruction lengths, the reverse engineer can identify certain portions of a program to see how they work. Another common tool is the DISASSEMBLER. The disassembler reads the binary code and then displays each executable instruction in text form. A disassembler cannot tell the difference between an executable instruction and the data used by the program so a debugger is used, which allows the disassembler to avoid disassembling the data portions of a program. These tools MIGHT be used by a cracker to modify code and gain entry to a computer system or cause other harm."

Here is a forum discussion of CM93, DiscoG has posted a link to an "Editor". Hope this is of some use to you.

My best advice is to use the Hex Editor to modify the binary then find out what the results are.

Good luckHey thanks for your reply Dusty, it's been lonely here...

Bit strange how you knew it was CM93

I have tried the editor but it unfortunately only allows me to change a few things (player ability/age)

Let me just run what I'm guessing here... see if it would make sense to you. I'm thinking there's a variable for a team then each player for that team with several items of information for that player.

For example:

Team name=$$
number of players=$$
player name 1=$$
player 1 age=$$
player 1 nationality=$$
player 1 Ability=$$

I can change names no problem, but I'm changing the target, so if I change John Barnes to Steven Gerrard then John Smith will also change to Steven Smith & Paul Barnes will become Paul Gerrard (sorry to be over explaining stuff that nobody has any interest in reading).

I think I need to find exactly in the program where a) the data for the team is b) the targets for the team data 3) targets for player data.

But I'm getting way ahead of myself... maybe you could be so kind to help me out with some very basic stuff first?

So binary.... is that the squigally *censored*? I'm guessing the squigals are representations of lines of code? like if I write: Let a$=b$-c$, that would be end up as ~o viewed in a hex editor?

So does a dissembler let me 'open up' the squigally *censored* to see the code?

Thanks...Well, hmmmmm, let me try.

The 'squiggly' things are the XVI32 program's interpretation of the binary code. As you will know everything is stored as a binary representation and the character printed is selected from the ASCII character codes. e.g. if you go to the very first character displayed at location 0 you will find an upper-case M. This is stored as binary 01001101 which translates to hexadecimal 4D which in turn is decimal 77. The ASCII Regular and Extended codes can be seen here. If a character cannot be determined then the hex editor prints a symbol, in the case of XVI32 it is a square box.

A fun binary converter can be seen here.

Quote

I can change names no problem, but I'm changing the target, so if I change John Barnes to Steven Gerrard then John Smith will also change to Steven Smith & Paul Barnes will become Paul Gerrard (sorry to be over explaining stuff that nobody has any interest in reading).

I understand your problem. I searched the binary and found that the name John appears at location 52D85 (and at least a further three locations). This is the sixth christian name in the display. Starting at location 54E00 is the surname Deeham. This is the sixth surname in the display. Is it possible that the two are linked and if you change the John at 52D85 to Fred the name will be changed to Fred Deeham? In other words is the sixth christian name linked to the sixth surname? You must manually edit individual names, the Replace option cannot be used or all occurrences will be changed.

Quote
So binary.... is that the squigally sh*t? I'm guessing the squigals are representations of lines of code? like if I write: Let a$=b$-c$, that would be end up as ~o viewed in a hex editor?

So does a dissembler let me 'open up' the squigally sh*t to see the code?

Yes and No. The source code, which is what you really want, has been compiled into machine language. Here is a description of what a disassembler can achieve. I know of no disassembler which will return machine language to its original programming language. Then, of course, theres a decompiler.. If this was easy then every program EVER written and compiled could be reverse engineered and modified to suit every user. We'd all be doing it.

Read this from my EARLIER post again
Quote
Another common tool is the disassembler. The disassembler reads the binary code and then displays each executable instruction in text form. A disassembler cannot tell the difference between an executable instruction and the data used by the program so a debugger is used, which allows the disassembler to avoid disassembling the data portions of a program.

and
Quote
By knowing the bit patterns that represent the processor instructions as well as the instruction lengths, the reverse engineer can identify certain portions of a program to see how they work.

There are many free disassemblers/decompilers on the WWW.

Good luck

1424.

Solve : stack....?

Answer»

hello,
can u please tell me:
How is it possible to INSERT different type of data elements in stack? That WOULD DEPEND on what PROGRAMMING language you're using.

1425.

Solve : fortran programm?

Answer» DEAR to start fotran related progrmming and its benefiteWelcome to the CH forums.

Please REPHRASE your question.
1426.

Solve : How to make a script to change boot order.?

Answer»

This is something I would like to do, but have no idea if it is even possible.

My current machine is a Dell 755 and I can program the BIOS to start the machine automatically at 2 AM every weekday morning. This saves me the needs of getting up early and starting up the machine to get the updates. Getting updates during the day daytime hours can be time-consuming and in some cases not even possible because of heavy Internet TRAFFIC. So, my idea is to let the computer do it by starting up the machine automatically at two o'clock in the morning and get updates.

So far so good. But here's the big problem. Presently I have this machine in a triple boot configuration with Windows XP, Windows 7, and Windows 10 and automatic updates are turned on.

But here's the problem. I need to remember to SET the boot default option to change to a different operating system for different days of the week. I could have Windows XP to the update on Wednesday, followed by Windows 7 on Thursday and then Windows 10 early Friday morning. But the trick is to have a script that will change the boot order for those three days.

So my question is, is there some way to write a script in some kind of scripting language that would change the defajult boot OS for those three days?
Any suggestions would be welcome . Thank you . Quote

is there some way to write a script in some kind of scripting language that would change the defajult boot OS for those three days?
No.

I mean, if you can get direct hardware access, find the location of the CMOS RAM, figure out the data format which is typically entirely undocumented, and change the appropriate bytes to adjust the boot order and then update the checksum with the correct algorithm, then maybe.

And if it's stored in the ESCD, as it is in some systems, you have to deal with not only knowing the format but now being able to flash the entire block, the mechanisms for which differ from one system to another.Tnaks BC.
The boot loader I am using is not in the BIOS, but it is the loader Windows 10 installs when It finds yhour halready have a windows instalation. Not wure how it works. Somehow it makes windows 10 "flip" and allow another system, Windows 7 or Windowsd XP, finish the boot process. I have no idea if it is an utility taht has options inside of Windows. But I am sure it is not a BIOS thing. I only have one drive in the system, and tmy Dell 755 BIOS is before UEFI came. So it is some kind of software that is on the hard drive boot area.

In that CASE, bcdedit /default in an administrator command prompt under Win10 sets the default. It might work with Win7 but you won't be able to change it from Windows XP to go "back".

You can use bcdedit /bootsequence to do it one time.

bcdedit /? has more info.OK. I took a look at the BCDedit options.
It looks like thaey afre the same in Windows 7 and Windoqws 10. But, there is a problem. I get 'acesse denied' when I tyr to see the store on the command line. So this might be a dead end.

However, in WImdows 10 one can do a o9ne time switch to another OS and then after that other OS shuts down it will recvert back to windo9ws 10. That might be a posibility.

BTW, I need to ask this: If the PC boots up and waits for the user to logon, can takse run in the backgroun? If not, how do you get WIN 10 s to automatically boot up and run something withoyut a user log in?
Quote
I get 'acesse denied' when I tyr to see the store on the command line.
Were you running in an Elevated command prompt?You can use Task Scheduler to schedule a task to run at startup, and setting it to Run whether there is a user logged in or not allows it to run at the login screen. It can be configured to run under a specific user account as well. Thjey cannot present a UI, obviously.Thanks, BC. Thatwil;l keep me busy for a month or so.
I am going to play with the task scedk in Windows 10 and see what i can do for me.
I might consider just letting my PC go into a sleep mode instead of do the full SHUTOFF thiing. Soewhere I read taht the power used in sleep mode is vert little.Update. What I want to do has to be done with the Windows 10 boot loader.
Other sorces indicate that you can not swap the boot loaders.** So I have to use BCDedit inside of WIndows 10, I can not use in in Windows 7, as far as I can tell.

What I want to do is to switch from OS to another without human interaction, My goal is to have both Windows 7 and Windows 10 get their respective updautes in the wee early hours of Wednedy morning,. Or maybe Thursday.

I can get Windows 10 to change the default boot entry and then reboot into Windows 7. But I can not get Windows 7 to reset the boot thing to go back to WIndows 10. So taht is as far as I can go with this. I have to reset it to Windoqws 10 manually the nect day.

I am going to stop here, a partial solution will be used.

** GRUB is an exception, but I don't want to go that far!
https://www.youtube.com/watch?v=EgzLKOF4blY

Ignore my post above.
BCDedit works inside of both Windows 10 and Windows 7.
Anyway, uou can use BCSesuit inside Windowss 10 at an elevated pronpt and use bootsequence to do a one-time reboot into Windows 7. Inside Windows 7 you could either use BCdedit or jsut shutdown the system. The later works fine. Windows 10 with return as the default entry.
The trick is to understand the sybtax of the bootswquence command. The documentation is there, it is not very easy to understand for us average people.
1427.

Solve : Curly Brace Pairing Identity?

Answer»

Working on a large program last night and it compiled and I ran it and it hit an infinite loop at one part so I had to kill it. The problem was difficult to TRACK down opening and closing curly braces since there are so many nested loops etc and no notation as to which are paired for opening and closing. I tried scrolling up and down my code and it was giving me a headache trying to keep track of which opening braces were paired with what closing braces with many while loops and conditional statements that required the use of them.

I ended up having to print out the 22 pages of code and then with a pencil write to the right of opening { and closing } a number like 001 and 002 and so on..... and at 017 I then found the extra closing } curly brace that didnt belong and was the result of me copying and pasting sections of code to not have to retype code for similar but isolated functions that cant reuse the same object and needed to have immunity between each other.

I suppose you could add comment notation to each brace giving it an identity such as { // 001 and { // 002 and in the code when coding and fresh on my mind add the closing brace with } // 002 and } // 001 to keep track of them that way with say a while loop with identity 002 nested within while loop 001.

But was wondering if there are any tools or viewers out there that might identify without having to type notation with comments in programming as to which opening and closing curly braces are paired, so that one that is closing too early would stand out when reading my code as to incorrect placement. Such as if I saw the closing curly brace } // 001 mid program it would have stood out right away as the problem because it needed to be moved to the tail end of the program. As for the code will compile because there are the correct number of opening and closing braces, but placement of the closing brace needed to be removed and added at about the 5th to last line of code in the program to operate correctly.

I tried out notepad++ and searched around and couldnt find anything that showed curly brace pairing.... so maybe I just need to add the comment notation to pair the opening and closing curly braces... but figured i'd check here vs assuming since others must have run into the same headache of tracking down misplaced opening or closing braces in code, and maybe someone made a viewer that color codes and shows identity since it seems as though it wouldnt be too hard to parse through code from a code STANDPOINT that will show which { and } are paired to then make it easy for someone to say mouse over the curly braces and see the identity given to them to know which ones are paired with current structure which is sound for compiling with no code issues other than misplacement which leads to the program executing incorrectly to intent.Here is a not-quick answer.

Break you code into seperate blocks at the source code. Each curly pair is a block. Each block is a different sourc e code file. Each clock of code should made logical sense by itself.You want a modular design where you can edit any module without need to re-write other parts of the whoule project.

Avoid so-called inline code. Don't worry about spped, that can be fixed later. First get the logic, then emply the tools taht improve speed. If somecode gets to be rather large, make it into a thing that is extrernal to what you see.Use whatever tools yur have to hide code from view. One old school method is to just make anything large a seperate funtion or procedure, even i9t is only used just once.

Some onld0shoolc programers had a rule taht any code fragment had to fit on the screen. If not, it must bebroken up into smaller blocks of code. This is for the benifit of the human, not the computer. The logic has to be in front of your face.

Bookls have been written about this. It is about style. The computer does not care about style. But to use humans, style helps us to understand logic.

Hope this stirs you to re-think your source code style.

EDIT:
Disclaimaer: Link below is a startng point tath can led in many directions. Be carefull about where it takes you.

http://www.cspray.net/my.so-archive/100-most-influential-programming-books.html

Look for this one:
The Art of Computer Programming if only for the effort Knuth put into it.
Visual Studio DISPLAYS the matching starting brace control statement when you hover over a closing brace:



Many text editors will also highlight the matching braces when you are over top of one. usually the editor needs to "know" it is dealing with a source file, doing that varies by the application though.

I think these (and things like regions in C#) are something that really just facilitates what is generally a hard-to-read coding style. If control flow is nested deeply enough that it's hard to keep track of which braces match, it should be refactored into separate functions/methods. Remember that unless you write code in Machine code that it is designed for humans to read first, and computers second.

Notice, for example, in the snippet in the screenshot I took- there are a bunch of function calls describing exactly what is happening- to the point that a lot of it is self documenting even without being very familiar with the codebase. most of the methods/functions being called all perform a number of looping or other control flow tasks, sometimes based on server configurations as well. If all of that code was in-line within the routine, it would be massive, and it would be difficult to match the braces- but as it is, the tooltip isn't even needed, since it fits on one screen now.

Cool Thanks for sharing that info .... I guess I need to break out of my bad habit of having a program all contained in a single cpp file. The program i have has become massive as i had been building on it off and on for the last 3 years picking away at it adding more and more functionality and complexity to it.

I didnt know that Visual Studio had this mouse over feature to show which function it detects is to be closed at the brace location. I have been using Bloodshed Dev C++ 4.9.9.2 IDE because its lightweight and small install. Its obsolete, but works, but perhaps maybe I should move on to Visual Studio C++ Express.

Going to work on splitting this up to make it more manageable. Given that I am the only one that works with my code I generally make it all in a single .cpp etc and once a project is done its almost never revised since it does what was intended and doesnt need to do more, but spitting it up for this project makes sense as for I have more stuff to add to it and I will be able to target functions directly vs having to search for them in 22 or more pages.

Most projects are a small program to do something and there is no revisions, they are just quick console apps. This project though is one that I have been messing with off and on for the last 3 years and I guess should really be treated and structured as a project to make it more manageable even if just my self would ever be looking at the source code. It started off with 2 main features and that has grown to 5 features, soon to have 6 once I can code without distractions and be in the coding mindset as for I need to be free of distractions otherwise I hit walls in programming vs CHARGING through with it to success. Its almost like i have to warm my brain up to programming and then charge full steam ahead when i do it without distractions otherwise I lose track of what is what and why, especially since I use abstract methods that I even confuse myself sometimes when looking back after not looking at my code for a while as to why I did that etc. Perhaps better structuring will remove this problem as for I wont have to think about so much and can focus on just the functions at the function level as blocks vs looking at it as a whole which is massive and can be sort of overwhelming to follow at times.

Back in college, the professor didnt pick at structure and organization. It was mainly that you know what each thing did, could debug others code as well as write your own, and length of programs in a single .cpp file wasnt a problem. As long as the program did as intended you were scored mainly on it doing as intended. Points were removed if you made redundant functions vs reuse, and commenting was requested but not required. He would test your code to make sure you protected it from say someone entering letters or characters at a input that is requesting a value to teach testing of user input etc. But that was pretty much it. Starting to think maybe my teacher was laid back and i should have had one that focused on better structure and management to make something pretty vs something cluttered. Reference:
https://en.wikipedia.org/wiki/Daniel_D._McCracken
Quote

Daniel D. McCracken (July 23, 1930 – July 30, 2011) was a computer scientist in the United States. He was a Professor of Computer Sciences at the City College of New York, and the author of over two dozen textbooks on computer programming. His A Guide to Fortran Programming (Wiley, 1961) and its successors were the standard textbooks on that language for over two decades. His books have been translated into fourteen languages.
Found a youtube video showing "C++ Lesson 04: Making Modular Code" https://www.youtube.com/watch?v=1uqUgMozTXQ

Gonna work on taking what I got and making it more manageable "proper" C++ Would typically compartmentalize things into classes via appropriate OO.

It's all about recognizing what sort of maintenance or improvements are likely in the future- even if you aren't implementing them now- and effectively "laying out the tools", so when it, or perhaps similar changes, come up later you can make the changes easily.

For example the most recent instance where I did this was with some logic intended to delete a particular database object. In order to be allowed to delete, it had to be unused in a number of other tables. Currently, it shows the same message regardless of why it is disallowed, but the function I wrote returns a bitmask flag indicating what other tables contain the item information, so if later it is requested that that information be provided, it will be a matter of adding the appropriate new resource strings, rather than rewriting the function.

of course it is possible to to that too much. I think it is partly something that comes about with experience to get the proper trade off. I've run into situations where something is overarchitected at least as much as underarchitected; though if I had to choose I'd probably go for the former.


Years ago when learning use of classes in C++, all examples had the classes in the same .cpp called within the int main { } section of code, and classes listed below that in their own { }. To me seeing it all in the same .cpp which is also how the book had it, I didnt see the benefit of it. To me it felt like GOSUB's of many years earlier when working with BASIC and made the code scattered when following.

So when the professor said you can program a final project any way that you like, I fell back to a very linear ( almost BASIC like ) method which used nested loops but no goto or gosub type of operations in C++ because jumping around seemed too spaghetti code like and I was able to control flow of execution all within loops to pass in and out of loops to reuse functions that way.

However those programs were maybe 3 pages of code and so easier to scroll up and down the code to follow loop logic. But now that i have this project that has gotten rather large, I see that it will be way better to manage this way with calls to objects vs cramming it all into a massive single .cpp file. So going to break out of my way of clutter programming and try to conform to this other way of better structure for large programs.


The other thing that had most of the class confused was why so many ways of the main of:

int main() {

return(0);
}


int main(void){

}


and

void main(){

}


and there is also

int main(int argc, char* argv[]){

}


as well as

int main(int argc, char** argv){

}



And I stuck with

int main(){

return(0);
}

mainly because I could control where the program ended by where return(0); was placed whereas the other methods you didnt have a return(0); ACTING as an end of program flag. Reading up on these its a mix of C and C++ and lots of comments on whats better than the other etc.In addition to The Art of Computer Programming (I have the three-volume set myself, not exactly cheap (nor brief...)) some other good programming books:

Clean Code by Robert C. Martin
Code Complete by Steve McConnell
The Pragmatic Programmer by Andrew Hunt and David Thomas
Refactoring: Improving the design of existing Code by Martin Fowler

Another good one is Programming Pearls by Jon Bentley.

Most of then aren't language specific. They might use one language or another, but the concepts discussed are typically language agnostic.



Also while not directly related to programming I suppose I have to plug Designing Usable Apps by Kevin Matz. It covers things more from a perspective of management but it is still relevant because some of the same considerations make sense in hobby programming as well, and it can be insightful with regards to User Experience. it's sort of like a "The Design of Everyday Things" meets software development.

Has to be said that I might be biased because my copy was free and the author was my Project Manager for a few years.cool thanks for the book suggestions. Will see if I can get one of them on amazon used or something after looking further into them to see which one I want to get. Just about all book stores dried up which is sad out my way.

Never had any books focusing on clean structure etc. Code examples were clean I suppose with tabs used on lines to indent in stuff in books, with loop or IF logic statements starting far left etc, which I tend to follow but thats all. No code examples ever really had you calling to other code outside of the initial .cpp file etc.
1428.

Solve : Easiest VBSCRIPT question of the day?

Answer»

I have the FOLLOWING vbscript

Code: [Select]' VBScript to Display ComputerName

Set WshNetwork = WScript.CreateObject("WScript.Network")
'
WScript.Echo ("This computer is... "& WshNetwork.ComputerName & vbCrLf & vbCrLf & _
"Active user is... " & WshNetwork.username)

I want to ADD OS name to my script. I have found these two "ways":
wmic os get caption
(gwmi win32_operatingsystem).caption
but I don't know "OO" or VBS scripting so I don't know what to do.

TIAI was ABLE to get a WORKING answer from the link PROVIDED (above). I had done many searches, but I didn't know what to search for.

Problem SOLVED

THANK YOUThis is the bare minimum you need
Code: [Select]Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & "." & "\root\cimv2")
Set oss = objWMIService.ExecQuery ("Select * from Win32_OperatingSystem")
For Each os in oss
Wscript.Echo "Caption: " & os.Caption
Next

1429.

Solve : I need some help.?

Answer»

Hi everyone ! My name's Thierry.
I liked BloodShed Dev C++ 5.0, BUT it has so many bugs and some bugs are causing grammatically and syntax correct code to compile successfully but completely malfunction such as within a while loop of recent code each iteration of the loop flips a value between 0 and 1 and back to 0 again in a flipflop, and the value starts at 0 as the integer is initialized before the loop and then the variable++; increments by 1 to value of 1, it runs an IF statement that if the variable is = 1 run a process different than if the variable was 0 and before exiting the IF logic to set the value back to 0 so the next iteration of the loop the value is now 0 and so it does the other logic for if the value is not equal to 1. The value gets stuck at 1 so it runs as 0111111111 instead of 0101010101. I dug out of storage my old Borland 4.02 and opened my CPP project and compiled it without any issues, ran the program and it runs correctly with 0101010101 so there is an issue with Bloodshed Dev C++ 5.0 in that the compile result from the source code is flawed and so it must be a bug that I ran into with it. I dont want to go back to USING Borland 4.02 on my old Windows XP system because it is so out of date. So looking for a modern IDE that will work the same as Borland 4.02, VC6, and Bloodshed Dev C++ 5. ทางเข้าufabet

Reason for avoiding Microsoft Visual C++ Express is 2 reasons...

#1 - I want to use one that is FREE that is completely FREE and so I have all Dev Features as well as no restrictions of Home vs Corporate Use
#2 - Might be nonsense, but I dont want to program based around MS VC++ because I want my source code to be less dependent on Microsoft and more flexible cross platform into Linux etc. I guess I am saying that I dont want to have a situation where I paint myself into a corner with programming for Windows if MS VC++ uses Windows ONLY libraries etc. *Sure I could always run it through Linux in a WINE environment, but I just want to avoid the potential to paint myself into a corner by creating more universal non OS platform specific code. (** I also have never programmed in C++ before for Linux but would like to and so you might see something in this part that I am wrong about and maybe I dont have to worry about MS VC++ created code MIGRATING to Linux OS use. )

Thanks. สมัครufabetInitialize your counter back to -1 and the flipflop will be fixed.

I also use Bloodshed Dev C++ and had an issue with flipfloping for a project i have and its an issue that the value needs to go back to -1 and not 0.

I have been pretty much working with Bloodshed Dev C++ and while it has some bugs I havent FOUND a suitable replacement to it. MS VC6 is one of my favorites, but I dont have a licensed copy of this. I ended up getting Borland along with a Book about 20 years AGO and the only issues I had with Borland was that it wanted the the includes to be with .h and Microsoft VC6 had a fit with the .h's. The VC6 that I had when back in college was the student educational edition and it would compile and add a line to the program showing that it was compiled with that free student edition to keep people from using student edition to write programs compiled to be sold from the free student IDE. So before Bloodshed Dev C++ 5 I was using Borland a lot, but Borland had some library limitations.

I have tried Eclipse C++ as SEEN here, but had problems with it: https://eclipse.org/cdt/

Lastly if you ever pass a string to CIN buffer with Bloodshed Dev C++ 5 where each character of that string input is placed into an array, you can run into problems with the first character of the string being duplicate in the array so the work like HELLO
which should be array element 0 of "H" and array element 1 of "E" and array element 2 of "L" will be element 0 = H element 1 = H and element 2 = E. I fixed this by creating a write to array delay where counter in while loop starts at 0 and not until counter reaches 1 does it then allow the nested if condition to write the data from CIN buffer 1 character per iteration to the array. * This issue only happens in Bloodshed Dev C++ 5, Borland doesnt have this issue as well as the student edition trial edition of VC6.

Bloodshed Dev C++ isnt that bad if you know of work arounds to dodge the bugs. I dont find bugs often and write all sorts of programs using Bloodshed Dev C++ 5. But whenever I do something completely off the wall, outside of what I normally code there is always the question of... is Bloodshed Dev C++ 5 going to act up or not.

With the -1 reset vs the reset to 0 for flipflop counter in my one program I am onto version 3 of it now and have all sorts of flipping and flopping going on as well as a non fixed periodic switching between arrays. The most complex thing now is constructing the inverse of that because my program is taking information and scrambling it up like crypto with character substitution and any letter in the substitution doesnt always correspond to the same ascii character substitution. I coded up a draft to the inverse and ran into problems. And when i have a clear head and can tackle this full force without distraction I will charge ahead and solve the inverse scramble issue where something like Hello World scrambles to 7gE0<y3#(vX and the inverse decrypt program will be able to replace characters back to their original characters based on a number of keys like a combination lock such as 3 values that control the behavior of the flipflopping and the variable period of flip flopping among multiple arrays which are shuffled and SRAND seed value injection for each array so that the seeds themselves are the keys to the combination to get the data back to original form.

1430.

Solve : just started coding?

Answer»

hello
i just starting leaning coding and the very first programming LANGUAGE i am being introduced to is java.
now my question is, please anyone help me with where i can get course materials to help me to code effectively
and if necessary help me out with places or links to where i can get a reliable video to watch help e to code?Learning Java ™ as your first programming language is a good idea.
As you know, the standards for Java ™ are set by the ORACLE company.
https://www.oracle.com/index.html

Do you like to learn by:

  • Classroom instruction.
  • Reading a book all the way.
  • Using actual code samples.

You can find lots of STUFF on-line. Most are free.
Here are just a few resources.

https://www.amazon.com/s/ref=nb_sb_noss_2?url=search-alias%3Daps&field-keywords=java+kindle&rh=i%3Aaps%2Ck%3Ajava+kindle

https://www.lynda.com/Java-training-tutorials/1077-0.html

http://www.javaworld.com/article/2076075/learn-java/core-java-learn-java-from-the-ground-up.html
quote:
Java is a simple, object-oriented, network-savvy, interpreted, ROBUST, secure, architecture-neutral, portable, high-performance, multithreaded, dynamic computer language.

That should help you. Also to add to Geeks list ... Youtube has some great tutorials as well. TheNewBoston has some that I have WATCHED on Java and other languages. Usually I am fast forwarding through stuff that I already know, but there is lots to learn on Youtube for free. There are videos for complete beginners all the way up to advanced.

One last place to mention is that MIT has open courseware. I have followed through courses they have up for the world to learn from and best part is that its all FREE https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-092-introduction-to-programming-in-java-january-iap-2010/index.htm
1431.

Solve : Opinion on Getters/Setters?

Answer»

If you were to do a SEARCH, you'll find several forums/threads that are divided when it comes to this topic. Some say getters/setters are evil and should be avoided, that the object should perform the calculation/behavior, and give you the result. Some developers use getters/setters, but with guidelines usually along the lines of:

Quote

Bad OO design: public fields.
Sort of bad OO design : when getters and setters are used, even when
not required
Great OO design : used only where they're REALLY required - and that to expose the behaviour of your class instead of a tool to manipulate the data.

or

Quote
Having getters and setters does not in itself break encapsulation. What does break encapsulation is having a getter and a setter for every data member (every field, in java lingo). That is one step away from making all data members public.

BUT...what if you do need a getter for every field?

Suppose I had an Author class for a Bookstore or Library PROGRAM(Java), so it will like something like this:

Code: [Select]public class Author {

private int authorID;
private String authorFirstname;
private String authorLastname;

//Constructor left out to keep code readable.

public int getAuthorID(){
return this.authorID;
}

public String getauthorFirstname(){
this.authorFirstname;
}

public String getauthorLastname(){
this.authorLastname;
}
}
Now I can display useful information by overriding the toString() method, but with this approach I can also implement a method to sort by lastname, and then display the ID, first and last name. My point is without getters/setters, how would I display the information in a GUI? How would I sort by lastname, and display the data? Getters make it more flexible, because this class could also be used in a web project, and the data being displayed on a webpage rather than a GUI.

Is it bad practice when you have to expose all the fields with getters? Should I be re-thinking my design? If so, how? There's nothing wrong with exposing EVERYTHING using getters and setters, what they MEAN by "What does break encapsulation is having a getter and a setter for every data member (every field, in java lingo). That is one step away from making all data members public." is that you shouldn't just create them for every variable as a matter of course. You should only create a getter or setter if you actually have a use for it.
1432.

Solve : Try Visual Studio. It's free.?

Answer»

Microsoft has versions of Visual Studio well suited for a newcomer to programming.
Yes, it is very good and you can learn it with less effort.
Why did I say that? Because there are lots of free tutorials all over the Internet.
Here is a good, simple starter on You Tube.
https://www.youtube.com/watch?v=pduCFX2O30o

He starts out with a console program. Ring t. A console program in Visual Studio. Don't snicker. It works good.
In one lesson he takes you from "Hello, World" to a little program that does something useful.

Later LESSONS go on to use more of the power of visual studio.
Also, you can fin tutorials from other sources. Look on you tube for other tutorials about Visual Studio. Most are free.

If you are new to programming, I recommend you look at Visual Studio.

Now here is my question. Do you use Visual Studio on a regular basis?
Why or why not?
in 2012 and earlier, Visual Studio effectively had three SKUs. There were some others which fell between some of these but they weren't consistent. You had Express, Professional, and Enterprise.

Express was the free version and had limited functionality in some areas, as well as a few licensing restrictions on what you could do with the software you created with it. It also couldn't load addons.

Professional was effectively the "full" product, with the "full" set of features, and was not encumbered by a TOS or EULA limiting it's use commercially.

Enterprise was the same as Professional, but included a number of tools for things like architectural diagrams, Code maps, memory dump analysis, Greatly expanded Test tools, and so forth.


Now, with the release of Visual Studio 2013, Microsoft completely DUMPED the "Express" editions.

From 2013 onwards, the Free release is now the "Community" edition. This was more than a name change, as well- the community is largely the same as the professional edition. It has some licensing restrictions, however they are much more lax compared to Express; Smaller Companies can use it without issue, and if the developed product is open source, it has no encumbrances.

Visual Studio Downloads

Quote

Now here is my question. Do you use Visual Studio on a regular basis?
Why or why not?

Yes, I have been using Visual Studio since I first set myself to the task of learning C# in 2008, and finally moving away from Visual Basic 6. You can also use it for a few other languages, like VB.NET and F#, and you can install things like IronPython to EVEN develop components using Python. I prefer using a straight up text editor for Python, though. Or, at best, PyCharm.

Supposedly you can even develop with Java using it- but again I think I'd take pretty much any existing Java IDE (Eclipse, Netbeans, etc.) over VS for that. It's just not built for it.

It's got a few nifty features. It can show some nifty information above methods, for example; In this case the project is part of a git repository, so it will show how many authors and commits a particular part of code has, and when the last commit was. If I add or remove code it will even show those changes with a coloured line in the left margin.

Unfortunately my work uses SVN so that integration doesn't show up. I haven't bothered to install one of the many add-ons which purport to add it either.

And of course that's one REASON I continue to use VS, because my work now deals with C# and C# projects. using something else would be an uphill battle even if I wanted to!
1433.

Solve : I got a problem?

Answer»

Hi there, My name's Thurner
I'm developing a small Android app and I've encountered such a problem. I WANT to move a object across the SCREEN in a particular amount of time (1 second), regardless of the screen size or density. I tried moving the object with DPI, but I don't get the same RESULT on different screens เล่นคาสิโนบนมือถือ

Seems as though you will need a way to know the area of the screen and then preset speeds for display sizes for the program to go with such as a smaller area screen it would get from one side to the other in 1 second at a slower rate then a large screen which the object would move faster across the screen to get to the other side within that same 1 second. My thoughts on this are that for small displays the game or whatever it is will appear to run slower and on LARGER screens faster. Thinking you need to either have the user specify a screen size or have some sort of hardware detection for size of display to be part of the equation.Going forward try to summarize your problem as the name of your Topic. Like maybe Android Development MOVEMENT.

1434.

Solve : Is there a Aucacity script to boost MP2 volume??

Answer»

I have a lot of MP3 files on a little naan-like PLAYER.
The load speaker is so tiny that it is hard to hear if there is any background noise. So I WANT to just boost the volume of all the files on the player, The player has 2 GB of flash and has lost of room let for more. I just want to boot the level of all the MP3 files on it.
Is tare a script that does that? If not, how do I make one?
I have Audacity 2.0.5 installed on my Windows XP and I have the Lame driver installed, so I already have used it to record and alter MP3.

Now I just want a script to boost up level of all files in a directory.

You might be able to loop back your audio out to microphone input and use VLC Player which allows you to go to 11 ( a little spinal tap humor ) with the volume playing the song. Then record it with audacity 2.0.5 as a higher volume audio than it initially is.

*I did this trick to gain higher volume to old cassettes that had a hiss to them as they are aged and my grandparents that passed away many years ago are on them. One of the tapes is from 1982 6 months before my grandfather passed away from cancer at 68 and other is 1988 my GRANDMOTHER who passed away in 1994 at 78. I now have these on MP3 and the magnetic taps are in rough shape and I still have them but because the tape aged they lost their crisp sound and have a hiss to them with some areas that are hard to understand as hysteresis of the magnetic tape spooled up affects each others layers over time I have been told to kill the quality. I used VLC Player as a booster to a audio recording using the Windows Recorder program, and feat the output back to the input and boosted its volume this way. There might be a program out there to do this but this was my free way of doing this.Did you have to do each my hand?
I was hoping for a script that would do it automatically.
I have never tried VlC to modify an audio file. I will look at it.

I wanted to use Audacity because it has a variety of effects that can be used to correct level and background noise. And add a little bit of echo to enhance the sound.

You want to use a Chain.

File->Edit Chains

Add. Call it "Amplify"

Now on the right side, click "Insert"

double-click "Amplify", then use "Edit Parameters" to change the settings of the amplification.

Now Insert Again, this time, insert "ExportMP3".

You should have a Chain that is 01- Amplify, and 02 - ExportMP3.

You can insert other things into the chain if you want to, as well, of course.

Now, Close out of the Edit Chains Dialog (confirming you want to save) and now go File->Apply Chain. Select Amplify, and choose "Apply to Files".

Now you select the files to apply to. I'd suggest making a copy of all the files you want to apply this to, and then applying it to the copy, in case amplification introduces clipping.

1435.

Solve : Address Change?

Answer»

Have a classic asp website that uses a QUERYSTRING to create page from template and data from database, the url creating is ALWAYS ending in ?T= have do i CHANGE this to be a more attractive url?

THANKS

1436.

Solve : unresolved externals visual studio 2013?

Answer»

I am writing a simple program for my CLASS. It is supposed to show a snowman. I am getting the ERROR "unresolved externals"" and when i try to run it, it says " The system cannot find the file specified".

#INCLUDE /* printf, scanf definitions*/
#include "stdafx.h"
#include
#include "function.h"
/* Draws a hat*/
void
draw_hat(void)
{
printf(" ___\n");
printf("| |\n ");
printf("____\n");
}
/* Draws a circle*/
void
draw_circle1(void)
{
printf(" * \n");
printf("* *\n");
printf(" * *\n");
}
void
draw_circle2(void)
{
printf(" * \n");
printf("* *\n");
printf(" * *\n");
printf(" * \n");
}
void
draw_circle3(void)
{
printf(" * \n");
printf("* *\n");
printf(" * *\n");
printf(" * * /n");
return(0);
}?You are TRYING to return 0 in draw_circle3 which has no return type. So that module won't compile.

There is ALSO no main routine, so it cannot be linked into a console application. I assume you made function.h.

1437.

Solve : draw with code?

Answer»

I am at home screen of computer and I want to draw with code so where I have to go what to do in computer More info???
What code are you using?
You want to draw what?I AGREE with mark... and drawing in code is something you can find in a google search for a specific language and get their code example for making a circle for example and then build on from it to do whatever you want.

You will want to take an intro to programming course or plan on lots of reading and playing around with demos of code before you are able to make a product to your liking. I took Advanced C++ in college for my degree requirement and Graphics with pixel control and collision detection and all that is a bit much for me. I get the concepts etc, but applying it is mathematical fun. I ended up sort of cheating a little on my final project in which I made a video game by calling to Bit Map Images to display certain game states, so i had an image that could be called and loaded for every game combination that i created with MSPAINT, and this gave the visual appearance of a very well crafted graphically eye appealing game, but it wasnt very complex at all for graphics as for it was just refreshing the bit map to the display for a turn based network game that was playable between 2 people and a text file that was shared between both PLAYERS allowed the game to keep track of who is where and what everyones stats are etc. The game was LARGE in size because there was no reuse of objects in the images. Each game state was its own image, so it was like 250MB in size for something that if I knew how to get the graphics down in C++ probably could have been done in less than 10MB by reuse of images as textures etc where a small image object acts like a texture and is called and replicated to patch together on the screen like many tiles that make up the games display. Keeping track of the tile states within 3 dimensional arrays and all that made my head spin on my shoulders, so i had to come up with a game for final project and use all that was learned but the teacher didnt show us graphics we had to learn all that on our own and I took the easy way out of calling to like 1 of 200 game state bitmaps and as players move around on the map which was rather small and more of a proof of concept program and it was turn based to where as its your turn your system will change location of you on map and write back to shared text file, then the turn was given to me and the text file read in by C++ and map changed to reflect their change in position and back and forth until SOMEONE was dead and other alive etc.

Here is a example of very basic graphics: https://www.youtube.com/watch?v=-sYRiqVWi3Y

Unless you have ever programmed before you will be very lost with this... its not for beginners...

1438.

Solve : how to re-conect automatically to RDP every 10 min. using a vbs script?

Answer»

I save my rdp account on my Desktop :'' MyAccount.rdp'' and when i click on it i will automatically log on.
Now i need a vbs script to log me automatically every 10 minutes
can u do that plz?i can open a thread and give u some pointsWhy do you need an unattended RDP session?

There has to be a better way than RDP if you need to gather INFORMATION from a remote system unattended. Maybe we can assist with a better method if you share what your trying to do. Additionally VNC would work better I am thinking if you need a remote access session. VNC would work out better if the connection was interrupted to where the connection can be remade and the desktop etc would still be up and running with whatever you have going on. A RDP session dropping out isnt as graceful as VNC.

Additionally looking at your past posts here... how do you have RDP access to Server 2008 yet you dont have Admin Access to go in and MAKE necessary changes in Server 2008?

Hopefully you didnt FIND someones open RDP on port 3389 and a weak password to get in etc. It just sounds really strange is all I'm saying. Not saying you are, but of everything i have seen in past posts it appears that you might have access to a system that maybe you shouldnt have access to. So hoping you can disprove all the flags that are popping up that to me I'm very cautious to assist with this because of how odd this is. Analogy to what I see = A shopping cart with everything to make a bomb draws attention until it can be disproved that its being used for a non-destructive application such as just needing to fertilize the farm, and the plumbing supplies are for the water system for the animals etc. Quote from: karlosss on October 13, 2017, 11:35:10 PM

Now i need a vbs script to log me automatically every 10 minutes
I usually need to know why or some background information and why does it need to be vbscript?

Quote from: karlosss on October 13, 2017, 11:35:10 PM
i can open a thread and give u some points
This comment baffles me.I was thinking on the "points" that this might not the the primary location that help was asked at. This might be a copy/paste from another forum they are asking at that has a points system in place to have kudos ranks through a point system SIMILAR to stackoverflow's gold, silver, and bronze badge system. Other than that I too am LOST and I dont require a gold sticker at the end of the day, nor a silver or bronze one.
1439.

Solve : Need Batch file to execute and close same program?

Answer»

Hello all.
I have rainmeter on my system, and game alot. I'm trying to figure out how to CREATE a single button on my desktop to open and close the program so as not to clutter my desktop with multiple icons for the same program. I currently have two separate files one for turning it on and the other for turning it off.

To turn on rainmeter I have the following batch

@echo off
cd "C:\Program Files\Rainmeter"
start Rainmeter.exe
EXIT

To turn off Rainmeter I have this batch

TASKKILL /f /im rainmeter.exe

Is there a way to COMBINE these into a single batch file so I have only one button that does both optionally?
This should "toggle" when you run it. If it's running it is terminated, if it's not running, it is launched.

Code: [Select]@echo off
cd "C:\Program Files\Rainmeter"
taskkill /f /im rainmeter.exe && echo "terminated Rainmeter" || rainmeter.exe
exit
Why not gracefully exit the program with the proper command LINE argument.

Code: [Select]"C:\Program Files\Rainmeter\Rainmeter.exe" !Quit

1440.

Solve : why is using namespace std foolish in c++??

Answer»

Was looking over some code and the repetition of std::cout instead of using using namespace std caught my attention as why all these extra keystrokes to type std:: before each cout when using the global using namespace std I thought was the way to go. From digging on google it looks like this using namespace std is older coding method and according to one commenter "foolish" but no reason as to why its foolish.

Below is the comment that grabbed my attention and decided to ask here whats foolish about coding that way and saving from having to type std:: prepended to every cout .... Its an output so... it cant make for an overflow that I know of

Quote

If you've foolishly dumped some of the standard library into the global namespace with using namespace std; then it means the same as std::cout.

https://stackoverflow.com/questions/25807082/difference-between-stdcout-and-coutMaybe this...

https://stackoverflow.com/questions/4043930/is-using-namespace-like-bad

Quote
It's primarily about good housekeeping. If you're not really going to use more than a few identifiers in a namespace, why clutter up your own namespace by dumping all of the identifiers from that namespace into yours?
Thanks Salmon... Google wasnt hitting on matches to "foolish" other than the one that I had found and "BAD" shows lots on this subject with exact reasons why like what you linked.

Reading up on this it looks like I need to break my legacy using namespace std method and force myself to make a habit of prefixing std:: before cout, cin, and endl. It wouldnt be a problem for stuff I code, but if I were to code anything for a larger project the legacy use of using namespace std could be a problem given the right conditions.

To me I was looking at this similar to how in batch you can just use @echo off and then not need to @echo. for each line making for extra keystrokes. I didnt expect it to be a naming convention issue with variables and libraries. Interesting.

BACK in the day of Basic programming I so loved using ? in place of having to type PRINT I like lesser keystrokes and get the job done, but this is a situation where I should ditch the legacy habit of global namespace I guess and type the 5 extra keystrokes per use.

Sometimes I wish there was a shorthand programming method like how ? = PRINT and all that to manually code faster and as is with ? = PRINT saving 3 keystrokes per since having to press shift and then ? is 2 strokes. Maybe there is a way to define functions and call to them in short hand. I've never done that in C++ other than calling to objects for reuse, but like instead of std::cout and std::cin you can simply use ? for std::cout and | for std::cin however I'm thinking maybe it can only be done by altering a compiler to recognize this syntax and run with it as such. BASIC use to flip the ? to PRINT so when listing your program it wouldnt show ? but instead would show PRINT in place of ? as for the IDE already flipped the shorthand to longhand so even when lprint of your code to that loud DOT matrix printer you didnt see ? but PRINT in proper syntax.

10 CLS
20 ?"Hello World"
30 END

but instead list would show as

10 CLS
20 PRINT"Hello World"
30 END

Shorthand programming is one of the reasons why Perl is so luring to me. "using namespace X" is not the same as imports or uses in other languages like Java or C#. It is largely these differences which make it a poor practice. With Java and C# imports and uses effectively tell the compiler "if you don't understand an identifier, try looking in these packages and namespaces before you give up". But in C++ using namespace X means to bring everything in that namespace into the global namespace in the current scope. Whereas ambiguous names in Java packages ad C# nmamespaces just means you have to explicitly reference those namespaces when using the appropriate class, with C++ a name collision is actually a compile error on the uses namespace statement which brings in the colliding identifier.

This means if a namespace changes and adds indentifiers which now collide with your global namespace or with another namespace, you either need to remove the uses namespace altogether and make everything explicit or change your code so it doesn't conflict with the namespace, if you can even do that.


If you want "shorthands" you can define them yourself using Macros or functions. For example:

Code: [Select]#include <iostream>
#define writeln(data) std::cout << data << std::endl
#define readln(variable) std::cin >> variable
int main()
{
int dataread=0;
writeln("data");
readln(dataread);
return 0;
}

You cannot use a question mark or pipe symbol here since the macro has to be a valid identifier. You could make macros for say i and o for each one.

Then the macro includes the namespace reference. Same if you were to do this via a separate function. (a separate function, by the way, can use using namespace... right within the function. You can use the using namespace... statement at any scope- it doesn't need to be at the start of the file).

As an aside, Source Code isn't supposed to be "easy to write" and striving to reduce keystrokes is counter-productive. You should be writing it so that it is easy to read, which means longer more descriptive identifiers. For example, Take this function: I doubt somebody even needs to know C# or have any understanding of the massive libraries that it is part of to understand what is happening here.

Code: [Select]private bool ProductSuiteApplies(ReportInformation reader)
{
var productType = Config.Static.Get<SuiteInformation.ProductTypeConstants>("General.ProductType");
String SuiteDesc = SuiteInformation.GetProductDescription(productType);
String Abbrev = SuiteInformation.GetProductAbbreviation(productType);
return reader.ApplicableSuites.Length > 0 ||
reader.ApplicableSuites.Contains(SuiteDesc) || reader.ApplicableSuites.Contains(Abbrev);
}

Imagine if it was using "shorthand" or quick and dirty variables, though:

Code: [Select]private bool CheckSt(RInf r)
{
var pt = Cfg.Get<SInfo.Types>("G.Type");
String sd = SInfo.GetPD(pt);
String abv = SInfo.GetPA(productType);
return reader.AS.Length > 0 ||
reader.AS.Contains(sd) || reader.AS.Contains(Abv);
}

It would require looking at the functions/methods that are being called to know what it is even doing. What is a "St"? Well, aside from saving a few characters, A completely OPAQUE identifier.Thanks BC for your input on this. Pretty Cool that you can shorthand by defining for readline and writeline. I was thinking the compiler would have to have rules on how to handle a shorthand, and you proved that it can be done with a standard IDE.

Regarding looking at the other C# code I agree that to others working with your code being as descriptive as possible is probably best in whats doing on to follow it without having to look up functions. I tend to not be as descriptive in the actual function variables and pointers but put description in my comments, however I see now that with a well descriptive function or method I can actually ditch the comment lines and have it self descriptive which saves keystrokes I suppose. At times I do tend to still go with short variable names such as CIN>>A; and CIN>>Acct; would be a better habit and to be proper STD::CIN>>Acct; to avoid the using namespace std and Acct is easily identifiable as Account.

Having been messing with programming since I was 10 with BASIC and not sticking to any one language to master but knowing enough to put stuff together when NEEDED has made for some bad habits. s well as sometimes I have even programmed in a mix of C and C++ and the IDE is happy with it due to legacy support but its a mess to professional programmers. Grins knowing you have seen some of my rube Goldberg code examples here over the years as well as some problems I have run into due to this. I feel like a jack of many programming languages but master of none. But I am able to piece together ways to get the job done however sometimes not as efficient in execution or vulnerable to overflow conditions because the input isn't tested for length etc because I am using the program myself and wont intentionally overflow it. However some interesting problems arise when I forgot for example that the FIRST element of an array is 0 and not 1 and my program called to memory outside of the scope of the array. Lesson learned and fortunately I caught it and fixed it. Or when I look at the code and it starts at 0 and ++ increments to 1 and then reset back to 0 and I am getting 1111111 as an output because for some reason while the code structure shows that it should reset back to 0 and then increment again to 1 and after it did the flop to the flip reset back to 0 to use 2 arrays in a concatenation it was found that I needed to set the value to -1 to get my 0101010101 which I was looking for with my flipflop issue about a year ago.

Thanks for your patience with my questions and descriptive examples.

Quote
needed to set the value to -1
Yes, that was documented somewhere in the Intel assembly language for the 8080.
Now way can I find it, but it is called 'Two's complement' arithmetic. It is the standard for Intel machine code in the 8086 family.
So you define:
FALSE = 0
TRUE = -1
And it is also part of the Microsoft Basic stuff.
That goes back to about 1975, I think.
Modern reference:
https://www.cs.cornell.edu/~tomf/notes/cps104/twoscomp.html
Quote
Two's complement is not a complicated scheme and is not well served by anything lengthly. Therefore, after this introduction, which explains what two's complement is and how to use it, there are mostly examples.
Two's complement is the way every computer I know of chooses to represent integers. To get the two's complement negative notation of an integer, you write out the number in binary. You then invert the digits, and add one to the result.
That is as much as anybody needs to know.
1441.

Solve : Programming motherboard?

Answer»

I just got an Intel Core i5-8600K CPU which didn't fit my MOTHERBOARD at the moment. My computer is a - Lenovo H50 Tower PC (AMD A10-7800 3.9 GHz, AMD Radeon R7 240 2 GB Graphics, 12 GB DDR3 RAM, 2 TB HDD, DVD-RW, with a NEW graphics card installed. I'm wondering what motherboard would fit my CPU and the chassis to my computer which isn't the biggest. Any suggestions on what kind of motherboard I should by?You need a Micro-ATX Motherboard with an LGA-1151 socket. You also need new RAM, as any LGA 1151 Motherboard will be using DDR4.

H50's power supply is only 280W and the i5 8600K will probably need AROUND 400W to work comfortably, so you should add a PSU to your list.

At that point you may as well add a case and make it a new system altogether.

1442.

Solve : Looking for suggestions on a game that I am porting from Javascript to C++?

Answer»

There was a game that I made a ways back when I was taking JavaScript Programming in college 20 years ago. I was thinking the other day of porting that by rewriting it for C++ from scratch to be a stand alone game that RUNS on C++ and ran into the challenges of graphics. So I remember in one of my old Borland C++ books it had bitmap rendering and all sorts of stuff on bitmaps.

So I skipped over looking this up in my old book from the late 1990s and went on to make the 120 different game states as 120 differently named bitmaps in Microsoft Paint. The idea is to call to the bitmap that displays the game state to display that game state without having to specify every bitmap pixel or sprite location, just call to the image and display the image that shows the game state which I thought would make it way simple than having to piece together pixels.

My book is somewhere, possibly lost in the move, and searching google I dont see any exact matches to what i am trying to do and they all seem to call to an outside viewer to display the image which for a game to have a viewer instance called, the only way that that could work for this game is if there was a refresh loop that was looking at a target location and display any bitmap at that location so as the game changes the viewer changes the image result of whatever the player is doing. Additionally there is the problem with the fact that you now have 2 windows open. One that displays the image for the game state and the other for the user input.

I'd like to get this all into the same window vs calling to outside viewer and its looking like I need to do away with console C++ programming and switch to programming for Windows. However once again I hit a wall looking for code examples to learn from to piece together my program to make this work.

The game title was Dark Room Deathmatch, the concept of 2 or more players placed into a dark confined space room with a knife and only 1 player survives, and they can not hear or see each other as they are all quiet in moving but when they bump into someone they stab them and then get to flea so who they are attacking cant just target the same location they are at. It starts off where you can't see your opponent initially. And after a certain number of moves the room shrinks in space by blocks in strategic areas no longer in play and so they get greyed out, and if a player is located at one of these blocks that is no longer in play they get relocated to the nearest block that is still in play. As the game progresses further if someone hasnt died yet then hint of blood is enabled and so you have an idea of where your opponent is sort of like hot or cold hot for closer to opponent and cold for further away but it doesnt give exact location away it makes blocks glow pink around a player but the player might not necessarily be at the center of the glowing blocked area they could be located on the edge of the glowing pink blocks. I also added special moves to the game that allowed players to teleport themselves to any block that is still in play but it was a limited use feature. If someone felt like they were being cornered they could use it to jump to far end of map or any location still in play. This feature of teleporting though wasnt enabled until a certain number of moves so that someone couldnt use it as their opening move to exploit the person going first landing on the starting location of their opponent which is known at the start.

Because I am not an artist by any means I chose to go low tech with just a map that shows your location in RELATION to the play area. Its about as low tech as a board game with a piece that moves on the board. The game is a combination of other game concepts mashed together. For the fact that your playing in the game environment of in the dark there is no need to display anything that impressive other then a map with a block location to indicate where you are as well as any changes to the map.

With javascript for this game it was pretty easy as for the browser environment allowed for user input and a refresh of the image to show the change in the game state. An array was used to keep track of where the player was, and if the array value was 5 for the players location, the image for map5.bmp would display to reflect the location of the player in regards to the other player. The game was like battleship in that you didnt know where the other player was but that when you found them they could flea. So unlike battleship where once you hit the opponent you just need to determine the orientation of fixed objects, in my game the opponent can go in 8 different directions to flea in a 30 block area laid out as 2 blocks, 4 blocks, 6 blocks, 6 blocks, 6 blocks, 4 blocks, and 2 blocks with each player starting on opposite ends of the map. It starts out as an open area and no idea where each other is until you land on them to strike a hit. After so many plays in the game blocks in specific locations turn from white to grey as they are barriers that are placed into the game to make the odds of bumping into each other increased as there are lesser blocks to move to. Then as the game goes on for even more turns by each player blocks in an area will turn pink indicating that your enemy is near and so each person knows a hot or cold close or far away from each other to further increase the odds of each other striking each other by landing on the block that they are at. After a player is struck 10 times they are dead. This javascript game was single player because making it 2 or more players would have required a database and forms to pass the data to the database etc and web server side dynamic HTML etc and time was limited.

I was thinking if I could get this working with C++ ( or just about any other programming language out there ) that I can get the multiplayer aspect of this to work. The game would play on 2 computers that have access to a network share. The network share has text files for the game state information to be passed between the program running on each of the computers. One of the text files is a read/write lock which keeps control of Player #1 vs Player #2's turn. The game has a time delay loop in it that tests the value within the text file to see whos turn it is. If the value is 1 then its player 1's turn. If the value is 2 then its player 2's turn.

I was talking to a friend at this years game con and he suggested that I should bring the game there next year with 2 computers since I have plenty of spare working computers that I could leave set up for people to sit down and play against each other etc. Even though its a low tech game and no impressive graphics he said it sounds like it would make for some fun for people looking for a break from the other games.

If I can get it working as 2 player then my goal is to then make it 4 player turn based with a larger map. But not going to go that route until I can get the 2 player version of this hammered out and working.

the reason why i am not going with a database to keep track of game state is because its just a few players. Its never going to be a game that is large scale that you have multiple instances of it going on, and a network share to text files with game states is simplistic and I have used that method before in the past for 2 player card game that was C++ console based to play War with a network connected friend to a network share back in college.

Javascripts inability to read/write to files locally as designed due to security reasons is the main reason why i didnt just take what I had in javascript and make it 2 player.

Part of me is feeling a tug to go with dynamic HTML vs beating my head against the C++ wall and just make the game run off of an apache web server with php for example and go the database route for keeping track of game state and progress. This method would make use of the bitmap game states very simple to implement. But I havent caved to that just yet and am sort of determined on a way to pull this off with C++ and avoiding the use of a database and instead just text files that each computer uses to keep track of turn and game progress.

I looked for a C++ code example that has a button and displays one bitmap image and then click on that button and it displays a new image as for once I know how to achieve this I can replicate the code and add the logic guts to it to make the rest of it come together I feel.

Additionally I refuse to just go the route of displaying ASCII characters for a display for the user with a console window open and something that looks like this with X as the players location
[ ] [ ]
[ ] [ ] [ ] [ ]
[ ] [ ] [ ] [ ] [ ] [ ]
[ ] [ ] [ ] [ ] [ ] [ ]
[ ] [ ] [ ] [ ] [ ] [ ]
[ ] [ ] [ ] [ ]
[X] [ ]
To show location of the player on a map with the slightly better than Zork method of gaming.

Seeing a picture vs ascii just looks more appealing and at least gives it an Atari 2600 feel of complexity which is more visually appealing.
Additionally I feel that I need to get over this roadblock and learn from it vs going an alternate route to achieve this unless its more realistic to go the route of the apache web server with people connecting to it with dynamic HTML, php, and form data passed to database to make it 2 to 4 players.

The up to 4 player version would be like this, but as a clean looking bitmap image in paint with some eye appeal and maybe a nice background too. Only the player themselves location is displayed to them. They cant see the other player or players. The numbers 1,2,3,4 indicating player start locations and all of then free to move in any direction and land on each other to land hits and able to move 1 or 2 places per turn or skip moving and stay put if foolish to wait to be landed on or stay out of the mix in the middle in hopes to wait it out around the outside perimeter until 2 players are eliminated and they can then focus on just 1 opponent as everyone went after each other towards the middle of the play area using the demolition derby method of staying out of the initial fight wih heavy damage to then wait it out to see who survives it and then go after them in hopefully better shape than they are in leaving the fight but taking some damage from others who failed.

[ ] [3]
[ ] [ ] [ ] [ ]
[ ] [ ] [ ] [ ] [ ] [ ]
[2] [ ] [ ] [ ] [ ] [ ] [ ] [ ]
[ ] [ ] [ ] [ ] [ ] [ ] [ ] [4]
[ ] [ ] [ ] [ ] [ ] [ ]
[ ] [ ] [ ] [ ]
[1] [ ]

Players health Bars can be displayed or not displayed by choice. If not displayed for actual health bar to be known by all then its just an ALIVE or dead indication.If you want to create a GUI in C++ you are going to have to either learn to construct and manage Windows and Device Contexts directly via the Windows API, or use a framework to manage it for you.

Visual Studio has a C++ template for a empty Desktop Application. But you will need to be familiar with the Win32 API.


I think saving every possible board state seems excessive. As you add features to the game you will need additional board states, and the bitmaps are also going to be relatively large. Since it's a simple grid it isn't difficult to just draw squares. Saving every board state is only feasible for simple, "solved" games like tic-tac-toe.

The basis for the entire thing seems to be about movement within a grid.

I don't think a multidimensional array is needed. Instead, you can have the number of rows and columns in the grid and then store the positions of any appropriate things such as players, or information about blocks that aren't available anymore and evaluate things that way. It also opens up additional possible features, such as pits that cause you to lose a turn, or finding "power ups" if they were to be added (perhaps a single-shot GUN that can shoot in one of the 8 cardinal directions and will eliminate players in that path, or a flashlight with a low battery that let's you illuminate a triangle in a particular direction and see the location of players, etc.

The grid-based movement is the basis for the entire idea and is relatively straightforward, of course I'm going to go out on a limb and say you have no idea how to even create a Windows Application in C++, let alone how to draw anything in one. I mean, you wouldn't be posting this question otherwise .

I've never created a GUI C++ Application either that I recall, but I've worked with the Win32 API a lot and was able to use some boilerplate for the standard stuff. I made a thrown together, very rough example which allows moving within a larger grid-based play area. This is *very* thrown together, and shouldn't really be used as an example of anything; I threw everything into a single source file. It still has a bunch of unnecessary stuff like the MENU and about box and stuff which need to be stripped out.

Fundamentally it stores information about the Play area (number of columns, number of rows) and the position of a single player. it draws the board in a very basic way with filled and outlined squares, and will draw the square with the first player in it differently. It responds to arrow keys by changing the first player's position and forcing things to repaint.

A version that plays over the network should use Sockets properly. How many games have you played which save text files to a shared drive for multiplayer? WoW doesn't make you use Hamachi and have a shared drive. Mind you I might not be much help with that one, my experience with networking via Sockets is largely with our Server program on Windows which mimics a much older server program that ran on a much older OS and it takes the requests and commands which would typically deal with ancient ISAM database files, and translates them to instead read/write Postgres tables. I didn't write it and have only made bugfixes and a few additions and it's not tended to be anywhere near where the actual network socket communication occurs.Why?

(Rhetorical question. I don't need any answer. You need to think about your objective.)

In general, programs that are interpreted should stay that way. The interpreted program ca resolve dependencies at run time, something the compiler can not do.

Quote

The grid-based movement is the basis for the entire idea and is relatively straightforward, of course I'm going to go out on a limb and say you have no idea how to even create a Windows Application in C++, let alone how to draw anything in one. I mean, you wouldn't be posting this question otherwise


Other than the books that come with lab projects and a CD or DVD in the back of them to follow and make programs in Visual C# or Visual C++ for Visual Studio Express 2010 for example, I have mainly programmed for console vs Windows. If push comes to shove I play around with Windows based programming and digging through pages for code examples, but my comfort zone in which i dont have to fumble through pages of a book to program has been down and dirty console programs that do what I need because I am the end user and it doesnt need to be pretty just need to work with exception to the fact that console programming doesnt have attractive user interfaces and no graphics or sounds other than BEEP etc.

Many many years ago I did some drawing of lines, and pixel sprite manipulation etc with Basic. Basic at least had color and sound tone / duration built into it. My biggest problem back then was trying to get the refresh right so that the object moving on the display wouldn't flicker as my refresh was a loop spamming the CLS clear screen to clean up the old display state. There was likely better ways to refresh, but the clear screen spamming was my method and I had seen it done with some other people code examples. There was code in a magazine back in the days when programs would be in monthly magazines (1980s) that showed how to set it up to use arrow keys and space bar and I used that code from the magazine for my game, however proper rendering of objects was pretty ugly and I was playing a round with adding time delays in the refresh in order to get game objects to display properly. This slowed down the game execution as well since it was single threaded so the program was on a pause state until the for loop counted from X=1 to 100 and moved on then reset the value to 1 so on next iteration X=1 and it would loop to 100 and repeat. When not using code sections for myself I would program it as seen in magazine and then correct for typos and when the program ( mostly games ) ran correctly I then would mess around with it all and trial and error learn what happens if you mess with this or that.

Sadly when I was in college ( late 1990s ) the professor taught VC++ 5.0 and everything was in console. No Windows programming at all. I asked why not be teaching how to make Windows programs since DOS type of games and programs are a thing of the past. His statement was that if I wanted to make Windows games that I should be taking the Visual Basic course as for the C++ courses they offer are all programming in console and that the type of C++ programming that is taught here gives a good foundation for writing programs that large companies would use for business with databases etc and not games. Knowing from reading about how the games out there are made mostly in C++ instead of Visual Basic, I chose the path of sticking with C++ because I felt it was the better path to go with programming for all platforms vs being stuck with only programming for Windows OS computers as well as while the teacher was telling me if I want to program Windows games I should have taken Visual Basic, I knew that that wasnt the programming language to be in for game programming as for greater than 80% of the games at the time were created using C++.

At some point I should probably take an up to date college level programming course that doesnt program in console programming and have the hands on learning with a teacher who can look over my shoulder and point out this or that. For now though I have books and follow lab examples but I find myself copy pasting sections of code that will do something and so if I needed a specific function I know copy/pasting it in and editing it as needed to do whatever I need, but picking it apart I might only know half of what is there as to what it does the other half I know is necessary but not sure exactly why etc. And doing this sometimes means that there is creep code. Portions of code that came from elsewhere that doesnt flag as a warning that its unnecessary when compiling but a skilled programmer would be like... why is that there it makes no sense... its harmless in that it doesnt affect the execution of the program but it stands out to someone who is a skilled coder that it doesnt belong. When explaining that I copy/pasted code from elsewhere and then tweaked it to what i needed it for and didnt quite understand every part of what is going on, it then makes sense as to why its there and that it wasnt added intentional for any extra feature in my code, but instead is unnecessary code that came from elsewhere. Usually though compiling there are warnings and I can remove stuff that isnt necessary and then get a clean compile without warnings, but sometimes the compiler doesnt catch it as unnecessary.

Regarding the use of the shared text file... yes that is an odd way to slap it together and make it work. Not complex but very different, and not a method that would make any sense if designed to be distributed etc. WoW uses databases for keeping track of everything which is the best method especially with at one point 10 million copies sold and probably half that active users.

Thanks for the reply to this. Going to look into Win32 API also thanks for linking your game snippet going to check that out after I click post.

*Update* ... Got a 404 page error for that link you provided.
Possible reference that might help a little.
https://www.leaningtech.com/cheerp/buy/
Cheep
Quote
Cheerp is distributed as a Free and Open Source Software under the University of Illinois/NCSA Open Source License (core compiler) and under the GNU General Public License v2 (libraries).
For commercial uses, Cheerp is also available with a non-copyleft proprietary license, private support, and premium features. Three licenses are available:

Code: [Select]// The cheerp/clientlib.h header contains declarations
// for all the browser APIs.
#include <cheerp/clientlib.h>

// webMain is the entry point for web applications written in Cheerp.
void webMain()
{
// client is a C++ namespace that contains all browser APIs
client::console.log("Hello World Wide Web!");
}You can compile this program using the following command line:
Code: [Select]/opt/cheerp/bin/clang++ -target cheerp example.cpp -o example.js
Source for above:
https://github.com/leaningtech/cheerp-meta/wiki/Cheerp-Tutorial

Fixed, Apparently Private pages/posts require login to show, I thought they just needed the URL. Probably because of some security modules I installed recently. I've made it public so the link should work now. I'll probably just put it at the end of this post anyways

Quote from: DaveLembke on December 02, 2017, 08:13:51 PM
Many many years ago I did some drawing of lines, and pixel sprite manipulation etc with Basic. Basic at least had color and sound tone / duration built into it. My biggest problem back then was trying to get the refresh right so that the object moving on the display wouldn't flicker as my refresh was a loop spamming the CLS clear screen to clean up the old display state. There was likely better ways to refresh, but the clear screen spamming was my method and I had seen it done with some other people code examples.

Yes, you wanted page flipping. If memory serves it was done with certain arguments to the SCREEN statement in BASIC which switched to graphics mode. Certain Screen modes supported page flipping, and you used different parameters to SCREEN to change the active buffer as well as change the active one. Buffer 0 would be on screen and you would draw to the second buffer, then when finished, instantly flip to the second buffer, then you would switch to the first buffer as active, clear it, and draw there, then when finished flip back to the first buffer, etc. the CLS and drawing would be effectively off-screen. It can also be done with non page-flipped modes with a memory buffer but that is more involved.

Quote
His statement was that if I wanted to make Windows games that I should be taking the Visual Basic course as for the C++ courses they offer are all programming in console and that the type of C++ programming that is taught here gives a good foundation for writing programs that large companies would use for business with databases etc and not games.

That doesn't make much sense to me! Business software for both small and large companies aren't usually console programs. The software I work on is for Inventory management, invoices, sales, Marina reservations, Work orders, etc. And they are all Windows GUI Applications. The only Console program in the entire thing is something I threw together as part of our source code build script, so it is only on our build server. Even in the mid to late 90's using Windows console software wasn't really a thing. Maybe on a *nix system but mostly with ancient mainframe terminal software, and businesses don't usually want to upgrade when there is going to be no real change.

Quote
Knowing from reading about how the games out there are made mostly in C++ instead of Visual Basic, I chose the path of sticking with C++ because I felt it was the better path to go with programming for all platforms vs being stuck with only programming for Windows OS computers as well as while the teacher was telling me if I want to program Windows games I should have taken Visual Basic, I knew that that wasnt the programming language to be in for game programming as for greater than 80% of the games at the time were created using C++.

AAA Games are also written by massive teams with a deep skillset in the language and associated frameworks, which makes C++ realistic to use. Most independent games are written in other languages which are more tenable for single programmers, (even if they are seeing somebody). Otherwise it is doable for simpler game ideas and/or more experienced C++ programmers.

It's also not the only cross-platform language. Even C# can be run on Linux and OSX; I had my Arkanoid Clone running on Linux through Mono, with only a few changes despite never writing it for Linux.

Quote
Regarding the use of the shared text file... yes that is an odd way to slap it together and make it work. Not complex but very different, and not a method that would make any sense if designed to be distributed etc. WoW uses databases for keeping track of everything which is the best method especially with at one point 10 million copies sold and probably half that active users.
WOW uses databases in the back end, but Clients communicate with the Server entirely using sockets, not with shared network drives. For a simple game a Peer-to-peer network connection would probably be best.
1443.

Solve : can someone tell me what this is??

Answer»

found this in my folders section:



-http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"&GT;






-

ms-resource:DisplayName

ms-resource:PublisherDisplayName

Assets\StoreLogo.png




-






-






-


-


-










-


- r">


-




AccountsControlUI.dll

lTypeInfo.XamlMetaDataProvider"/>




lFrame"/>

lFrameBase"/>





del"/>

ewModel"/>




ew_FixHassles"/>



ew_FixHassles"/>

rovalView"/>






iesBase"/>

untModel"/>

untProperties"/>

Frequency"/>

ailureEventArgs"/>

roperties"/>

equest"/>

equestManager"/>

uccessEventArgs"/>

ompletedEventArgs"/>

overyProperties"/>

e"/>

ventArgs"/>

el"/>

countModel"/>

countProperties"/>

ailHistoryAge"/>

ncFrequency"/>



ryProperties"/>

l"/>

el"/>

tingsViewModel"/>

AdvancedSignInViewModel"/>

SyncSettingsViewModel"/>

wModel"/>

tHelper"/>

mmand"/>

untViewModel"/>

ordSignInViewModel"/>

thTypeDiscoveryViewModel"/>

dViewModel"/>

orViewModel"/>

hViewModel"/>

untsViewModel"/>

countDisplayProperties"/>

ailAdvancedSignInViewModel"/>

ilSyncSettingsViewModel"/>

verCertViewModel"/>

ewModel"/>

el"/>

untTypeViewModel"/>

gsViewModel"/>

gsViewModelFactory"/>

mainSignInViewModel"/>

ASE"/>

ViewModel"/>

isplayNameViewModel"/>



erUserControl"/>

PAGE"/>

cedSignInPage"/>

ettingsUserControl"/>



ightConverter"/>

lityConverter"/>

ge"/>

ressBar"/>

gnInPage"/>

eDiscoveryPage"/>



e"/>



age"/>

vancedSignInPage"/>

cSettingsUserControl"/>

rtPage"/>

nverter"/>

VisibilityConverter"/>





uthOptionsUserControl"/>



pePage"/>

onsUserControl"/>

erControl"/>

e"/>

omationNameConverter"/>

ignInPage"/>



yNamePage"/>








-













thanks for the help? lol

1444.

Solve : Starting with C++??

Answer»

Hey,

I'm looking to start maybe learning code. I'd preferably start with something like C++ and would probably start off with small commandline utilities and stuff before moving on to other things. I am using Windows 7, although also have Solus Linux and MacOS High Sierra for other things which I could also test on.

Any places I can learn online how to learn C++ and any particular tips and such that can be given about learning code in general?

Thanks,
Amy S.Microsoft has a collection tools called 'Visual Studio' that lets you pick the tool you want to learn and use. It has excellent tutorials both from Microsoft and others.
You can use it in Console mode, and the is OFTEN how you do C++ programs.
However, the visual interact is a real help while TESTING and editing a program.

It is highly recommended, even if you only want the C++ part.
An it is free for personal use.
Here is just one of many good starting pints.
Microsoft Forums, C++

And it is all over You Tube.
How to program C++ in Visual Studio.

Of course, don't believe everything on You Tube.
But you already know that .
I understand you may want to learn C++ quickly with LOTS of programming examples, with my more than 10 YEARS experience on c++ out of 25 years experience, I suggest you videos that will teach you c++ in just one DAY, after that you will be capable to understand any c++ forum / book without much efforts..

Find the link below

https://www.youtube.com/watch?v=rwtUP8ZvA-w&list=PLajSVz9ukYlyQargq36vjWlaMfTY94WA-

All the best....Enjoy learning..

1445.

Solve : File conversion to .txt file?

Answer»

Hi there everyone!

SHORT QUESTION: Is there a tool or CODE to convert a file (e.g. .EXE, .JPG, .PDF) to a .TXT file and vice versa?

LONG QUESTION: In 1997 I made a program (using Qbasic in DOS on my PC) that converted any file to ASCII (.TXT) and then encrypted it changing every character in a string and then doing other "TRANSFORMATION" (of course also vice versa). It's long time I haven't programmed and now I want to start again by making such a program (maybe using Visual Basic) but I can't find a tool to convert a normal file to ASCII. In that time a friend of mine gave me a converter (a DOS tool, something.COM) but I can't remember the name nor have I found it.
So I am asking if there is a separate program that does the conversion or if there is a code I can use in Visual Basic.

Thank you!

SalvatoreYou can't convert binary files into ASCII text.

You can create representations of the binary files contents in ASCII- by say writing the file contents as hexadecimal.Oh, thank you, that's what I needed to know...
So, if I use C, how can my program make this representation (and of course the reverse)? Is there a code to get in?
Thank you again.
SalvatoreYou read the binary program, byte by byte, and for each byte, write out its hexadecimal representation, thus, if a byte had a value of 1, you'd write 01, and if it was 255, you'd write FF. To do the reverse is trivial.



Ok, it's so clear and interesting!
Another question: every file is binary (for example, .JPG, .PDF, .EXE... even .TXT), isn't it? .
And in the file architecture, bits are organised in bytes, aren't they?
As written in first answer, what I'm doing is just to "represent" every byte in hexadecimal, am I right?
Thank you!
Salvatorecurious as to why and what benefit you get from 'converting', say, a .EXE or .JPG file to a .TXT file?
if you just want to 'look' or heaven forbid 'tweak' at the binary data why not use a hex editor?Quote from: Mark. on January 13, 2018, 01:21:57 PM

why not use a hex editor?
++1
Ok, maybe the "problem" is my 1997-Qbasic way of thinking...
So, what you all are telling me is that I can read every byte from a file (any file) and then encrypt it (that's the purpose of my project)...
And I don't need to "convert" to .TXT, as I did in 1997 with my Qbasic program...
Now I'm starting learning C and the final/update/real question (spoiler!) is: which is the C command (or the code) to read any single byte from a file to use it as a variable? And how can I do the reverse?I'm still at a loss as to WHY ?
you seem intent on re-inventing the wheel.

if this is some sort of logic problem or coding test, OK then, but there are already programs out there that will do what you want, that is, look at any sort of file at the binary (hex) level and if desired, also encrypt that file.Quote from: Mark. on January 14, 2018, 04:40:13 AM
I'm still at a loss as to WHY ?
you seem intent on re-inventing the wheel.

if this is some sort of logic problem or coding test, OK then, but there are already programs out there that will do what you want, that is, look at any sort of file at the binary (hex) level and if desired, also encrypt that file.

Ok... why? Maybe I want to re-invent the wheel... The point is that I want to start again with programming and - as a sort of exercise - I want to make again that program that I create in 1997... There is no why... I'm not a professional, it's my hobby... So, as you were saying, it's like a coding test... Where do I start? I've just started learning C, so I'll arrive to the point, but I just wanted a "spoiler". So, now I know that what I want to do is possible (even if in a different way than I thought), but I'd like to know also how.

P.S. What's "++1" above?Quote from: sal.ventre on January 14, 2018, 05:41:34 AM
P.S. What's "++1" above?
A compact way of saying "I AGREE with the above".

You would be better looking at Stack Exchange or Rosetta Code.


Code: [Select]which is the C command (or the code) to read any single byte from a file to use it as a variable? And how can I do the reverse?

It's unclear from what context you are asking this question; even in QBASIC there was no "command" (or statement) that would read a single byte from a file to a variable or the reverse. It was a series of operations that you put together.

There is loads of documentation for the C language and it's standard libraries. Generally SPEAKING, sticking to C, you'd open the file with fopen(), read from it with fread(), translate it to a hexadecimal character array using one of the formatted print functions(printf, fprintf, etc) and close the file using fclose().Quote from: BC_Programmer on January 14, 2018, 01:04:41 PM
Code: [Select]which is the C command (or the code) to read any single byte from a file to use it as a variable? And how can I do the reverse?

It's unclear from what context you are asking this question; even in QBASIC there was no "command" (or statement) that would read a single byte from a file to a variable or the reverse. It was a series of operations that you put together.

There is loads of documentation for the C language and it's standard libraries. Generally speaking, sticking to C, you'd open the file with fopen(), read from it with fread(), translate it to a hexadecimal character array using one of the formatted print functions(printf, fprintf, etc) and close the file using fclose().

Ok, thank you... This is what I needed to know... I didn't know that this was possible even in Qbasic... I'm an autodidact, so I don't know the whole theory...
1446.

Solve : Script to resize JPEG files?

Answer»

Also, if we turn out to have a professional or pro-sumer's archive of big RAW images, something doesn't add up, because these people TEND to be very conscious of storage backup and archiving issues, often choosing a large external HARD drive or NAS for this purpose. So where is this? Of course you do get "gadget guy" type people who buy a "bridge" camera or DSLR and fill up their PC's internal hard drive with huge images they don't need.

Quote from: Geek-9pm on December 31, 2017, 01:12:01 AM

The photos are tabout 2 to 7 megabytes each. How big a TV does it take to show a photo that is over 5000 pixels wide?
These aren't "huge" digital camera images. The TV will scale so you can see the whole picture.
Quote from: Geek-9pm
Have can anybody accumulate over 200 GB of JPEG photos in seven years?

Quote from: Geek-9pm
The photos are tabout 2 to 7 megabytes each

That's between 30,000 and 100,000 images. Some slide show.
Quote from: Salmon Trout on January 01, 2018, 10:22:59 AM
That's between 30,000 and 100,000 images. Some slide show.
I think the slide show is off. Unless it becomes a movie. Pardon me. I am stuck on this. Can't sleep until I know.
But I would like to know how to run any pho EDITOR from command line. Some research shows GIMP is what I should try. But I have a hard time with the massive documentation..

I just want to know how to run it from the command prompt. Or else call it from Vb-script or some kind of script.

Anybody? Please?
What did you want the photo editing software to do? Just start, or perform some kind of scripted operation?My objective is to made a batch file that would alter all the images found in a directory. Conversion from one format to another could be helpful. Orr seduction of detail or reduced color depth. Right now I am looking at photos I have collected.

I would hope that a pho editor would his kind of syntax on the command line:
photo-editor
The profile. or template, would have the parameters and a process to be performed. Such as convert to another format, or reduce the number of vertical or horizontal pixels.
GIMP is said to be able to handle calls coming from C++ or python. That would IMPLY something like a command line interface. -Right?

I did find a command line information for Format Factory, but I NEVER got it to work. So I gave up.

Any help or suggestions are appreciated.


Quote from: Geek-9pm on January 10, 2018, 02:29:00 PM
seduction of detail

Seduction of Detail is provided by a Frisky Filter...

Gimp's batch processing is done through Lisp. Or at least, it sure looks like Lisp.Quote from: Geek-9pm on January 10, 2018, 02:29:00 PM
I would hope that a pho editor would his kind of syntax on the command line:
photo-editor <input file> <profile> <output file>
The profile. or template, would have the parameters and a process to be performed. Such as convert to another format, or reduce the number of vertical or horizontal pixels.
I said it before, and I'll say it again: Image Magick (spelled thus) It has command-line options and a scripting language,

https://www.imagemagick.org/script/index.php

Code: [Select]magick convert rose.jpg rose.png
Code: [Select]magick convert rose.jpg -resize 50% rose.png
Code: [Select]magick convert -size 320x85 canvas:none -font Bookman-DemiItalic -pointsize 72 \
-draw "text 25,60 \'Magick\'" -channel RGBA -blur 0x6 -fill darkred -stroke magenta \
-draw "text 20,55 \'Magick\'" fuzzy-magick.pngThank you, Salmon Trout

No I have some reading to do and try and grasp how that works. It seems that either GIMP or Image Magick will do the work.
Well, it was just too much for me. I don't understand it.
So, I did some looking around and found...
Factory Image Converter.
The command line syntax was so simple that even I could understand it. After about three hours. Basically it is just source, target, options. Works great!
1447.

Solve : Error when posting?

Answer»

I post here because is a complicate problem and i really ill be happy to have a solution. So, when i try to comment (not to share on my wall) on facebook to someone with a youtube link is ok, but when i add one more comment with a youtube link, this is marked as spam. This not hapened before. With normal words can add how many comments i want but with youtube links cant add more than 2-3 comments. I heard they updated the algoritms, dont know... they are so smart if a simple youtube comment is blocked......... I tried on other pc, same problem... sometimes, when i change the browser, i can post but only one more, because the spam message appear again.
I found on internet sugestions, but not really about what i want: https://www.youtube.com/watch?v=d2MFWzm3Wl8 and see in picture attachement what i got, but this didnt really worked

So is a way to avoid this spam when there is no spam? something in REGISTRY, in host, in browsers options?

can someone comment on facebook on someone with 2-3 youtube links to test? if you dont find someone or dont want to DISTURB can try this inactive user https://www.facebook.com/profile.php?id=100013738830613 Thanks

[attachment deleted by admin to conserve space]You are spamming, by definition (What do you think POSTING 2/3 comments on the same post with youtube links is?) So it blocks you.

This is SERVER side.Thanks, oh, you beginner) but i said this didnt hapened before.. and i want to know how to avoid the thing, for example i saw login in other browser is working, but only for one more comment. Youtube is a safe site and should not be marked as spam after only 2 comments, but they dont care about most USED site in this worldI have found here https://www.facebook.com/help/community/question/?id=10154278072908220
this: https://developers.facebook.com/tools/debug/sharing but dont know what to do there or if can report to facebook, so they can see how smart are

1448.

Solve : Can NOT put Visual Studio Express on WIndsows XP.?

Answer»

Is this true?
I am sure a time past Visual Express did work on my XP machine.
Recently I did install XP all over again. Just now I tried to install Visual Studio 2012 and it bailed. So I tried the Visual Express 2010 and is stalls.

Somewhere I read that Visual Studio 2013 will work on Windows XP.
https://www.visualstudio.com/en-us/productinfo/vs2013-compatibility-vs
I am confused.

Does anybody know what is going on ? The link covers available Platform targets, not systems that Visual Studio itself will run on. That is, you can build software with Visual Studio 2013 that is designed to run on Windows XP, but you cannot install or run Visual Studio 2013 on it.


Visual Studio 2010 is the latest version of Visual Studio that will install on Windows XP. "it stalls" doesn't give much more to work with as to why it's not installing for you.

Thanks for the quick response.
The piratical solution would be for me to develop some code in Windows 7 or 10 and then put the code on my Windows XP system.
Mab I could try an older version? I might have a 2005 in my junk box.2010 Installed fine for me on Windows XP. I expect it would require Service Pack 2.As far as older versions. Microsoft removed the ability to get legacy versions direct from them and they push people to USE the latest and they have the community free edition kind of hidden in an attempt to get people to buy the professional edition. This link is where you will end up when looking for it at their site direct. https://www.microsoft.com/en-us/store/b/visualstudio?

I have a book that is for Visual Studio Express 2008 and the DVD in the back of the book is where I got my offline installer edition of 2008 from. If you have any books for 2005 that have a disc in the back of them you might find it on there. Usually I am bad at putting the discs back into the back page sleeve of books and I lucked out the day that i needed 2008.

This link here is the path to the free community edition, but its the latest editions and not the legacy.
https://www.visualstudio.com/vs/community/


This book here is where I got my 2008 offline installer Visual Studio 2008 Express edition from: https://www.ebay.com/itm/Build-A-Program-Now-Microsoft-Visual-C-2008-Express-Edition-with-Disc-NEW/263243797958?epid=1603102699&hash=item3d4a8d95c6:g:FG4AAOSwR29ZG8x0

Looking on ebay there is a 2005 edition of the book that i have that might have Visual Studio 2005 Express on its disc that comes with book. https://www.ebay.com/itm/Microsoft-Visual-C-2005-Build-a-Program-Now-by-Patrice-Pelland/142184137651?epid=47767230&hash=item211ad5c3b3:g:NCYAAOSwH3haERnRIt sounds like GEEK already has the install media for the PREVIOUS releases to me. The 2010 that they have should be able to install, too, and I expect what might be causing it to "stall" may very well affect attempts to install 2008,2005, or 2003.Quote from: BC_Programmer on January 17, 2018, 03:05:25 PM

It sounds like Geek already has the install media for the previous releases to me. The 2010 that they have should be able to install, too, and I expect what might be causing it to "stall" may very well affect attempts to install 2008,2005, or 2003.
Yes, that would make sense. I will go dig up another install of XP and see if that matters. I think SOMETHING has happened to my current install of XP that blocks the setup of Visual Express from the CD. I will come bank later after I do an experiment.
OK, I was wrong. Visual Studio 2010 install on Windows XP SP3 with updates.
I just tried it on a install of XP SP3 that I had done a few weeks ago. The only issue was a hardware error with my DVD drive. After doing a workaround, Vistula Studio 2010 installed nicely.

Thanks for your suggestions.

EDIT: For any newbies out there, Visual Studio is great for students who want to explore the prospect to becoming a computer programmer. The Internet has lots of free tutorials for the different parts of the free Microsoft package. It is not limited to just Windows. The current version can do some things for Android and Linux.
Look here:
https://www.visualstudio.com/en-us/productinfo/vs2017-compatibility-vs
Quote
Developing apps for Windows
Developing apps for Android
Developing apps for iOS
Developing apps for Linux
Developing apps for macOS
Developing apps for other technologies and platforms
1449.

Solve : Tips for starting python??

Answer»

Hello! This is my first topic so yeah.

Anyway, I was wondering what tips anyone might have for someone just starting python? Like what are the best programs to use and what do I NEED to start.



Thanks!
You can WRITE code with Notepad. You don't really need any "programs" except the INSTALLATION of Python on your computer. I recommend VERSION 2 SOMETHING. version 27 is the latest. There is also a version 3 family but 2 is more widespead. Just get coding and try out your efforts. You can find out just about everything you need to know using Google.

1450.

Solve : vba macro to strip metadata from pdf files?

Answer»

Hi,

I am looking to write an excel macro that will erase the metadata fields (specifically the "TITLE" field) from pdf documents. I want to paste a list of the full pathnames of multiple PDFS in column a, then run a macro to perform this OPERATION.

Thanks in advance for the help!Maybe this will help. A former coworker wrote a small macro where you would import the full pathnames into column A, run the below macro, and it would add the full FILEPATH to the "Keywords" line in the pdf metadata. This was very helpful when trying to trace extracted pdf pages back to its ORIGINAL file.

Code: [Select]Sub BrandBreakouts()
Dim PDF As CAcroPDDoc
Dim RawSet As Range
Range("A1").Select
Range(Selection, Selection.End(xlDown)).Select
Set RawSet = Selection
Set PDF = CreateObject("AcroExch.PDDoc")
For Each pth In RawSet
If PDF.Open(pth) = -1 Then
st1 = PDF.SetInfo("Keywords", pth)
st2 = PDF.Save(PDSaveCollectGarbage, pth)
PDF.Close
End If
Next pth

End Sub
I just want to clear the title field, rather than add anything. Thanks again!Would have thought finding info about Acrobat objects would have been simple. Guess again!

Code: [Select]st1 = PDF.SetInfo("Title", "")

If VBA has a constant literal for nulls use that instead of ""

Citation Do a search for Winbatch Articles

Happy Days Once again Sidewinder, you're the best! Thank you! Hallo!
When I began to step in your Subroutine in my MS VBA 7 in MS Excel 2010 I received error "User-defined type not defined" on declaration "Dim PDF As CAcroPDDoc". Is there missing any library in VBA?
In my VBA for Excel, I need to get property "Title" from "PDF information" sheet from PDF file located on my computer.
Thanks.