Dos "Hello World" Crash [ No I'm not insanie ]

Just starting out? Need help? Post your questions and find answers here.
User avatar
Inner
PureBasic Expert
PureBasic Expert
Posts: 714
Joined: Fri Apr 25, 2003 4:47 pm
Location: New Zealand

Dos "Hello World" Crash [ No I'm not insanie ]

Post by Inner »

Code: Select all

PrintN("Hello World")
Compile as a "/Console" application

Open MS-Dos window, execute the resulting executable.

And

"Unhandled exception in bumprev.exe: 0xC0000094: Integer Divide by Zero"

004015AB mov si,word ptr ds:[40306Ah]
004015B2 mov ax,[0040306C]
004015B8 mov cx,word ptr ds:[403066h]
004015BF mul ax,cx
004015C2 add ax,si
004015C5 add ax,di
>>>>004015C8 div al,cl
004015CA mov [0040306C],al
004015CF mov byte ptr ds:[40306Ah],ah
004015D5 push dword ptr ds:[40306Ah]
004015DB push dword ptr ds:[403062h]
004015E1 call 00401A60
004015E6 pop esi

x86 Asm means gibberish to me, 64k asm well I'd have a chance with that, but I guess someone would know what all that means, came from MS-VC++ 6.0
Last edited by Inner on Sat May 17, 2003 3:58 pm, edited 1 time in total.
Henrik
Enthusiast
Enthusiast
Posts: 404
Joined: Sat Apr 26, 2003 5:08 pm
Location: Denmark

Post by Henrik »

Hi Inner
Did you use OpenConsole() and CloseConsole() :?:

Edited: Hmm. Sorry better show an Example.

Code: Select all

If OpenConsole()
    PrintN("Hello World ")
    PrintN("")
    Print("Press return to exit the World!")
    Input()
    CloseConsole()
EndIf
End
Bedst Regards
Henrik.
Last edited by Henrik on Sat May 17, 2003 2:48 pm, edited 1 time in total.
WolfgangS
Enthusiast
Enthusiast
Posts: 174
Joined: Fri Apr 25, 2003 3:30 pm

Post by WolfgangS »

Try to open a console at first ... [;)]

Code: Select all

OpenConsole()
printn("Hello World")
delay(5000)              ; wait 5 sec.

This was also one of my first postings in this forum 1 1/2 years ago :lol:

MFG
WolfgangS
User avatar
Inner
PureBasic Expert
PureBasic Expert
Posts: 714
Joined: Fri Apr 25, 2003 4:47 pm
Location: New Zealand

Post by Inner »

Erm, no a Dos Application needs not consoleopen() command since the dos window is already opened by, CMD or command.com depending on which version of windows you have.

the printn("Hello World") should there for look like;

C:\>runme.exe
Hello World
C:\>

And not open a new window.
Henrik
Enthusiast
Enthusiast
Posts: 404
Joined: Sat Apr 26, 2003 5:08 pm
Location: Denmark

Post by Henrik »

Inner wrote:Erm, no a Dos Application needs not consoleopen() command since the dos window is already opened by, CMD or command.com depending on which version of windows you have.

the printn("Hello World") should there for look like;

C:\>runme.exe
Hello World
C:\>

And not open a new window.
It Dose'nt open a new window if you run it from the the Prompt C:\runme.exe.
An output of my example from the ms-dos prompt

Code: Select all

Microsoft(R) Windows 98
   (C)Copyright Microsoft Corp 1981-1999.

C:\WINDOWS>cd..

C:\>cd programmer

C:\Programmer>cd..

C:\>cd pbtest

C:\PBTEST>ex.exe

C:\PBTEST>ex.exe
Hello World

Press return to exit the World!
C:\PBTEST>
freak
PureBasic Team
PureBasic Team
Posts: 5948
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

Yes, OpenConsole() is always needed, even if executed from the Command prompt. PB will automatically use the allready open console,
if executed from the command prompt.

OpenConsole() is needed to intialize the Output stuff i guess.

Timo

BTW: I moved this to 'Beginners' as it is no Bug.
quidquid Latine dictum sit altum videtur
User avatar
Inner
PureBasic Expert
PureBasic Expert
Posts: 714
Joined: Fri Apr 25, 2003 4:47 pm
Location: New Zealand

Post by Inner »

Now, why is it.. that the more I code the more I think program has less to do with logic and more to do with how much of an illegal substant you've devowed. :oops: not that I do such things but still.

here was therefor my logic;

Window is already opened, no need to open a console in a console since the console is there already, and if it wasn't windows would figure I wanted a console window because this is a dos application and open the console window itself.

:idea: note to self, edit the PureBasic docs, to reflect this.

:oops: all that ramblering, thanks both of you... 8O still think openconsole shouldn't be there but it works.

8) 17 years of programming to be move to the beginniners forum !!! AAAHHH :lol: :oops: :oops:
User avatar
Inner
PureBasic Expert
PureBasic Expert
Posts: 714
Joined: Fri Apr 25, 2003 4:47 pm
Location: New Zealand

Post by Inner »

Code: Select all

OpenConsole()
    PrintN("Hello World")
    PrintN("Hello World") ; << CRASHES HERE
    PrintN("Hello World")
    PrintN("Hello World")
    PrintN("Hello World")
CloseConsole()
So there is a bug after all.
Henrik
Enthusiast
Enthusiast
Posts: 404
Joined: Sat Apr 26, 2003 5:08 pm
Location: Denmark

Post by Henrik »

Hi Inner :)
Not on win98 se.. What's your Os ?
Resoult of Your Exampel:

Code: Select all

Microsoft(R) Windows 98
   (C)Copyright Microsoft Corp 1981-1999.

C:\WINDOWS>cd..

C:\>cd pbtest

C:\PBTEST>inner.exe
Hello World
Hello World
Hello World
Hello World
Hello World

C:\PBTEST>
Bedst Regards
Henrik.
freak
PureBasic Team
PureBasic Team
Posts: 5948
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

Hmm, also no crash here...
(Win2k Sp3 PB3.62)

> 17 years of programming to be move to the beginniners forum !!! AAAHHH
:P

Timo
quidquid Latine dictum sit altum videtur
User avatar
Inner
PureBasic Expert
PureBasic Expert
Posts: 714
Joined: Fri Apr 25, 2003 4:47 pm
Location: New Zealand

Post by Inner »

Windows XP
DominiqueB
Enthusiast
Enthusiast
Posts: 103
Joined: Fri Apr 25, 2003 4:00 pm
Location: France

Post by DominiqueB »

hello inner,
by default, the compiler compiles to windows prog.
Did you check the compiler's otions to select it to console option ?

I use xp too, and if console d=selected the prog works well.

If the windows output is selected, a console window is quickly opend and then closed.
No crash at all... ?

Have a test.

Dominique
Dominique

Windows 10 64bits. Pure basic 32bits
Manolo
User
User
Posts: 75
Joined: Fri Apr 25, 2003 7:06 pm
Location: Spain

Post by Manolo »

Hi,
XP dont have DOS window. M$ or Billy the Kid$ forgot this implementation.
If you have one program in MS-DOS and want run in XP, please see the old mannuals of the beginers of Unix nad think in one daemon implementation.
XP is the more great "merde" from M$.
Manolo
Return to the forum
ricardo
Addict
Addict
Posts: 2438
Joined: Fri Apr 25, 2003 7:06 pm
Location: Argentina

Post by ricardo »

Inner wrote:

Code: Select all

OpenConsole()
    PrintN("Hello World")
    PrintN("Hello World") ; << CRASHES HERE
    PrintN("Hello World")
    PrintN("Hello World")
    PrintN("Hello World")
CloseConsole()
So there is a bug after all.
XP here, run your code with a bat file and there is no problem.
Run it by doubleclicking the executable and no problem too.
Run it from the IDE and no problem...

How did you tried to run it?

I think that you forget to compile it as console application
ARGENTINA WORLD CHAMPION
User avatar
Inner
PureBasic Expert
PureBasic Expert
Posts: 714
Joined: Fri Apr 25, 2003 4:47 pm
Location: New Zealand

Post by Inner »

Uhmm okay, weirder and weirder.

"C:\Program Files\PureBasic\Compilers\pbcompiler.exe" bumprev.pb /CONSOLE /EXE D:\IT\Code\PureBasic\bumprev\bumprev.exe
bumprev.exe -o foo -f bam -x furbar x y z

that is the batch file I am using to compile the application.

I don't use the IDE that comes with PB, I use ultraedit.

Manolo : yes I know slip of the (er?) type, it's called CMD these days, while I asume is called CommandLine.

There is however one thing I've noticed diferent from mine to yours, I have commandline arguments where as you do not.

Okay.... so I reboot my computer after being asleep for the night, and it works again.. now I am even more confused, okay 10mins later it happend again, closed the console down, and started a new console and ran it, it worked fine, me thinks something isn't being freed. you may have to compile run a few times to get the crash.
Post Reply