5

I am running a Fenuc Karel robot for a class assignment which uses a variation of Pascal however our robot is from 1991-1993 before they added random(). Does anyone know how to get a random number on an old dos implementation of Pascal? Please note because of the age variable names can't be more than 8 characters and numbers can't count past 255

HDeffo
  • 51
  • 1
  • Being dos is no reason for not having Random. If you want a better answer state your exact implementation. Many will have non standard verrsions. In an total emergency, you can use the Mersenne Twister implementation of Free Pascal. – Marco van de Voort Jan 29 '15 at 19:35
  • I already stated which version of pascal it is as close as I can get you is 1991-1993 KAREL which is a variation of pascal created by FANUC for use in their industry robots. It does not have random as a predefined routine. – HDeffo Jan 30 '15 at 17:22

1 Answers1

1

If it is a borland pascal version, you can use asm { … } blocks, which would allow you to get a value from the RTC, which is sufficiently random for many intents and purposes. Given a variable random:

asm {
  xor ax, ax;
  int 1ah;
  mv random, al;
}

This would give you the last 8 bit of the real time clock value.

Apart from that you could look for pseudorandom number generation on old machines, e.g. C64; though you'd have to port the code to pascal.

Update: It appears, Fanuc Karel (I hope this is it) has a GET_TIME routine, though I'm unsure about what that returns.

llogiq
  • 13,815
  • 8
  • 40
  • 72
  • Being FENUC KAREL and a variation of pascal functions are not supported and instead it uses routines. There are very few predefined routines and I am not aware of one that can get the current clock. If you know of a routine to get the clock in FENUC KAREL this would be a perfect method. – HDeffo Jan 30 '15 at 19:42