forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


A Few Small coding conundrums

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
Seffyroff
Newbie


Joined: 08 Apr 2002
Posts: 15

PostPosted: Mon Apr 08, 2002 5:14 pm    Post subject: A Few Small coding conundrums Reply with quote

Folks,

I've tried for most of today to figure these out, can anyone offer advice?
I know some of these things are fairly specific..

1> Is it possible to pass parameters to subroutines, like in certain BASIC languages? ie 'gosub mysub(myoption1,myoption2)'

2> How can I dump the contents of a list box out to a text file?

3> Is there any way to get the output of a commandline program that is being run, and display it (within a list box?)
Back to top
View user's profile Send private message
Dr. Dread
Professional Member
Professional Member


Joined: 03 Aug 2001
Posts: 1065
Location: Copenhagen, Denmark

PostPosted: Mon Apr 08, 2002 5:55 pm    Post subject: Re: A Few Small coding conundrums Reply with quote

Quote:
1> Is it possible to pass parameters to subroutines, like in certain
BASIC languages? ie 'gosub mysub(myoption1,myoption2)'

No, you cannot do it in this way. But you can of course put your
parameters in variables and just use those variables in your subroutines.

Quote:
2> How can I dump the contents of a list box out to a text file?

Use a command such as:
LIST SAVEFILE,yourlist,output.txt


Quote:
3> Is there any way to get the output of a commandline program that is being run
and display it (within a list box?)

One way is to direct the output of your command line program to a file and then load this file into
your list. Like this:
RUN ping.exe www.winzip.com > ping-out.txt
LIST LOADFILE,yourlist,ping-out.txt

Greetz
Dr. Dread

_________________
~~ Alcohol and calculus don't mix... Don't drink and derive! ~~

String.DLL * advanced string processing
Back to top
View user's profile Send private message
Seffyroff
Newbie


Joined: 08 Apr 2002
Posts: 15

PostPosted: Mon Apr 08, 2002 6:18 pm    Post subject: Re: A Few Small coding conundrums Reply with quote

Thanks dread!

Sorry, some of those questions were a little obvious. I figured out the list to file one shortly after posting.. i'll try to look more thoroughly before posting again.

Thanks again.
Back to top
View user's profile Send private message
Dr. Dread
Professional Member
Professional Member


Joined: 03 Aug 2001
Posts: 1065
Location: Copenhagen, Denmark

PostPosted: Mon Apr 08, 2002 6:34 pm    Post subject: Reply with quote

Don't worry about it - just go ahead and ask if you cannot figure out something.
This is a very well-mannered forum; you'll see no RTFM answers here, I think.

Have a nice day.

Dread

_________________
~~ Alcohol and calculus don't mix... Don't drink and derive! ~~

String.DLL * advanced string processing
Back to top
View user's profile Send private message
Garrett
Moderator Team


Joined: 04 Oct 2001
Posts: 2149
Location: A House

PostPosted: Wed Apr 10, 2002 12:57 am    Post subject: Reply with quote

The only stupid question is the one not asked.

Everyone here remembers what it's like starting out with a new programming language, so we understand what you are going through right now.

The only thing that's not tolerated here, and you will get someone all over you for this.... Is if you get lazy and try to get others to do something that you should do yourself.


-Garrett

_________________
'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.)
Back to top
View user's profile Send private message
Seffyroff
Newbie


Joined: 08 Apr 2002
Posts: 15

PostPosted: Wed Apr 10, 2002 5:19 pm    Post subject: Reply with quote

I'm having real problems displaying the output of a program in a list window. This is what i'm doing:
I have an output window which is a list. Various messages are displayed here whilst the program is running. During program execution I call a number of commandline tools, and pipe their output to text files. after each commandline tool has finished, I want to add the contents of the piped text file to my list window, without overwriting the information already in it.

The nearest i've gotten to having this working is by having it overwriting the existing messages in the list with the contents of the text file (LIST ASSIGN). LIST ADD doesn't appear to work.

here's what i'm up to anyways:

Code:
:TARGSout
     LIST CREATE, 6
     LIST LOADFILE,6,c:\targs-out.txt
     REPEAT
       LIST ADD,OutputWindow,@NEXT(6)
      gosub scrollwindow
     UNTIL @NOT(@OK())
     LIST ADD, OutputWindow, @DLGTEXT(6)
    LIST CLOSE, 6
     Exit

the subroutine scrollwindow makes sure the window keeps up with the messages appearing in it, and looks like this:
Code:

:scrollwindow
     rem move window focus to most recent item
     DIALOG FOCUS, OutputWindow
     IF @GREATER(@COUNT(OutputWindow))
        LIST SEEK, OutputWindow, @PRED(@COUNT(OutputWindow))
     END
     Exit


This gets stuck in an infinite loop and scrolls the window down indefinitely. not sure wether its getting stuck in scrollwindow or in the text file displayer. I'm wondering if the OK value is getting set wrong by the scroll subroutine before returning to the rest of the text file displayer. Any ideas anyone? If you need to see more of the code i'll post it.
Back to top
View user's profile Send private message
Dr. Dread
Professional Member
Professional Member


Joined: 03 Aug 2001
Posts: 1065
Location: Copenhagen, Denmark

PostPosted: Wed Apr 10, 2002 5:50 pm    Post subject: Reply with quote

I see one error:
Code:
IF @GREATER(@COUNT(OutputWindow))

The second compare value is missing, you should have something like this:
Code:
IF @GREATER(@COUNT(OutputWindow),0)


If you want to see where your program starts looping, try to use the VDS editor's
'debug script' button which will highlight the active line of your script while running
and so you will be able to see it working. If it is too fast for you try to put in a few
WAIT commands in strategic places.

Greetz
Dr. Dread

_________________
~~ Alcohol and calculus don't mix... Don't drink and derive! ~~

String.DLL * advanced string processing
Back to top
View user's profile Send private message
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Wed Apr 10, 2002 7:21 pm    Post subject: Reply with quote

__________________________________________________________________________________________________________________________
Try this approach (I've had some problems with @next() in loops).
This also eliminates having a separate scroll routine.

I'm not real sure, but I don't think you need the DIALOG FOCUS
command. If you need it, remove the "rem", otherwise remove
the whole line.

Also, if you're reading each line as it loads, you might want a WAIT
or WAIT ".5", etc. inserted in the loop...
Code:

rem -- I'd create this list at the start of the program, and just clear
rem -- it each time (especially if you constantly use it).
LIST CREATE, 6

:TARGSout
  LIST LOADFILE,6,c:\targs-out.txt
  if @greater(@count(6), 0)
     %x = 0
     REPEAT
       LIST ADD,OutputWindow, @item(6, %x)
       rem DIALOG FOCUS, OutputWindow
       LIST SEEK, OutputWindow, @pred(@count(OutputWindow))
       %x = @succ(%x)
     UNTIL @equal(%x, @count(6))
     LIST CLEAR, 6
  end
  Exit

_________________
VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group