Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - eleusmario

Pages: [1] 2
1
Variable Comb(5) String
Variable amt(5) Decimal
Variable result String
Var editMask String
Var x Integer, y Integer

Font Parent.Name = "Courier"

editMask = "0000.00"

Comb(0) = "Extra";                       amt(0) = 38.06
Comb(1) = "Visa";                        amt(1) = 124.62
Comb(2) = "Car Ins";                     amt(2) = 80.59

x = 0; y = 1
While x <= 2
  Position y, 1; Write Comb(x)
  result = Format(amt(x), editMask)
  result = RemoveZeros(result)
  Position y, 20; Write result
  x++; y++
Loop
EndProgram

Function RemoveZeros(S String) String
Var C Integer, T Integer, V String

T = StrPos(S, ".") - 2
C = 1
V = SubStr(S, C, 1)
While C <= T And V = "0"
  V = SubStr(S, C, 1)
  If V = "0"; RepStr S, " ", C, 1 ; EndIf
  C++
Loop
Return S
EndFunction

2
Alternatively you can assign the value inside the loop instead of creating a timer, I think it gets better:

Code: [Select]
While 1 = 1
  If StartJaguar = 0
    KeyRight = KeyTest("39")
    KeyLeft = KeyTest("37")
    If KeyRight = "39+"
      WalkRight()
    EndIf
    If KeyLeft = "37+"
      WalkLeft()
    EndIf
    If KeyRight = "39-" Or KeyLeft = "37-"
      If IsWalking = 1; Temp++; EndIf
      If Temp = 5; StopMan(); EndIf
    EndIf

    If ColMan < 450 And ColMan > 220 And Direction = "LEFT"; LinMan++; EndIf
    If ColMan >= 220 And ColMan < 450 And Direction = "RIGHT"; LinMan--; EndIf

    If ColMan > 900
      If StartJaguar = 0
        Sound Roar.Play
        StartJaguar = 1
      EndIf
    EndIf
  Else
    AnimatedGif Jaguar.Col = ColJaguar
    AnimatedGif Jaguar.Lin = LinJaguar
    ColJaguar-=9
    If ColJaguar < 450 And ColJaguar > 220; LinJaguar+=2; EndIf   
  EndIf
   
  Label Test2.Txt=cron
  cron++                                 

  Wait Events, 350
Loop

3
Hi Daniel!

In this case you should create a timer, below the corrected code:

Code: [Select]
Var Counter Integer, CounterLin Integer, CounterCol Integer, JetHeight Integer, JetWidth Integer
Var PcHeight Integer, PcWidth Integer, PCLin Integer, PcCol Integer
Var Direction String, LinMan Integer, ColMan Integer, KeyLeft String, KeyRight String
Var IsWalking Integer, Temp Integer, ColJaguar Integer, LinJaguar Integer, StartJaguar Integer     

Var cron Integer  ''''''''''
cron = 0          ''''''''''



Window Size=48,Max, Res=750,1280, Pos=Center,Center, Border=False



'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' aqui''''''''''''''''''''''
Label Test, " informações de tempo ", 10, 700, 25, 100   
Label Test.FontName = "Arial"; Label Test.FontSize = 8
Label Test.BackColor = Yellow; Label Test.Alignment = 0
 

Label Test2, "", 10, 802, 25, 20   
Label Test.FontName = "Arial"; Label Test.FontSize = 8
Label Test.BackColor = Yellow; Label Test.Alignment = 2
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Timer Cronometro.Off
Timer Cronometro.Activate, 10

Window Background="Background04.jpg"

Sound Atmosphere01, "Atmosphere01.mp3"
Sound Atmosphere01.Loop = True
Sound Atmosphere01.Play

Sound Roar, "Roar.mp3"

AnimatedGif LeftTurn, "LeftTurn.gif"
AnimatedGif RightTurn, "RightTurn.gif"
AnimatedGif WalkingLeft, "WalkingLeft.gif"
AnimatedGif WalkingRight, "WalkingRight.gif"
AnimatedGif Block, "Block.gif"
AnimatedGif Block.Lin = 392; AnimatedGif Block.Col = 785
AnimatedGif Block.Visible = True

AnimatedGif Fire01, "Fire01.gif"
AnimatedGif Fire01.Lin = 430
AnimatedGif Fire01.Col = 430
AnimatedGif Fire01.Visible = True
AnimatedGif Fire01.Play

AnimatedGif Fire02, "Fire02.gif"
AnimatedGif Fire02.Lin = 615
AnimatedGif Fire02.Col = 680
AnimatedGif Fire02.Visible = True
AnimatedGif Fire02.Play

ColJaguar = 1500; LinJaguar = 450
AnimatedGif Jaguar, "Jaguar.gif"
AnimatedGif Jaguar.Lin = LinJaguar
AnimatedGif Jaguar.Col = ColJaguar
AnimatedGif Jaguar.Back
AnimatedGif Jaguar.Visible = True
AnimatedGif Jaguar.Play

LinMan = 460; ColMan = 600
AnimatedGif LeftTurn.Lin = LinMan; AnimatedGif LeftTurn.Col = ColMan
AnimatedGif RightTurn.Lin = LinMan; AnimatedGif RightTurn.Col = ColMan
AnimatedGif LeftTurn.Visible = True
Direction = "RIGHT": IsWalking = 0

While 1 = 1
  If StartJaguar = 0
    KeyRight = KeyTest("39")
    KeyLeft = KeyTest("37")
    If KeyRight = "39+"
      WalkRight()
    EndIf
    If KeyLeft = "37+"
      WalkLeft()
    EndIf
    If KeyRight = "39-" Or KeyLeft = "37-"
      If IsWalking = 1; Temp++; EndIf
      If Temp = 5; StopMan(); EndIf
    EndIf

    If ColMan < 450 And ColMan > 220 And Direction = "LEFT"; LinMan++; EndIf
    If ColMan >= 220 And ColMan < 450 And Direction = "RIGHT"; LinMan--; EndIf

    If ColMan > 900
      If StartJaguar = 0
        Sound Roar.Play
        StartJaguar = 1
      EndIf
    EndIf
  Else
    AnimatedGif Jaguar.Col = ColJaguar
    AnimatedGif Jaguar.Lin = LinJaguar
    ColJaguar-=9
    If ColJaguar < 450 And ColJaguar > 220; LinJaguar+=2; EndIf   
  EndIf
   
  Wait Events, 350
Loop

EndProgram

Sub StopMan()
If IsWalking = 1
  If Direction = "LEFT"
    AnimatedGif RightTurn.Lin = LinMan; AnimatedGif RightTurn.Col = ColMan
    AnimatedGif LeftTurn.Visible = False
    AnimatedGif WalkingLeft.Visible = False
    AnimatedGif WalkingRight.Visible = False
    AnimatedGif RightTurn.FrameNumber, 0
    AnimatedGif RightTurn.Visible = True
  Else
    AnimatedGif LeftTurn.Lin = LinMan; AnimatedGif LeftTurn.Col = ColMan
    AnimatedGif RightTurn.Visible = False
    AnimatedGif WalkingLeft.Visible = False
    AnimatedGif WalkingRight.Visible = False
    AnimatedGif LeftTurn.FrameNumber, 0
    AnimatedGif LeftTurn.Visible = True
  EndIf
  IsWalking = 0
EndIf
EndSub

Sub WalkRight()
AnimatedGif WalkingRight.Lin = LinMan; AnimatedGif WalkingRight.Col = ColMan
AnimatedGif LeftTurn.Visible = False
AnimatedGif RightTurn.Visible = False
AnimatedGif WalkingLeft.Visible = False
AnimatedGif WalkingRight.Visible = True
AnimatedGif WalkingRight.NextFrame
ColMan += 5
Direction = "RIGHT"; IsWalking = 1; Temp = 0
EndSub

Sub WalkLeft()
AnimatedGif WalkingLeft.Lin = LinMan; AnimatedGif WalkingLeft.Col = ColMan
AnimatedGif LeftTurn.Visible = False
AnimatedGif RightTurn.Visible = False
AnimatedGif WalkingRight.Visible = False
AnimatedGif WalkingLeft.Visible = True
AnimatedGif WalkingLeft.NextFrame
ColMan -= 5
Direction = "LEFT"; IsWalking = 1; Temp = 0
EndSub

''''''''''''' aqui''''''''''''
Sub Timer_cronometro(1)
  Label Test2.Txt=cron
  cron++                                 
EndSub
   

4
"Another Dimension" Game Project / Game explanation
« on: May 05, 2018, 07:33:26 AM »
This is a two-dimensional platform game, inspired by old games like FlashBack, Another World, Prince of Persia, and so on; the frames of the protagonist's animated gifs will be obtained from the FlashBack game sprites, which can be downloaded at the link below, so far only the gifs to walk and turn the protagonist were created:

http://www.logicbasic.net/images/FlashBack.png

This image, as well as background images, animated gifs and game sounds,  have been collected on the internet and may contain copyright, although these items have undergone modifications to adapt to the game.

The animated gifs of the protagonist were created with the software "Jasc Animation Shop" that can be downloaded at the link below:

http://www.softpedia.com/get/Multimedia/Graphic/Graphic-Editors/Animation-Shop.shtml

The animated gif of Jaguar was created based on the YouTube video that can be seen in the link below:

https://www.youtube.com/watch?v=a6yp7oldxVM

The video was downloaded on the site "SaveFromNet", then converted to animated gif on the site "Convertio", then link to those sites:

https://en.savefrom.net
https://convertio.co

With the "Animation Shop" software I reduced the animated gif and set a transparent background for all frames.

5
"Another Dimension" Game Project / Introduction
« on: May 05, 2018, 07:02:23 AM »
I launched this project for the development of an adventure game called "Another Dimension", where anyone from the Logic Basic community can participate.

The link to download the project is as follows:

http://www.logicbasic.net/download/AnotherDimension.zip

So far only the introduction of the game has been made, suggestions, bug reports, collaborations (animated gifs, backgrounds, sounds, game plot) will be well received, and anyone can make changes to the game and post in this section.

6
Apps for study and entertainment / Archimedes spiral
« on: March 12, 2018, 06:29:15 AM »
The archimedes spiral is applied in the construction of various mechanisms, such as scroll compressors, fans, centrifugal pumps, and so on. This is a rather simple and interesting example of fractal.

Code: [Select]
Var T Decimal, A Decimal, R Decimal, Xs Decimal, Ys Decimal
Var X0 Decimal, Y0 Decimal, X1 Decimal, Y1 Decimal

Window Res = 150, 250

T = 0.7 'starting point of spiral
A = 0.03 'increment size - spiral trail width
Xs = 125; Ys = 75
X0 = 0; Y0 = 0 'start point of line

While 1 = 1
  R = A * T
 
  X1 = R * Cos(T) * 50
  Y1 = R * Sin(T) * 50
  Straight Ys + Y0, Xs + X0, Ys + Y1, Xs + X1, Black
  X0 = X1; Y0 = Y1
  T = T + A
  Wait Events
Loop

7
See the Logic Basic example programs folder (C: \ Logic Basic Code), see the Customers and Rep Folders. Also see the sample program for download at http://www.logicbasic.net/download/AccessDatebook.zip.

8
News and announcements / In progress the ebook "Logic Basic - The Bible"
« on: December 15, 2017, 04:31:10 AM »
Soon the ebook titled "Logic Basic - The Bible" will be completed, explaining in detail all aspects of the language, teaching the development of practical applications, and including complete documentation of all commands and functions.

9
Discussions about Logic Basic / Re: Images and Pictures
« on: December 07, 2017, 05:32:53 AM »
Use the Resize method to decrease or enlarge the image to any dimension, for example:

Image Test, "Test.jpg"
Image Test.Lin = 0
Image Test.Col = 0
Image Test.Height = 15
Image Test.Width = 30
Image Test.Resize, 15, 30

This method does not appear in LB Help, but I will update it soon.


10
Discussions about Logic Basic / Re: Why Doesn't This Work?
« on: December 01, 2017, 04:55:40 AM »
It's a bug. I'll make the correction then I'll announce here. But if you put a button before testing the value, the program works correctly:

Currency txtOwed, 3, 50, 10
Currency txtOwed.Value = -3850.00
Currency txtOwed.places = 2

Button OK, 5, 50
Wait ClickButton

If txtOwed.Value < 0
  Currency txtOwed.ForeColor = Red
Else
  Currency txtOwed.ForeColor = DarkGreen
EndIf

11
Discussions about Logic Basic / Re: Mask
« on: December 01, 2017, 04:35:33 AM »
Thanks for the suggestions, I have already noted them in my agenda and will soon be providing these changes in the component.

12
Hello Randal,

Yes, I plan to create a complete game in Logic Basic, perhaps with the collaboration of other LB users, I will soon be posting the code in this section.

13
Apps for study and entertainment / Moves a point linearly in any direction
« on: November 27, 2017, 06:34:30 AM »
Function to move a point from an initial line, initial column to an end line, final column, great for creating games to fire in any direction, the function was based on the line generation algorithm at https://www.tutorialspoint.com/computer_graphics/line_generation_algorithm.htm:

Code: [Select]
Window PointSize = 10

Shoot(5, 5, 20, 70) 'Shoot from initial Line, initial Column to final line, final column

EndProgram

Function Shoot(L1 Integer, C1 Integer, L2 Integer, C2 Integer)
  Var DL Integer, DC Integer
  Var Steps Integer, LIncrement Decimal, CIncrement Decimal
  Var L Decimal, C Decimal, V Integer
 
  L = L1; C = C1

  If L2 > L1
    DL = L2 - L1
  Else
    DL = L1 - L2
  EndIf 
  If C2 > C1
    DC = C2 - C1
  Else
    DC = C1 - C2
  EndIf 

  If DL > DC
    Steps = DL
  Else
    Steps = DC
  EndIf 

  LIncrement = DL / Steps
  CIncrement = DC / Steps

  If L1 > L2; Lincrement = Lincrement * (-1); EndIf
  If C1 > C2; Cincrement = Cincrement * (-1); EndIf

  V = 0
  While V < Steps
    Cls
    L += LIncrement
    C += CIncrement
 
    Point L, C, Blue
    Wait Events
    V++
  Loop
EndFunction

14
Discussions about Logic Basic / Re: Runtime error in line 38
« on: November 01, 2017, 04:54:35 AM »
Hello Randal,

Thanks for posting the program with these problems, I'll be providing a fix on LB so that it correctly reports the error, or accept the command without a return variable. It's my wish that you heal yourself soon.

15
Discussions about Logic Basic / Re: Runtime error in line 38
« on: October 31, 2017, 07:10:39 AM »
The ReadRecord function returns a string, so you should put a variable first, even if you do not use it:

DB Customer, "C:\documents", "ABC123"
  custname, String, 20
  city, String, 25
EndDB

Variable i Integer, j Integer, x Integer, y Integer
Variable restart Integer, Ret, T Integer

OpenDB Customer, "ABC123"

T = TotalRecordsDB(Customer)

If T = 0 'no record included
  Customer.custname = "Randy"
  Customer.city = "Lawrenceville"
  AddRecord Customer
 
  Customer.custname = "John"
  Customer.city = "Stone Mountain"
  AddRecord Customer
 
  Customer.custname = "Peggy"
  Customer.city = "Douglasville"
  AddRecord Customer
 
  Customer.custname = "Michelle"
  Customer.city = "Boaz"
  AddRecord Customer
 
  Customer.custname = "Ashley"
  Customer.city = "Alpharetta"
  AddRecord Customer
EndIf

i = 0; T = TotalRecordsDB(Customer) 
While i < T
  Ret = ReadRecord(Customer, i)
  Write Customer.custname, "  ", Customer.city
  i++
Loop
CloseDB Customer

Pages: [1] 2