Re: [BLACKBOX] ARRAY as CONSTANT

From: Rene A. Krywult <"Rene>
Date: Wed, 13 Feb 2008 16:19:57 +0100

----boundary-LibPST-iamunique-516792021_-_-
Content-type: text/plain

You're right. 0x terminates a string. But you can, of course, do something like this:

InitString("00 00 00 61 00 00 00 00");

or:

MODULE PrivShow;
IMPORT StdLog,Strings;

PROCEDURE InitString (a: ARRAY OF CHAR);
BEGIN
        StdLog.String(a)
END InitString;
 
PROCEDURE I2S(x:INTEGER):POINTER TO ARRAY OF CHAR;
VAR string:POINTER TO ARRAY OF CHAR;
BEGIN
        NEW(string,17);
        Strings.IntToStringForm(x,Strings.hexadecimal,2,"0",FALSE,string);
        string^ := string^$ + " ";
        RETURN string;
        
END I2S;

PROCEDURE Do*;
BEGIN
         InitString(I2S(0) + I2S(0) + I2S(0) + I2S(0) + I2S(ORD("a")) + I2S(0) + I2S(0))
END Do;

BEGIN
END PrivShow.

Of course, you would have to do a POINTER TO ARRAY OF BYTE and write a short conversion from hex to this array afterwards.

Rene

-------- Original-Nachricht --------
> Datum: Wed, 13 Feb 2008 12:38:13 +0200
> Von: "Oleg N. Cher" <allot{([at]})nowhere.xy
> An: BLACKBOX{([at]})nowhere.xy
> Betreff: Re: [BLACKBOX] ARRAY as CONSTANT

> Dear igor,
>
> >You can put your data into strings.

>
> Yes, you're RIGHT.
> But BB compiler does not allow to put binary data
> (concretely symbol 0X) into a string. Please check:
>
> MODULE Show;
> IMPORT StdLog;
>
> PROCEDURE InitString (a: ARRAY OF SHORTCHAR);
> BEGIN
> StdLog.Int(LEN(a))
> END InitString;
>
> PROCEDURE Do*;
> BEGIN
> InitString(0X + 0X + 0X + "a" + 0X + 0X)
> (* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Length of this string is 2
> We checks LEN(a), not LEN(a$) ! *)
> END Do;
>
> BEGIN
> END Show.
>
> >
> Symbol 0X simply ignored by compiler.
> And I did a conclusion that all strings in BlackBox
> are null-terminated, and cannot contain superfluous nulls.
> It means we never can save binary information into strings.
>
>
> Oleg N. Cher,
> Colossoft Research.
> allot{([at]})nowhere.xy
> 2008-02-13
>
>
> ----
> To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to
> LISTSERV{([at]})nowhere.xy

-- 
GMX FreeMail: 1 GB Postfach, 5 E-Mail-Adressen, 10 Free SMS.
Alle Infos und kostenlose Anmeldung: http://www.gmx.net/de/go/freemail
----
To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to LISTSERV{([at]})nowhere.xy----boundary-LibPST-iamunique-516792021_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"
e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJvbXRleHQgXGRlZmYwe1xmb250dGJsDQp7XGYwXGZz
d2lzcyBBcmlhbDt9DQp7XGYxXGZtb2Rlcm4gQ291cmllciBOZXc7fQ0Ke1xmMlxmbmlsXGZjaGFy
c2V0MiBTeW1ib2w7fQ0Ke1xmM1xmbW9kZXJuXGZjaGFyc2V0MCBDb3VyaWVyIE5ldzt9fQ0Ke1xj
b2xvcnRibFxyZWQwXGdyZWVuMFxibHVlMDtccmVkMFxncmVlbjBcYmx1ZTI1NTt9DQpcdWMxXHBh
cmRccGxhaW5cZGVmdGFiMzYwIFxmMFxmczIwIFlvdSdyZSByaWdodC4gMHggdGVybWluYXRlcyBh
IHN0cmluZy4gQnV0IHlvdSBjYW4sIG9mIGNvdXJzZSwgZG8gc29tZXRoaW5nIGxpa2UgdGhpczpc
cGFyDQpccGFyDQpJbml0U3RyaW5nKCIwMCAwMCAwMCA2MSAwMCAwMCAwMCAwMCIpO1xwYXINClxw
YXINCm9yOlxwYXINClxwYXINCk1PRFVMRSBQcml2U2hvdztccGFyDQpJTVBPUlQgU3RkTG9nLFN0
cmluZ3M7XHBhcg0KXHBhcg0KUFJPQ0VEVVJFIEluaXRTdHJpbmcgKGE6IEFSUkFZIE9GIENIQVIp
O1xwYXINCkJFR0lOXHBhcg0KXHRhYi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