| View previous topic :: View next topic |
| Author |
Message |
Robert Switz Newbie
Joined: 07 Dec 2002 Posts: 6
|
Posted: Wed Mar 12, 2003 6:13 pm Post subject: VDS3.X Random Number Generator |
|
|
Can anyone help? I'm trying to get this to work off a file with out success. If you put a text file in the file Edit and click assign by file it should assign random numbers, to another file.
I've been working on it off and on for some time, I've had it working befor but it would only work with 7 or less numbers in the source file or get nested too deeply error.
Any help would be greatly appreciated
Thanks Bob
| Code: |
Title Random Number Generator
REM ****** NEXT LINE MUST REMAIN**********
external vdsrnd32.dll
DIALOG CREATE,Random Number Generator,-1,0,334,160
DIALOG ADD,EDIT,seed,18,224,104,22
DIALOG ADD,RADIO,RADIO1,10,12,76,58,NUM. Digits,6 Digit|10 Digit,6 Digit,Click
DIALOG ADD,EDIT,fileh,44,224,104,22
DIALOG ADD,RADIO,RADIO2,10,92,98,58,Method,Individual|Assign by File,Individual,Click
DIALOG ADD,TEXT,TEXT1,50,200,,,File
DIALOG ADD,TEXT,RESULT,82,34,,,RANDOM
DIALOG ADD,BUTTON,Start1,124,26,64,24,&Start
DIALOG ADD,BUTTON,Cancel2,124,134,64,24,&Cancel
DIALOG ADD,TEXT,TEXT3,22,198,,,Num:
DIALOG SHOW
dialog set,seed,@datetime(snd)
%A = 3
list create,3,sorted
:Evloop
wait event
goto @event()
:Start1BUTTON
%B = 0
dialog clear,result
REM *****Create list using random number in edit as default. *****
list create,1,sorted
RANDOM @dlgtext(seed)
repeat
%X = @random(100,999)
if @not(@match(1,%X))
REM ******* if this number doesn't match list **********
list add,1,%X
%B = @succ(%B)
end
until @equal(%B,%A)
REM *****Until the number of pairs match continue ********
list seek,1,0
gosub repeatpair
%Z = %X
repeat
gosub repeatpair
REM ******* Place pairs side by side ******
%Z = %Z%X
REM ********%A was 10
REM ***** %A = 3 unless radio group 1 is clicked then equal to 5
until @equal(@index(1),%A)
REM Number of pairs = %A
list close,1
dialog set,result,%Z
goto evloop
:Cancel2BUTTON
info Good BYE
exit
:Close
info Good BYE
exit
:Radio1Click
goto change
goto evloop
:Radio2Click
Goto TESTbyfile
goto evloop
:repeatpair
rem ****was 2,4****
%X = @substr(@next(1),2,4)
if @zero(@substr(%X))
rem ****was 2,3****
%X = @substr(%X,2,3)
end
exit
:change
%A = 5
goto evloop
:TESTbyfile
%Y = @dlgtext(fileh)
If @NULL(%Y)
info Enter File and path first. @CR() EX: C:\ext.txt
goto close
end
List create,2,sorted
List loadfile,2,%Y
:fileNext
parse "%J",%K
repeat
%1 = @next(2)
Dialog set,seed,%1
goto testfileop
Until @not(@OK())
goto closefileop
end
goto testfileop
rem until @not(@ok())
rem goto evloop
:testfileop
%B = 0
dialog clear,result
REM ****** Below tests to see if list 1 previously created *******
if @equal(%2,cool)
list clear,1
list close,1
end
REM *****Create list using random number in edit as default. *****
list create,1,sorted
%2 = cool
if @null(%1)
goto closefileop
end
RANDOM @dlgtext(seed)
repeat
%X = @random(100,999)
if @not(@match(1,%X))
REM ******* in this number doesn't match list **********
list add,1,%X
%B = @succ(%B)
end
until @equal(%B,%A)
REM *****Until the number of pairs match continue ********
list seek,1,0
gosub repeatpair
%Z = %X
repeat
gosub repeatpair
REM ******* Place pairs side by side ******
%Z = %Z%X
REM ********%A was 10
REM ***** %A = 3 unless radio group 1 is clicked then equal to 5
until @equal(@index(1),%A)
REM Number of pairs = %A
List add,3,%Z
goto filenext
:closefileop
list savefile,3,c:\windows\desktop\RANDOMfile.txt
list clear,3
list close,3
info allright
end
exit
|
|
|
| Back to top |
|
 |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Wed Mar 12, 2003 6:46 pm Post subject: |
|
|
Not sure what your goal is, but when using @match() in a loop, you
should increment the pointer when a match is found, otherwise it
stays on that item:
| Code: |
REPEAT
if @match(1, "test")
if @greater(@count(1), @succ(@index(1)))
LIST SEEK, 1, @succ(@index(1))
end
end
UNTIL (whatever)
|
Maybe you could give a few more details on what the program does?
BTW, but here's a couple of threads for random stuff in pure VDS
if you're interested:
Combination letters/numbers:
http://www.vdsworld.com/forum/viewtopic.php?t=125
Numbers only:
http://www.vdsworld.com/forum/viewtopic.php?p=296&highlight=random#296
Cheers, Mac  _________________ 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 |
|
 |
Robert Switz Newbie
Joined: 07 Dec 2002 Posts: 6
|
Posted: Wed Mar 12, 2003 7:29 pm Post subject: |
|
|
What this is suppose to do is, use one file as the source.
Example
Num.txt that contains a list of numbers like
1234
1235
1236
1237
Use these numbers as a seed for the random generator, then provide a text file with the the random numbers in it called
Randomfile.txt
and these would be either 6 or 10 digit ramdom numbers. |
|
| Back to top |
|
 |
|
|
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
|
|