help on RANDOM and converting int's to strings 
Author Message
 help on RANDOM and converting int's to strings

ok i have a basic array of records setup of type string, i want to produce a
random password for my password field in the record's, how do i go about
doing this? i've tried using the help on "random" and "randseed" in Pascal
help but didnt really understand.

Also how can i add an integer to a array of records of type string?

Any help appreciated :) Thanks!

Dazz



Thu, 26 May 2005 00:27:14 GMT  
 help on RANDOM and converting int's to strings


Sat, 7 Dec 2002 16:27:14 :-

Quote:
>ok i have a basic array of records setup of type string, i want to produce a
>random password for my password field in the record's, how do i go about
>doing this? i've tried using the help on "random" and "randseed" in pascal
>help but didnt really understand.

Consider :

const Pswd : string [8] = '12345678' ;

Randomize ;
for J := 1 to 8 do
        byte(Pswd[J]) := Ord('A') + Random(26) + 32*Random(2) ;

--

  <URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/&c., FAQqy topics & links;
  <URL:http://www.merlyn.demon.co.uk/clpb-faq.txt> Pedt Scragg: c.l.p.b. mFAQ;
  <URL:ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip> Timo Salmi's Turbo Pascal FAQ.



Thu, 26 May 2005 05:46:37 GMT  
 help on RANDOM and converting int's to strings
Thank you,

any idea how i would get integers to be added to a string of arrays, the
reason i want to know is because i have a date field where i want to limit
the days/months/years to the proper values, sort of a validation, so ive got

record = date;
  day : 1..31;
  month : 1..12;
  year : 1880..2002;
end; { date }



Quote:


> Sat, 7 Dec 2002 16:27:14 :-
> >ok i have a basic array of records setup of type string, i want to
produce a
> >random password for my password field in the record's, how do i go about
> >doing this? i've tried using the help on "random" and "randseed" in
pascal
> >help but didnt really understand.

> Consider :

> const Pswd : string [8] = '12345678' ;

> Randomize ;
> for J := 1 to 8 do
>         byte(Pswd[J]) := Ord('A') + Random(26) + 32*Random(2) ;

> --

MIME. ?
>   <URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/&c., FAQqy topics &
links;
>   <URL:http://www.merlyn.demon.co.uk/clpb-faq.txt> Pedt Scragg: c.l.p.b.
mFAQ;
>   <URL:ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip> Timo Salmi's Turbo Pascal

FAQ.


Thu, 26 May 2005 18:33:34 GMT  
 help on RANDOM and converting int's to strings
Also i have an auto generatered student id, which needs to be added to the
array


Quote:
> Thank you,

> any idea how i would get integers to be added to a string of arrays, the
> reason i want to know is because i have a date field where i want to limit
> the days/months/years to the proper values, sort of a validation, so ive
got

> record = date;
>   day : 1..31;
>   month : 1..12;
>   year : 1880..2002;
> end; { date }





> > Sat, 7 Dec 2002 16:27:14 :-
> > >ok i have a basic array of records setup of type string, i want to
> produce a
> > >random password for my password field in the record's, how do i go
about
> > >doing this? i've tried using the help on "random" and "randseed" in
> pascal
> > >help but didnt really understand.

> > Consider :

> > const Pswd : string [8] = '12345678' ;

> > Randomize ;
> > for J := 1 to 8 do
> >         byte(Pswd[J]) := Ord('A') + Random(26) + 32*Random(2) ;

> > --

> MIME. ?
> >   <URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/&c., FAQqy topics &
> links;
> >   <URL:http://www.merlyn.demon.co.uk/clpb-faq.txt> Pedt Scragg: c.l.p.b.
> mFAQ;
> >   <URL:ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip> Timo Salmi's Turbo
Pascal
> FAQ.



Thu, 26 May 2005 18:39:09 GMT  
 help on RANDOM and converting int's to strings
Dazz schrieb:
Quote:
> Also i have an auto generatered student id, which needs to be added to the
> array

Do you already know that you can build an array of your own type?

Delcate like this:

type my_rec = record
                 year:1980..2099; {or similar}
                 studentID:WORD;
                 s:STRING;
               end;

var my_array:ARRAY[1..10] OF my_rec;

BEGIN
   my_array[1].studentID:=1;
   my_array[1].s:='Did you already know that I am a Student?';
END.

Greetings

Markus



Sat, 28 May 2005 02:03:36 GMT  
 help on RANDOM and converting int's to strings
i tried doing this
date = record;
  day : 1..31;
   month : 1..12;
end; { record }

student_record = record   { student record setup }
                       stu_id : m;
                       first_name : string[20];
                       surname : string[20];       { Fields in student
record }
                       sex : string[1];
                       birthday : date;
                       mother_lang : string[20];
                       foreign_lang : string[20];
                       password : string[8];
                   end; { student_record }

internal_database = array [1..max_student_number] of student_record;
 Setup of array with student records }
   external_database = text;     { external_database stored to a text file }

--------------
part of my assignment is to write the the internal database to the external
database, but when i have this "date"" thing in the record instead of
"string" it just gives me an error
e.g.

with i_dp[i] do
write(e_db,birthday)
gives error
[Error] Assignment1_3.dpr(229): Illegal type in Write/Writeln statement

because its not a string yea? because u need the array to be nothing but
strings ?

Dazz

Quote:
> Dazz schrieb:
> > Also i have an auto generatered student id, which needs to be added to
the
> > array

> Do you already know that you can build an array of your own type?

> Delcate like this:

> type my_rec = record
>                  year:1980..2099; {or similar}
>                  studentID:WORD;
>                  s:STRING;
>                end;

> var my_array:ARRAY[1..10] OF my_rec;

> BEGIN
>    my_array[1].studentID:=1;
>    my_array[1].s:='Did you already know that I am a Student?';
> END.

> Greetings

> Markus



Sat, 28 May 2005 17:39:28 GMT  
 help on RANDOM and converting int's to strings
oh i forgot to put the date record in properly
date = record
day : 1..31;
month : 1..12;
year : 1880..2002;
end; { record }

not that it makes much difference :)


Quote:
> i tried doing this
> date = record;
>   day : 1..31;
>    month : 1..12;
> end; { record }

> student_record = record   { student record setup }
>                        stu_id : m;
>                        first_name : string[20];
>                        surname : string[20];       { Fields in student
> record }
>                        sex : string[1];
>                        birthday : date;
>                        mother_lang : string[20];
>                        foreign_lang : string[20];
>                        password : string[8];
>                    end; { student_record }

> internal_database = array [1..max_student_number] of student_record;
>  Setup of array with student records }
>    external_database = text;     { external_database stored to a text
file }

> --------------
> part of my assignment is to write the the internal database to the
external
> database, but when i have this "date"" thing in the record instead of
> "string" it just gives me an error
> e.g.

> with i_dp[i] do
> write(e_db,birthday)
> gives error
> [Error] Assignment1_3.dpr(229): Illegal type in Write/Writeln statement

> because its not a string yea? because u need the array to be nothing but
> strings ?

> Dazz


> > Dazz schrieb:
> > > Also i have an auto generatered student id, which needs to be added to
> the
> > > array

> > Do you already know that you can build an array of your own type?

> > Delcate like this:

> > type my_rec = record
> >                  year:1980..2099; {or similar}
> >                  studentID:WORD;
> >                  s:STRING;
> >                end;

> > var my_array:ARRAY[1..10] OF my_rec;

> > BEGIN
> >    my_array[1].studentID:=1;
> >    my_array[1].s:='Did you already know that I am a Student?';
> > END.

> > Greetings

> > Markus



Sat, 28 May 2005 17:41:09 GMT  
 help on RANDOM and converting int's to strings
I tried what you said, and it works but take for example.
i just added a  record 1 into a array in memory,
it gives a random password.
I then add another record and it gives a different random password. Then i
save the array to e.g. txt file and exit the dos promt.
Now i run my program again and add a record into the array in memory,
the password that is given is the same as the first password when i added
other records earlier.

Any help will be gratefully appreciated.

Thanks

Dazz



Quote:


> Sat, 7 Dec 2002 16:27:14 :-
> >ok i have a basic array of records setup of type string, i want to
produce a
> >random password for my password field in the record's, how do i go about
> >doing this? i've tried using the help on "random" and "randseed" in
pascal
> >help but didnt really understand.

> Consider :

> const Pswd : string [8] = '12345678' ;

> Randomize ;
> for J := 1 to 8 do
>         byte(Pswd[J]) := Ord('A') + Random(26) + 32*Random(2) ;

> --

MIME. ?
>   <URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/&c., FAQqy topics &
links;
>   <URL:http://www.merlyn.demon.co.uk/clpb-faq.txt> Pedt Scragg: c.l.p.b.
mFAQ;
>   <URL:ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip> Timo Salmi's Turbo Pascal

FAQ.


Sat, 28 May 2005 17:54:49 GMT  
 help on RANDOM and converting int's to strings


Tue, 10 Dec 2002 09:54:49 :-

Quote:
>I tried what you said, and it works

Naturally.

Quote:
> but take for example.
>i just added a  record 1 into a array in memory,
>it gives a random password.
>I then add another record and it gives a different random password. Then i
>save the array to e.g. txt file and exit the dos promt.
>Now i run my program again and add a record into the array in memory,
>the password that is given is the same as the first password when i added
>other records earlier.

That's as it should be.  Evidently you have not read the built in Help
for Random and Randomize with care; nor Prof Timo Salmi's Turbo Pascal
FAQ.  You should do so.  You could also read my Web pas-rand.htm.

You should also read about proper quoting in News; you could learn by
example, or (better) by reading other parts of TS's site and of course
the mFAQ - in particular the paragraph with the misplaced - (currently)
and the previous one.  Otherwise your articles may be ignored by some
here.

Quote:
>Dr John Stoc
>> ... ... ... ... ... ...

--

  <URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/&c., FAQqy topics & links;
  <URL:http://www.merlyn.demon.co.uk/clpb-faq.txt> Pedt Scragg: c.l.p.b. mFAQ;
  <URL:ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip> Timo Salmi's Turbo Pascal FAQ.


Sun, 29 May 2005 04:26:06 GMT  
 
 [ 9 post ] 

 Relevant Pages 

1. convert string to int

2. convert string to int

3. Converting Bytes(?) to Int / Int to Bytes

4. Random isn't random?

5. Random isn't random?

6. How to convert strings to nul-terminated strings?

7. Help: Converting DOS Clipper DBF's to Windows DBF's

8. Help - How do I Convert a string to an object name

9. Help to convert STRING to WORD

10. Need Help Converting String to Integer

11. Help Needed - Converting String[8] to Integer Value

12. Help! How do you convert Strings to Integers

 

 
Powered by phpBB® Forum Software