The Dink Network

Reply to Re: cannot run any version after 1.07

If you don't have an account, just leave the password field blank.
Username:
Password:
Subject:
Antispam: Enter Dink Smallwood's last name (surname) below.
Formatting: :) :( ;( :P ;) :D >( : :s :O evil cat blood
Bold font Italic font hyperlink Code tags
Message:
 
 
August 11th 2022, 02:49 PM
custom_robj.png
Robj
Jester He/Him Australia
You feed the madness, and it feeds on you. 
"Somewhat off topic but I am working on a tool that would allow us to use a single global &value to function as 31 bools or optionally for multiple small collections"

I think slipdink does something like this in Checkbit.

Also, a little different maybe to what you're creating, but I used an external function in Charlie that lets you jam multiple values in one variable(you can store, and extract), and you can pass info to tell it what base and position to store the numbers in, but it can also store 31 bools
Example using a base-2 value(boolean):

//store a bool(base-2 value) in position 1 in global variable &booleans. Store the value '1'.
external("dc-f", "svar_store", &boolean, 1, 2, 1);


//extract the value in position 1 of &booleans, and save it in &getvalue.
external("dc-f", "svar_extract", &boolean, 1, 2);
int &getvalue = &return;


Here's the store and extract procedures:
//dc-f.c

void svar_store(void)
{
  //&arg1: entire variable
  //&arg2: place (1 = far right)
  //&arg3: base (eg. 10, 100, 1000, etc)
  //&arg4: new number
  
  external("dc-f", "svar_extract", &arg1, &arg2, &arg3);
  &save_x = &return;
  
  int &total = &arg1;
  int &new = &arg4;
  &new -= &save_x;
  int &tms = &arg2;
  
svar_storeloop:
  if (&tms != 1)
  {
    &new *= &arg3;
    &tms -= 1;
    goto svar_storeloop;
  }
  
  &total += &new;
  return(&total);
}

void svar_extract(void)
{
  //&arg1: entire variable
  //&arg2: place (1=far right)
  //&arg3: base (eg. 10, 100, 1000, etc)
  
  int &tms = &arg2;
  int &rest = &arg1;
  int &value;
  
svar_extractloop:
  &value = math_mod(&rest, &arg3);
  &rest /= &arg3;
  &tms -= 1;
  
  if (&tms != 0)
  {
    goto svar_extractloop;
  }
  
  return(&value);
}


Something like this was first demonstrated by user 'Someone' I think.
I took his example and expanded on/fixed it.

EDIT:
Also you can scrap global variables altogether, if you want, when storing/retrieving values. Just use editor_seq instead. There's 99 editor sprite number slots per screen (whether the screen exists or a sprite is attached to a number does not matter, you can still store and access the editor_info, AND you can access editor info remotely, and pull info from any screen, I did that in Charlie to save globals).
Editor_seq has a MAX valid value of 65535, so you could store 16 bools in there, or even 4 base-10 values, using the above store and extract procedures.
If you dedicate one blank unused screen to editor_seq values using this method you could store/retrieve over 1400 bools, or nearly 400 base-10 values in one screen, without ever touching a global variable.