String to long ?

Just starting out? Need help? Post your questions and find answers here.
colguetti
User
User
Posts: 11
Joined: Wed Feb 27, 2013 5:03 am

String to long ?

Post by colguetti »

Hi everyone, this time I´m trying to get a string from InputRequester() into RandomSeed(), but I can´t figure out how to convert complete ASCII string to ASCII values and feed that into RandomSeed()

Does anybody know a slick way of performing this task?

I guess also that the input requester should be parsed as unicode instead, just in case,

I thought of using PeekS and a pointer to a variable and PokeL and a pointer to that same variable, but I´m not sure to know how it works

Thanks in advance !!!
User avatar
flaith
Enthusiast
Enthusiast
Posts: 704
Joined: Mon Apr 25, 2005 9:28 pm
Location: $300:20 58 FC 60 - Rennes
Contact:

Re: String to long ?

Post by flaith »

Should use syntax "Asc"

Code: Select all

debug Asc("A") ;will give you ascii code 65
:?:
For a string, use this :

Code: Select all

String$ = "Your string to convert in Ascii !!!"

For i = 1 To Len(String$)
  Ascii = Asc(Mid(String$, i, 1))
  ; Put each value in a array for example
  Debug Ascii
  RandomSeed(Ascii)
  Debug Chr(Random(Ascii))
Next
“Fear is a reaction. Courage is a decision.” - WC
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3942
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: String to long ?

Post by wilbert »

colguetti wrote:Hi everyone, this time I´m trying to get a string from InputRequester() into RandomSeed()
If you want the string itself as a seed, I suggest you use the CRC32Fingerprint of the string as a seed for RandomSeed.
Windows (x64)
Raspberry Pi OS (Arm64)
colguetti
User
User
Posts: 11
Joined: Wed Feb 27, 2013 5:03 am

Re: String to long ?

Post by colguetti »

Thank you guys, I´ll try to write some code based on this approaches tomorrow, now I´m fighting with a BSP-tree like map generator,
whenever I get it to work as intended, I´ll need the seed stuff for it...

Thank you very much !!!
Post Reply