housen@ssc-vax.UUCP (Kevin Housen) (07/20/89)
I am a recent convert to LightSpeed Pascal. Its orders of magnitude nicer to work with compared to what I was using (Absoft Fortran). Anyway, I have a few simple questions - (1) How can I convert an integer (or longint) to a variable of type real. I sometimes want to pass integer quantities to procedures that want real arguments. In Fortran parlance, this is just float(integer). What do I do in Pascal? (2) Does LSP support conformant arrays? From what I can tell, it doesnt. I am writing some procedures which process arrays of varying length. One way is to type bigArray=array[1..aLargeNumber] of real; bigArrayPtr=^bigArray; bigArrayHandle=^bigArray; and then declare a variable of type bigArrayHandle, allocate however much space (with NewHandle) I need for the array, and then pass the handle to the procedure which processes the array. My question - Is this the standard way to pass arrays of varying length? (3) Has anyone had problems with the Backup Project utility that comes with LSP? This a.m. I was backing up my project onto a floppy. I selected the destination folder on the floppy and hit the Backup button. A system error (ID 12) occurred immediately. After I rebooted, my floppy was unreadable. Fortunately, the project on my hard disk was OK. Anyway, I reformatted the floppy and tried again and all was fine. Has this happened to anyone else? (BTW, I am running a MacII, 5Meg, 90Meg Jasmine, LSP 2.0, various INITs). (4) This is directed to Rich. In case you are looking for suggestions... Are there any plans to implement split windows in the editor? I was spoiled by this feature in Qued. Also, are there plans to embelish the list of mathematical operators (e.g. x to the y power) or functions? As I said earlier, I like LSP alot. I am just curious about the direction(s) its heading in. Thanks heaps, Kevin Housen
RADSOFT@APPLELINK.APPLE.COM (Richard Eames) (07/21/89)
In article <2806@ssc-vax.UUCP> housen@ssc-vax.UUCP (Kevin Housen) writes: > (1) How can I convert an integer (or longint) to a variable of type real. > I sometimes want to pass integer quantities to procedures that want > real arguments. In Fortran parlance, this is just float(integer). What > do I do in Pascal? This is one of those rare instances where it is easier than you can beleive: PROGRAM MyProg; VAR MyInt: integer; MyReal: Real; BEGIN MyInt:=654; MyReal:=MyInt; {This really works, trust me...even on LongInt} END. Hope that helps....don't know about the rest of your questions. ############################################## These thoughts are mine, not # "Anyltus and Meletus have the Power to # Apple Computer's. Blame me, # put me to death, but not to harm me." -- # not them. # SOCRATES # ##############################################
jpd00964@uxa.cso.uiuc.edu (07/22/89)
> I am a recent convert to LightSpeed Pascal. Its orders of magnitude > nicer to work with compared to what I was using (Absoft Fortran). > Anyway, I have a few simple questions - Better to just switch to LSC. C is much more flexable for your problems
siegel@endor.harvard.edu (Rich Siegel) (07/23/89)
In article <227700013@uxa.cso.uiuc.edu> jpd00964@uxa.cso.uiuc.edu writes: > >> I am a recent convert to LightSpeed Pascal. Its orders of magnitude >> nicer to work with compared to what I was using (Absoft Fortran). >> Anyway, I have a few simple questions - > >Better to just switch to LSC. C is much more flexable for your problems I try to be nice, most of the time, but my bogometer just went off the scale. I will agree that in some circumstances, C is a better implementation language. However, since you've done absolutely NOTHING to justify your recommendation, NOR have you made even a minimal attempt to address the problems that the earlier poster was having, I just consider your response a complete and total waste of net space, not to mention a response that is uniquely rude and unhelpful. Now: solutions to the earlier poster's problems as applied to the C programming language: integer-to-float conversions in C are done by means of an explicit typecast, as they are in Fortran: you can say "f = (float) i", and the compiler generates the appropriate code for int-to-float conversion. (On the 68881, this is pretty simple, and almost as simple using SANE.) Conformant arrays can be done in C, as well. (My C is a but rusty in this area, but I'm sure that some C god will correct my mistakes.) void foo(count, array) long count; float array[]; { }; Declaring "array" as an indefinite array of floats causes the compiler to pass the address of array[0] as an argument. The formal declaration float *array; would accomplish the same thing. You may recall that this approach is very much like passing a pointer (or handle) to a dynamic array as an argument in Pascal. The main difference is that the language offers syntactic support for the appropriate construct. The point I'm trying to make is that Pascal and C are equally suitable here; to say that "C is so much more flexible for your problems" is misleading at best, and just plain wrong, at worst. (And now that I've exceeded for my curmudgeon quota for this month, I will now become the meek and mild-mannered program that I once was.) And f'r cryin' out loud, why don't you SIGN your posting?! R. ~~~~~~~~~~~~~~~ Rich Siegel Staff Software Developer Symantec Corporation, Language Products Group Internet: siegel@endor.harvard.edu UUCP: ..harvard!endor!siegel "When it comes to my health, I think of my body as a temple - or at least a moderately well-managed Presbyterian youth center." - Emo Phillips ~~~~~~~~~~~~~~~