From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.1 required=5.0 tests=BAYES_05,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,2004443f45ecdf56,start X-Google-Attributes: gid103376,public From: EMANUELE COSTA Subject: Wvsprintf in Ada Date: 1996/04/09 Message-ID: #1/1 X-Deja-AN: 146574456 sender: Ada programming language comments: Gated by NETNEWS@AUVM.AMERICAN.EDU content-type: TEXT/PLAIN; charset=US-ASCII mime-version: 1.0 newsgroups: comp.lang.ada Date: 1996-04-09T00:00:00+00:00 List-Id: Hello everybody, I'm trying to convert the programs which appear in the book "Programming Windows" by Peztold from C to Ada, and I've encountered a curious problem with the use of the Win32 api function Wvsprintf. Actually the function is supported within the Alsys Activada compiler throughout the call to the pragma CALL_IN, but it doesn't seem to work in the same way as the C function does. Here is an example: if we had the following code in C: short nLength; char szBuffer[40]; nLength = wvsprintf(szBuffer,"The sum of %d and %d is %d", nA,nB,nA+nB); Textout(hdc,x,y,szBuffer,nLength); and we wrote down the following Ada code: nLength : integer; szBuffer1 : string(1..100); szBuffer2 : constant string := "The sum of %d and %d is %d" & ascii.null; nLength:=wvsprintf(szBuffer1'address,szBuffer2'address,nA,nB,nA+nB); Textout(hdc,x,y,szBuffer1,nLength); we 'll finished with this compiling time error: No Valid prefix is compatible with this list of indexes or of parameters. The unique solution I've worked out so far is to declare an array to store all the integers I need to perform the sum, and assuming that all the numbers will be stored in adjacent memory locations we have got the following code: nLength : integer; szBuffer1 : string(1..100); szBuffer2 : constant string := "The sum of %d and %d is %d" & ascii.null; type number is array (1..3) of integers; sum_numbers : number; sum_numbers(1) := 2; sum_numbers(2) := 3; sum_numbers(3) := sum_numbers(1) + sum_numbers(2); nLength:=wvsprintf(szBuffer1'address,szBuffer2'address,sum_numbers' address); Textout(hdc,x,y,szBuffer1,nLength); and peculiarly enough the program seems to work fine and at the end a window is displayed on the screen with the correct output. The only thing is that the whole procedure looks quite clumsy, so I would like to know if there is someone who can help me and perhaps suggest a better solution to this problem. Thanks a lot EMANUELE COSTA ====================== Emanuele Costa Pendle College Lancaster University costa@unix.lancs.ac.uk ======================