10 June 2018, 09:45 | #121 |
Banana
Join Date: Jul 2016
Location: Darmstadt
Posts: 1,217
|
Yes, it is definitely possible. The question is how... In c I'd create an array of function pointers and call those.
Ultimately its just an array of memory addresses which you jump to. I think this is what you want Code:
On Expression Goto|Gosub Program Label[,Program Label...] On allows a program to branch, via either a Goto or a Gosub, to one of a number of Program Labels depending upon the result of the specified Expression. If the specified Expression results in a 1, then the first Program Label will be branched to. A result of 2 will cause the second Program Label to be branched to and so on. If the result of Expression is less than one, or not enough Program Labels are supplied, program flow will continue without a branch. |
10 June 2018, 17:39 | #122 |
Warhasneverbeensomuchfun
Join Date: Jun 2001
Location: Rio de Janeiro / Brazil
Age: 41
Posts: 3,450
|
OH MY GOD.
I remember when I coded on MSX Basic there was this EXACT command and I had completely forgot about it. Yes, found this on the manual. Somehow I believe that, performance-wise, this will be just like doing a select...case . I'll have to test speed of this to see if it's faster than doing a few ifs on a tree strcuture. Thank you a lot! |
11 June 2018, 00:27 | #123 |
Warhasneverbeensomuchfun
Join Date: Jun 2001
Location: Rio de Janeiro / Brazil
Age: 41
Posts: 3,450
|
Ok, I've made a few tests.
Select..Case seems to be just a series of If..else one after the other. If the first "case" is the right one, it executes faster than the last "case" is the true one (or if there's no case at all).. it's actually a little faster than doing IFs for some reason, but not a lot faster to make a big difference unless you are doing a shitload of them (Still worth using it though - should use it more on my code) In the other hand, On..Gosub is pretty fast most of the time. If the first subroutine is the selected one it will go a little faster, but then the speed doesnt change if its the second or the thirtieth one being executed. This is *great* EDIT: Testing on REAL hardware (my 68000 A600 with 2Mb Chip Ram) gives me a lot more random results than on Winuae emulating a 040. Still, the same results more or less, On..Gosub always more or less at the same speed either the second or thirtieth option is the true one, while Select Case is a little faster when it's the first or second option, then it becomes progressively slower. On..Gosub should be used instead of Select..Case when it's viable and you are dealing with more than 5 possibilities. When the right option was the 5th one or before that one, sometimes Select..Case is faster, sometimes On..Gosub is faster (like I said, it's weirdly too random), but from the 6th possibility onwards, On..Gosub is always faster. So, when using Select Case, always try to have the more common possibility before the less common ones. Last edited by Shatterhand; 11 June 2018 at 00:51. |
11 June 2018, 00:53 | #124 |
Warhasneverbeensomuchfun
Join Date: Jun 2001
Location: Rio de Janeiro / Brazil
Age: 41
Posts: 3,450
|
NEW QUESTION.
What's the MAX value of VPOS? |
13 June 2018, 13:35 | #125 | |
Registered User
Join Date: Nov 2015
Location: Vaasa, Finland
Posts: 525
|
Quote:
|
|
19 June 2018, 12:24 | #126 |
A1200 040 SAM440EP 667
Join Date: Jan 2008
Location: Lisbon / Portugal
Posts: 873
|
When an event calls the next statement it keeps generating sequences all the time.
Is there a easy way to make the statement generate only one sequence and then stop generating more? Code:
Statement rndKey{} alpha$="ABCDEFGHIJKLMNOPQRSTYUVWXZabcdefghijklmnopqrstyuvwxz#/+=0123456789" Dim s$(Len(alpha$)) Dim p$(20) For x=0 To Len(alpha$) s$(x)=Mid$(alpha$,x,1) Next For i=0 To 19 p$(i)=s$(Rnd(66)) pass$=pass$+ p$(i) Next MUISet 3, #MUIA_ShowMe, 1 : MUISetString 3, "Generated key> "+pass$ End Statement |
19 June 2018, 12:34 | #127 |
Registered User
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,379
|
Do you mean, only generate a pass$ string once, then keep them for the rest of the program's run? You need to make the pass$ variable global, then check if the string contains any characters, and only generate the random characters if it doesn't. Something like this:
Code:
pass$ = "" Statement rndKey{} SHARED pass$ If pass$ = "" alpha$="ABCDEFGHIJKLMNOPQRSTYUVWXZabcdefghijklmnopqrstyuvwxz#/+=0123456789" Dim s$(Len(alpha$)) Dim p$(20) For x=0 To Len(alpha$) s$(x)=Mid$(alpha$,x,1) Next For i=0 To 19 p$(i)=s$(Rnd(66)) pass$=pass$+ p$(i) Next End If MUISet 3, #MUIA_ShowMe, 1 : MUISetString 3, "Generated key> "+pass$ End Statement |
19 June 2018, 21:13 | #128 |
A1200 040 SAM440EP 667
Join Date: Jan 2008
Location: Lisbon / Portugal
Posts: 873
|
Hi Daedalus, thanks for your help again.
I mean "freeze" the statement and keep the 1st pass$ until a MUICycle is changed. I want to keep the pass$ to the rest of the program, but as the statement will be selected by a MUICycle gadget (outside statement), the statement will keep generating new pass$´s while the cycle gadget where keeped in the same choice. That will be slowing down the computer and, when showing a MUIString with the pass$ inside the statement it will be mutating all the time. |
19 June 2018, 23:04 | #129 |
Registered User
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,379
|
Well, I think my suggestion might be what you're looking for in that case. It will only run the generation code the first time it's needed.
|
19 June 2018, 23:51 | #130 |
A1200 040 SAM440EP 667
Join Date: Jan 2008
Location: Lisbon / Portugal
Posts: 873
|
If you run this code (including already your suggestion), and change the MUICycle and go to see the console output you will see that the statement generates many passwords.
Anyway, I think your suggestion it´s the best bet, thanks Code:
optimize 7 ; Set some application properties MUIApplicationTitle "3ncrYptor" MUIApplicationDescription "MUI encrypter/Decrypter program" pass$="" Statement rndKey{} SHARED pass$ alpha$="ABCDEFGHIJKLMNOPQRSTYUVWXZabcdefghijklmnopqrstyuvwxz#/+=0123456789" Dim s$(Len(alpha$)) Dim p$(20) For x=0 To Len(alpha$) s$(x)=Mid$(alpha$,x,1) Next For i=0 To 19 p$(i)=s$(Rnd(66)) pass$=pass$+ p$(i) Next MUISet 3, #MUIA_ShowMe, 1 : MUISetString 3, "Generated key> "+pass$ NPrint pass$ End Statement Statement noRnd{} MUISet 2, #MUIA_ShowMe, 1 : teste$=MUIGetString$(2) ; MUIFreeObject 3 End Statement success.l=0 myChoice.l=False cy.l=0 ;NoCli WBStartup FindScreen 0 Dim PageName$(2) PageName$(0)="3ncrYpter" PageName$(1)="d3crypt3r" MUILabel 0,"Generate a random key?",#MUIO_Label_DoubleFrame MUICycle 1,"Rnd key","Yes","No" MUIString 2,"Enter key",10 : MUISet 2, #MUIA_ShowMe, 0 MUIString 3,"",37 : MUISet 3, #MUIA_ShowMe, 0 MUIHSpace 4,60 MUIAddObjsHGroup 6,0,1 MUICreateHGroup 6 MUIAddObjsHGroup 7,2,3,4 MUICreateHGroup 7 MUIAddObjsVGroup 8,6,7 MUICreateVGroup 8 MUIAddObjsPage 10,8 MUICreatePage 10,"3ncrYpt3r","d3crYpt3r" MUICreateWindow 11,"crYpt3r","PAGE",10 MUIAddSubWindow 11 If MUICreateApplication <> True Then End MUINotifyApp 11,#MUIA_Window_CloseRequest,1,-11 success=MUIOpenWindow(11) Repeat ev.l=MUIWaitEvent Select ev Case myChoice cy=MUIGetCycle(1) If cy=1 Then rndKey{} If cy=2 Then noRnd{} End Select Until ev=-11 MUICloseWindow 11 End |
20 June 2018, 00:35 | #131 |
Banana
Join Date: Jul 2016
Location: Darmstadt
Posts: 1,217
|
Code:
PaletteRange Palette#,StartCol,EndCol,r0,g0,b0,r1,g1,b1 PaletteRange creates a spread of colors within a palette. Similar to DPaint's spread function PaletteRange takes a start and end colour and creates the color tweens between them. |
20 June 2018, 00:58 | #132 |
Registered User
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,379
|
Hmmm, I was never able to get it to work either, and if you print out the palette values, you can see they haven't changed too, which means it's not just a case of the palette updates not being applied to the screen. I've written my own routine in the past too for this...
|
20 June 2018, 01:06 | #133 |
Banana
Join Date: Jul 2016
Location: Darmstadt
Posts: 1,217
|
Glad it's not just me then! I'll post my version here once I'm done with it.
Out of interest did you convert to HSV colour space? Google suggests it might give nicer colour transitions. |
20 June 2018, 01:18 | #134 |
Registered User
Join Date: Aug 2006
Location: Scunthorpe/United Kingdom
Posts: 2,087
|
|
20 June 2018, 01:20 | #135 |
Registered User
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,379
|
No, it was just a very straightforward RGB spread using floats. I dug out the code there but it's not particularly elegant since it uses other functions for actually storing the values. HSL might indeed give better results - that conversion's a little more involved of course, and I'm not sure the subtleties would be even captured on ECS with only 4 bits per gun.
|
20 June 2018, 01:44 | #136 | |
Banana
Join Date: Jul 2016
Location: Darmstadt
Posts: 1,217
|
Well some pictures are of a comet, but one has to take what one can get. Maybe phobos too if I can find a nice pic.
Quote:
|
|
20 June 2018, 12:34 | #137 |
Registered User
Join Date: Aug 2006
Location: Scunthorpe/United Kingdom
Posts: 2,087
|
|
20 June 2018, 13:03 | #138 |
Banana
Join Date: Jul 2016
Location: Darmstadt
Posts: 1,217
|
I fly interplanetary spacecraft for the European Space Agency as a day job. It's a lot like working with vintage hardware but in SPAAAAAAAAAAAAAAAAAACE
|
20 June 2018, 14:27 | #139 |
Registered User
Join Date: Aug 2006
Location: Scunthorpe/United Kingdom
Posts: 2,087
|
And here I was thinking I was mad, but no - people are actually thinking that BB is more important than this. We have a real life rocket ship pilot in our midst.
Jeez, I love this place. |
20 June 2018, 14:46 | #140 |
Registered User
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,379
|
Hehe, in my defence, I already knew about that
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Blitz basic 2 Help | Havie | Coders. Blitz Basic | 30 | 08 September 2013 09:15 |
blitz basic | petza | request.Apps | 11 | 08 April 2007 01:49 |
Blitz Basic 2 anyone? | jobro | request.Apps | 12 | 28 November 2005 18:15 |
Blitz Basic StopCD32 | Tony Landais | Coders. General | 2 | 08 May 2003 22:51 |
Blitz Basic 2 | LaundroMat | Retrogaming General Discussion | 5 | 24 July 2001 08:10 |
|
|